This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AWR1642BOOST: CLI bypass

Part Number: AWR1642BOOST


Tool/software:

/*
 *   @file  mmw_cli.c
 *
 *   @brief
 *      Mmw (Milli-meter wave) DEMO CLI Implementation
 *
 *  \par
 *  NOTE:
 *      (C) Copyright 2018 Texas Instruments, Inc.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *    Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 *    Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the
 *    distribution.
 *
 *    Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**************************************************************************
 *************************** Include Files ********************************
 **************************************************************************/

/* Standard Include Files. */
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>

/* BIOS/XDC Include Files. */
#include <xdc/runtime/System.h>

/* mmWave SDK Include Files: */
#include <ti/common/sys_common.h>
#include <ti/common/mmwave_sdk_version.h>
#include <ti/drivers/uart/UART.h>
#include <ti/control/mmwavelink/mmwavelink.h>
#include <ti/utils/cli/cli.h>
#include <ti/utils/mathutils/mathutils.h>

/* Demo Include Files */
#include <ti/demo/xwr16xx/mmw/include/mmw_config.h>
#include <ti/demo/xwr16xx/mmw/mss/mmw_mss.h>
#include <ti/demo/utils/mmwdemo_adcconfig.h>
#include <ti/demo/utils/mmwdemo_rfparser.h>

/**************************************************************************
 *************************** Local function prototype****************************
 **************************************************************************/

/* CLI Extended Command Functions */
static int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIMultiObjBeamForming (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLICalibDcRangeSig (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIClutterRemoval (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLISensorStart (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLISensorStop (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIGuiMonSel (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIADCBufCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLICompRangeBiasAndRxChanPhaseCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIMeasureRangeBiasAndRxChanPhaseCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLICfarFovCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIAoAFovCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIExtendedMaxVelocity (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIBpmCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIChirpQualityRxSatMonCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIChirpQualitySigImgMonCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIAnalogMonitorCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLILvdsStreamCfg (int32_t argc, char* argv[]);
static int32_t MmwDemo_CLIConfigDataPort (int32_t argc, char* argv[]);

/**************************************************************************
 *************************** Extern Definitions *******************************
 **************************************************************************/

extern MmwDemo_MSS_MCB    gMmwMssMCB;

/**************************************************************************
 *************************** Local Definitions ****************************
 **************************************************************************/

#define MMWDEMO_DATAUART_MAX_BAUDRATE_SUPPORTED 3125000

/**************************************************************************
 *************************** CLI  Function Definitions **************************
 **************************************************************************/
/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for the sensor start command
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLISensorStart (int32_t argc, char* argv[])
{
    bool        doReconfig = true;
    int32_t     retVal = 0;

    /*  Only following command syntax will be supported 
        sensorStart
        sensorStart 0
    */
    if (argc == 2)
    {
        doReconfig = (bool) atoi (argv[1]);

        if (doReconfig == true)
        {
            CLI_write ("Error: Reconfig is not supported, only argument of 0 is\n"
                       "(do not reconfig, just re-start the sensor) valid\n");
            return -1;
        }
    }
    else
    {
        /* In case there is no argument for sensorStart, always do reconfig */
        doReconfig = true;
    }

    /***********************************************************************************
     * Do sensor state management to influence the sensor actions
     ***********************************************************************************/

    /* Error checking initial state: no partial config is allowed 
       until the first sucessful sensor start state */
    if ((gMmwMssMCB.sensorState == MmwDemo_SensorState_INIT) || 
         (gMmwMssMCB.sensorState == MmwDemo_SensorState_OPENED))
    {
        MMWave_CtrlCfg ctrlCfg;

        /* need to get number of sub-frames so that next function to check
         * pending state can work */
        CLI_getMMWaveExtensionConfig (&ctrlCfg);
        gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames =
            MmwDemo_RFParser_getNumSubFrames(&ctrlCfg);

        if (MmwDemo_isAllCfgInPendingState() == 0)
        {
            CLI_write ("Error: Full configuration must be provided before sensor can be started "
                       "the first time\n");

            /* Although not strictly needed, bring back to the initial value since we
             * are rejecting this first time configuration, prevents misleading debug. */
            gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames = 0;

            return -1;
        }
    }

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: Sensor is already started\n");
        return 0;
    }

    if (doReconfig == false)
    {
         /* User intends to issue sensor start without config, check if no
            config was issued after stop and generate error if this is the case. */
         if (MmwDemo_isAllCfgInNonPendingState() == 0)
         {
             /* Message user differently if all config was issued or partial config was
                issued. */
             if (MmwDemo_isAllCfgInPendingState())
             {
                 CLI_write ("Error: You have provided complete new configuration, "
                            "issue \"sensorStart\" (without argument) if you want it to "
                            "take effect\n");
             }
             else
             {
                 CLI_write ("Error: You have provided partial configuration between stop and this "
                            "command and partial configuration cannot be undone."
                            "Issue the full configuration and do \"sensorStart\" \n");
             }
             return -1;
         }
    }
    else
    {
        /* User intends to issue sensor start with full config, check if all config
           was issued after stop and generate error if  is the case. */
        MMWave_CtrlCfg ctrlCfg;

        /* need to get number of sub-frames so that next function to check
         * pending state can work */
        CLI_getMMWaveExtensionConfig (&ctrlCfg);
        gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames =
            MmwDemo_RFParser_getNumSubFrames(&ctrlCfg);
        
        if (MmwDemo_isAllCfgInPendingState() == 0)
        {
            /* Message user differently if no config was issued or partial config was
               issued. */
            if (MmwDemo_isAllCfgInNonPendingState())
            {
                CLI_write ("Error: You have provided no configuration, "
                           "issue \"sensorStart 0\" OR provide "
                           "full configuration and issue \"sensorStart\"\n");
            }
            else
            {
                CLI_write ("Error: You have provided partial configuration between stop and this "
                           "command and partial configuration cannot be undone."
                           "Issue the full configuration and do \"sensorStart\" \n");
            }
            /* Although not strictly needed, bring back to the initial value since we
             * are rejecting this first time configuration, prevents misleading debug. */
            gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames = 0;
            return -1;
        }
    }

    /***********************************************************************************
     * Retreive and check mmwave Open related config before calling openSensor
     ***********************************************************************************/

    /*  Fill demo's MCB mmWave openCfg structure from the CLI configs*/
    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_INIT)
    {
        /* Get the open configuration: */
        CLI_getMMWaveExtensionOpenConfig (&gMmwMssMCB.cfg.openCfg);
        /* call sensor open */
        retVal = MmwDemo_openSensor(true);
        if(retVal != 0)
        {
            return -1;
        }
        gMmwMssMCB.sensorState = MmwDemo_SensorState_OPENED;    
    }
    else
    {
        /* openCfg related configurations like chCfg, lowPowerMode, adcCfg
         * are only used on the first sensor start. If they are different
         * on a subsequent sensor start, then generate a fatal error
         * so the user does not think that the new (changed) configuration
         * takes effect, the board needs to be reboot for the new
         * configuration to be applied.
         */
        MMWave_OpenCfg openCfg;
        CLI_getMMWaveExtensionOpenConfig (&openCfg);
        /* Compare openCfg->chCfg*/
        if(memcmp((void *)&gMmwMssMCB.cfg.openCfg.chCfg, (void *)&openCfg.chCfg,
                          sizeof(rlChanCfg_t)) != 0)
        {
            MmwDemo_debugAssert(0);
        }
        
        /* Compare openCfg->lowPowerMode*/
        if(memcmp((void *)&gMmwMssMCB.cfg.openCfg.lowPowerMode, (void *)&openCfg.lowPowerMode,
                          sizeof(rlLowPowerModeCfg_t)) != 0)
        {
            MmwDemo_debugAssert(0);
        }
        /* Compare openCfg->adcOutCfg*/
        if(memcmp((void *)&gMmwMssMCB.cfg.openCfg.adcOutCfg, (void *)&openCfg.adcOutCfg,
                          sizeof(rlAdcOutCfg_t)) != 0)
        {
            MmwDemo_debugAssert(0);
        }
    }

    

    /***********************************************************************************
     * Retrieve mmwave Control related config before calling startSensor
     ***********************************************************************************/
    /* Get the mmWave ctrlCfg from the CLI mmWave Extension */
    if(doReconfig)
    {
        /* if MmwDemo_openSensor has non-first time related processing, call here again*/
        /* call sensor config */
        CLI_getMMWaveExtensionConfig (&gMmwMssMCB.cfg.ctrlCfg);
        retVal = MmwDemo_configSensor();
        if(retVal != 0)
        {
            return -1;
        }
    }
    retVal = MmwDemo_startSensor();
    if(retVal != 0)
    {
        return -1;
    }

    /***********************************************************************************
     * Set the state
     ***********************************************************************************/
    gMmwMssMCB.sensorState = MmwDemo_SensorState_STARTED;
    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for the sensor stop command
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLISensorStop (int32_t argc, char* argv[])
{
    if ((gMmwMssMCB.sensorState == MmwDemo_SensorState_STOPPED) ||
        (gMmwMssMCB.sensorState == MmwDemo_SensorState_INIT) ||
        (gMmwMssMCB.sensorState == MmwDemo_SensorState_OPENED))
    {
        CLI_write ("Ignored: Sensor is already stopped\n");
        return 0;
    }

    MmwDemo_stopSensor();

    MmwDemo_resetStaticCfgPendingState();

    gMmwMssMCB.sensorState = MmwDemo_SensorState_STOPPED;
    return 0;
}

static int32_t CLI_Remix_sensorstop()
{
    if ((gMmwMssMCB.sensorState == MmwDemo_SensorState_STOPPED) ||
        (gMmwMssMCB.sensorState == MmwDemo_SensorState_INIT) ||
        (gMmwMssMCB.sensorState == MmwDemo_SensorState_OPENED))
    {
        return 0;
    }

    System_printf("stopping sensor\n");
    MmwDemo_stopSensor();

    System_printf("pending sensor\n");
    MmwDemo_resetStaticCfgPendingState();

    gMmwMssMCB.sensorState = MmwDemo_SensorState_STOPPED;
    return 0;
}

/**
 *  @b Description
 *  @n
 *      Utility function to get sub-frame number
 *
 *  @param[in] argc  Number of arguments
 *  @param[in] argv  Arguments
 *  @param[in] expectedArgc Expected number of arguments
 *  @param[out] subFrameNum Sub-frame Number (0 based)
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIGetSubframe (int32_t argc, char* argv[], int32_t expectedArgc,
                                       int8_t* subFrameNum)
{
    int8_t subframe;
    
    /* Sanity Check: Minimum argument check */
    if (argc != expectedArgc)
    {
        CLI_write ("Error: Invalid usage of the CLI command\n");
        return -1;
    }

    /*Subframe info is always in position 1*/
    subframe = (int8_t) atoi(argv[1]);

    if(subframe >= (int8_t)RL_MAX_SUBFRAMES)
    {
        CLI_write ("Error: Subframe number is invalid\n");
        return -1;
    }

    *subFrameNum = (int8_t)subframe;

    return 0;
}



/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for gui monitoring configuration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIGuiMonSel (int32_t argc, char* argv[])
{
    MmwDemo_GuiMonSel   guiMonSel;
    int8_t              subFrameNum;

    if(MmwDemo_CLIGetSubframe(argc, argv, 8, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize the guiMonSel configuration: */
    memset ((void *)&guiMonSel, 0, sizeof(MmwDemo_GuiMonSel));

    /* Populate configuration: */
    guiMonSel.detectedObjects           = atoi (argv[2]);
    guiMonSel.logMagRange               = atoi (argv[3]);
    guiMonSel.noiseProfile              = atoi (argv[4]);
    guiMonSel.rangeAzimuthHeatMap       = atoi (argv[5]);
    guiMonSel.rangeDopplerHeatMap       = atoi (argv[6]);
    guiMonSel.statsInfo                 = atoi (argv[7]);

    MmwDemo_CfgUpdate((void *)&guiMonSel, MMWDEMO_GUIMONSEL_OFFSET,
        sizeof(MmwDemo_GuiMonSel), subFrameNum);

    return 0;
}


static int32_t CLI_Remix_GuiMonSel (uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6)
{
    MmwDemo_GuiMonSel   guiMonSel;
    int8_t              subFrameNum = -1;

    /* Initialize the guiMonSel configuration: */
    memset ((void *)&guiMonSel, 0, sizeof(MmwDemo_GuiMonSel));

    /* Populate configuration: */
    guiMonSel.detectedObjects           = a1;
    guiMonSel.logMagRange               = a2;
    guiMonSel.noiseProfile              = a3;
    guiMonSel.rangeAzimuthHeatMap       = a4;
    guiMonSel.rangeDopplerHeatMap       = a5;
    guiMonSel.statsInfo                 = a6;

    MmwDemo_CfgUpdate((void *)&guiMonSel, MMWDEMO_GUIMONSEL_OFFSET,
        sizeof(MmwDemo_GuiMonSel), subFrameNum);

    return 0;
}
/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for CFAR configuration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */


static int32_t MmwDemo_CLICfarCfg (int32_t argc, char* argv[])
{
    DPU_CFARCAProc_CfarCfg   cfarCfg;
    uint32_t            procDirection;
    int8_t              subFrameNum = -1;
    float               threshold;


    /* Initialize configuration: */
    memset ((void *)&cfarCfg, 0, sizeof(cfarCfg));

    /* Populate configuration: */
    procDirection             = (uint32_t) atoi (argv[2]);
    cfarCfg.averageMode       = (uint8_t) atoi (argv[3]);
    cfarCfg.winLen            = (uint8_t) atoi (argv[4]);
    cfarCfg.guardLen          = (uint8_t) atoi (argv[5]);
    cfarCfg.noiseDivShift     = (uint8_t) atoi (argv[6]);
    cfarCfg.cyclicMode        = (uint8_t) atoi (argv[7]);
    threshold                 = (float) atof (argv[8]);
    cfarCfg.peakGroupingEn    = (uint8_t) atoi (argv[9]);

    if (threshold > 100.0)
    {
        CLI_write("Error: Maximum value for CFAR thresholdScale is 100.0 dB.\n");
        return -1;
    }

    /* threshold is a float value from 0-100dB. It needs to
       be later converted to linear scale (conversion can only be done
       when the number of virtual antennas is known) before passing it
       to CFAR DPU.
       For now, the threshold will be coded in a 16bit integer in the following
       way:
       suppose threshold is a float represented as XYZ.ABC
       it will be saved as a 16bit integer XYZAB
       that is, 2 decimal cases are saved.*/
    threshold = threshold * MMWDEMO_CFAR_THRESHOLD_ENCODING_FACTOR;
    cfarCfg.thresholdScale    = (uint16_t) threshold;

    /* Save Configuration to use later */
    if (procDirection == 0)
    {
        MmwDemo_CfgUpdate((void *)&cfarCfg, MMWDEMO_CFARCFGRANGE_OFFSET,
                          sizeof(cfarCfg), subFrameNum);
    }
    else
    {
        MmwDemo_CfgUpdate((void *)&cfarCfg, MMWDEMO_CFARCFGDOPPLER_OFFSET,
                          sizeof(cfarCfg), subFrameNum);
    }
    return 0;
}

static int32_t CLI_Remix_CfarCfg (uint32_t a1, uint8_t a2, uint8_t a3, uint8_t a4, uint8_t a5, uint8_t a6, float a7, uint8_t a8)
{
    DPU_CFARCAProc_CfarCfg   cfarCfg;
    uint32_t            procDirection;
    int8_t              subFrameNum = -1;
    float               threshold;

    /* Initialize configuration: */
    memset ((void *)&cfarCfg, 0, sizeof(cfarCfg));

    /* Populate configuration: */
    procDirection             = a1;
    cfarCfg.averageMode       = a2;
    cfarCfg.winLen            = a3;
    cfarCfg.guardLen          = a4;
    cfarCfg.noiseDivShift     = a5;
    cfarCfg.cyclicMode        = a6;
    threshold                 = a7;
    cfarCfg.peakGroupingEn    = a8;

    if (threshold > 100.0)
    {
        System_printf("Error: Maximum value for CFAR thresholdScale is 100.0 dB.\n");
        return -1;
    }

    /* threshold is a float value from 0-100dB. It needs to
       be later converted to linear scale (conversion can only be done
       when the number of virtual antennas is known) before passing it
       to CFAR DPU.
       For now, the threshold will be coded in a 16bit integer in the following
       way:
       suppose threshold is a float represented as XYZ.ABC
       it will be saved as a 16bit integer XYZAB
       that is, 2 decimal cases are saved.*/
    threshold = threshold * MMWDEMO_CFAR_THRESHOLD_ENCODING_FACTOR;
    cfarCfg.thresholdScale    = (uint16_t) threshold;

    /* Save Configuration to use later */
    if (procDirection == 0)
    {
        MmwDemo_CfgUpdate((void *)&cfarCfg, MMWDEMO_CFARCFGRANGE_OFFSET,
                          sizeof(cfarCfg), subFrameNum);
    }
    else
    {
        MmwDemo_CfgUpdate((void *)&cfarCfg, MMWDEMO_CFARCFGDOPPLER_OFFSET,
                          sizeof(cfarCfg), subFrameNum);
    }
    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for CFAR FOV (Field Of View) configuration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLICfarFovCfg (int32_t argc, char* argv[])
{
    DPU_CFARCAProc_FovCfg   fovCfg;
    uint32_t            procDirection;
    int8_t              subFrameNum;

    if(MmwDemo_CLIGetSubframe(argc, argv, 5, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&fovCfg, 0, sizeof(fovCfg));

    /* Populate configuration: */
    procDirection             = (uint32_t) atoi (argv[2]);
    fovCfg.min                = (float) atof (argv[3]);
    fovCfg.max                = (float) atof (argv[4]);

    /* Save Configuration to use later */
    if (procDirection == 0)
    {
        MmwDemo_CfgUpdate((void *)&fovCfg, MMWDEMO_FOVRANGE_OFFSET,
                          sizeof(fovCfg), subFrameNum);
    }
    else
    {
        MmwDemo_CfgUpdate((void *)&fovCfg, MMWDEMO_FOVDOPPLER_OFFSET,
                          sizeof(fovCfg), subFrameNum);
    }
    return 0;
}

static int32_t CLI_Remix_CfarFovCfg (uint32_t a1, float a2, float a3)
{
    DPU_CFARCAProc_FovCfg   fovCfg;
    uint32_t            procDirection;
    int8_t              subFrameNum = -1;

    /* Initialize configuration: */
    memset ((void *)&fovCfg, 0, sizeof(fovCfg));

    /* Populate configuration: */
    procDirection             = a1;
    fovCfg.min                = a2;
    fovCfg.max                = a3;

    /* Save Configuration to use later */
    if (procDirection == 0)
    {
        MmwDemo_CfgUpdate((void *)&fovCfg, MMWDEMO_FOVRANGE_OFFSET,
                          sizeof(fovCfg), subFrameNum);
    }
    else
    {
        MmwDemo_CfgUpdate((void *)&fovCfg, MMWDEMO_FOVDOPPLER_OFFSET,
                          sizeof(fovCfg), subFrameNum);
    }
    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for AoA FOV (Field Of View) configuration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIAoAFovCfg (int32_t argc, char* argv[])
{
    DPU_AoAProc_FovAoaCfg   fovCfg;
    int8_t              subFrameNum;

    if(MmwDemo_CLIGetSubframe(argc, argv, 6, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&fovCfg, 0, sizeof(fovCfg));

    /* Populate configuration: */
    fovCfg.minAzimuthDeg      = (float) atoi (argv[2]);
    fovCfg.maxAzimuthDeg      = (float) atoi (argv[3]);
    fovCfg.minElevationDeg    = (float) atoi (argv[4]);
    fovCfg.maxElevationDeg    = (float) atoi (argv[5]);

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&fovCfg, MMWDEMO_FOVAOA_OFFSET,
                      sizeof(fovCfg), subFrameNum);
    return 0;
}

static int32_t CLI_Remix_AoAFovCfg (float a1, float a2, float a3, float a4)
{
    DPU_AoAProc_FovAoaCfg   fovCfg;
    int8_t              subFrameNum = -1;

    /* Initialize configuration: */
    memset ((void *)&fovCfg, 0, sizeof(fovCfg));

    /* Populate configuration: */
    fovCfg.minAzimuthDeg      = a1;
    fovCfg.maxAzimuthDeg      = a2;
    fovCfg.minElevationDeg    = a3;
    fovCfg.maxElevationDeg    = a4;

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&fovCfg, MMWDEMO_FOVAOA_OFFSET,
                      sizeof(fovCfg), subFrameNum);
    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for extended maximum velocity configuration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIExtendedMaxVelocity (int32_t argc, char* argv[])
{
    DPU_AoAProc_ExtendedMaxVelocityCfg   cfg;
    int8_t              subFrameNum;

    if(MmwDemo_CLIGetSubframe(argc, argv, 3, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled      = (uint8_t) atoi (argv[2]);

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_EXTMAXVEL_OFFSET,
                      sizeof(cfg), subFrameNum);
    return 0;
}

static int32_t CLI_Remix_ExtendedMaxVelocity (uint8_t a1)
{
    DPU_AoAProc_ExtendedMaxVelocityCfg   cfg;
    int8_t              subFrameNum = -1;

    /* Initialize configuration: */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled      = a1;

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_EXTMAXVEL_OFFSET,
                      sizeof(cfg), subFrameNum);
    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for multi object beam forming configuration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIMultiObjBeamForming (int32_t argc, char* argv[])
{
    DPU_AoAProc_MultiObjBeamFormingCfg cfg;
    int8_t              subFrameNum;

    if(MmwDemo_CLIGetSubframe(argc, argv, 4, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled                     = (uint8_t) atoi (argv[2]);
    cfg.multiPeakThrsScal           = (float) atof (argv[3]);

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_MULTIOBJBEAMFORMING_OFFSET,
                      sizeof(cfg), subFrameNum);

    return 0;
}

static int32_t CLI_Remix_MultiObjBeamForming (uint8_t a1, float a2)
{
    DPU_AoAProc_MultiObjBeamFormingCfg cfg;
    int8_t              subFrameNum = -1;

    /* Initialize configuration: */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled                     = a1;
    cfg.multiPeakThrsScal           = a2;

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_MULTIOBJBEAMFORMING_OFFSET,
                      sizeof(cfg), subFrameNum);

    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for DC range calibration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLICalibDcRangeSig (int32_t argc, char* argv[])
{
    DPU_RangeProc_CalibDcRangeSigCfg cfg;
    uint32_t                   log2NumAvgChirps;
    int8_t                     subFrameNum;

    if(MmwDemo_CLIGetSubframe(argc, argv, 6, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration for DC range signature calibration */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled          = (uint16_t) atoi (argv[2]);
    cfg.negativeBinIdx   = (int16_t)  atoi (argv[3]);
    cfg.positiveBinIdx   = (int16_t)  atoi (argv[4]);
    cfg.numAvgChirps     = (uint16_t) atoi (argv[5]);

    if (cfg.negativeBinIdx > 0)
    {
        CLI_write ("Error: Invalid negative bin index\n");
        return -1;
    }

    if (cfg.positiveBinIdx < 0)
    {
        CLI_write ("Error: Invalid positive bin index\n");
        return -1;
    }

    if ((cfg.positiveBinIdx - cfg.negativeBinIdx + 1) > DPU_RANGEPROC_SIGNATURE_COMP_MAX_BIN_SIZE)
    {
        CLI_write ("Error: Number of bins exceeds the limit\n");
        return -1;
    }
    log2NumAvgChirps = (uint32_t) mathUtils_ceilLog2(cfg.numAvgChirps);
    if (cfg.numAvgChirps != (1U << log2NumAvgChirps))
    {
        CLI_write ("Error: Number of averaged chirps is not power of two\n");
        return -1;
    }

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_CALIBDCRANGESIG_OFFSET,
                      sizeof(cfg), subFrameNum);

    return 0;
}

static int32_t CLI_Remix_CalibDcRangeSig (uint16_t a1, int16_t a2, int16_t a3, uint16_t a4)
{
    DPU_RangeProc_CalibDcRangeSigCfg cfg;
    uint32_t                   log2NumAvgChirps;
    int8_t                     subFrameNum = -1;

    /* Initialize configuration for DC range signature calibration */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled          = a1;
    cfg.negativeBinIdx   = a2;
    cfg.positiveBinIdx   = a3;
    cfg.numAvgChirps     = a4;

    if (cfg.negativeBinIdx > 0)
    {
        System_printf("Error: Invalid negative bin index\n");
        return -1;
    }

    if (cfg.positiveBinIdx < 0)
    {
        System_printf("Error: Invalid positive bin index\n");
        return -1;
    }

    if ((cfg.positiveBinIdx - cfg.negativeBinIdx + 1) > DPU_RANGEPROC_SIGNATURE_COMP_MAX_BIN_SIZE)
    {
        System_printf("Error: Number of bins exceeds the limit\n");
        return -1;
    }
    log2NumAvgChirps = (uint32_t) mathUtils_ceilLog2(cfg.numAvgChirps);
    if (cfg.numAvgChirps != (1U << log2NumAvgChirps))
    {
        System_printf("Error: Number of averaged chirps is not power of two\n");
        return -1;
    }

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_CALIBDCRANGESIG_OFFSET,
                      sizeof(cfg), subFrameNum);

    return 0;
}

/**
 *  @b Description
 *  @n
 *      Clutter removal Configuration
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIClutterRemoval (int32_t argc, char* argv[])
{
    DPC_ObjectDetection_StaticClutterRemovalCfg_Base cfg;
    int8_t              subFrameNum;

    if(MmwDemo_CLIGetSubframe(argc, argv, 3, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration for clutter removal */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled          = (uint16_t) atoi (argv[2]);

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_STATICCLUTTERREMOFVAL_OFFSET,
                      sizeof(cfg), subFrameNum);

    return 0;
}

static int32_t CLI_Remix_ClutterRemoval (uint16_t a1)
{
    DPC_ObjectDetection_StaticClutterRemovalCfg_Base cfg;
    int8_t              subFrameNum = -1;

    /* Initialize configuration for clutter removal */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled          = a1;

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg, MMWDEMO_STATICCLUTTERREMOFVAL_OFFSET,
                      sizeof(cfg), subFrameNum);

    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for data logger set command
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIADCBufCfg (int32_t argc, char* argv[])
{
    MmwDemo_ADCBufCfg   adcBufCfg;
    int8_t              subFrameNum;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    if(MmwDemo_CLIGetSubframe(argc, argv, 6, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize the ADC Output configuration: */
    memset ((void *)&adcBufCfg, 0, sizeof(adcBufCfg));

    /* Populate configuration: */
    adcBufCfg.adcFmt          = (uint8_t) atoi (argv[2]);
    adcBufCfg.iqSwapSel       = (uint8_t) atoi (argv[3]);
    adcBufCfg.chInterleave    = (uint8_t) atoi (argv[4]);
    adcBufCfg.chirpThreshold  = (uint8_t) atoi (argv[5]);

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&adcBufCfg,
                      MMWDEMO_ADCBUFCFG_OFFSET,
                      sizeof(MmwDemo_ADCBufCfg), subFrameNum);
    return 0;
}

static int32_t CLI_Remix_ADCBufCfg (uint8_t a1, uint8_t a2, uint8_t a3, uint8_t a4)
{
    MmwDemo_ADCBufCfg   adcBufCfg;
    int8_t              subFrameNum = -1;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {

        return 0;
    }

    /* Initialize the ADC Output configuration: */
    memset ((void *)&adcBufCfg, 0, sizeof(adcBufCfg));

    /* Populate configuration: */
    adcBufCfg.adcFmt          = a1;
    adcBufCfg.iqSwapSel       = a2;
    adcBufCfg.chInterleave    = a3;
    adcBufCfg.chirpThreshold  = a4;

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&adcBufCfg,
                      MMWDEMO_ADCBUFCFG_OFFSET,
                      sizeof(MmwDemo_ADCBufCfg), subFrameNum);
    return 0;
}


/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for compensation of range bias and channel phase offsets
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLICompRangeBiasAndRxChanPhaseCfg (int32_t argc, char* argv[])
{
    DPU_AoAProc_compRxChannelBiasCfg   cfg;
    int32_t Re, Im;
    int32_t argInd;
    int32_t i;

    /* Sanity Check: Minimum argument check */
    if (argc != (1+1+SYS_COMMON_NUM_TX_ANTENNAS*SYS_COMMON_NUM_RX_CHANNEL*2))
    {
        CLI_write ("Error: Invalid usage of the CLI command\n");
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.rangeBias          = (float) atof (argv[1]);

    argInd = 2;
    for (i=0; i < SYS_COMMON_NUM_TX_ANTENNAS*SYS_COMMON_NUM_RX_CHANNEL; i++)
    {
        Re = (int32_t) (atof (argv[argInd++]) * 32768.);
        MATHUTILS_SATURATE16(Re);
        cfg.rxChPhaseComp[i].real = (int16_t) Re;

        Im = (int32_t) (atof (argv[argInd++]) * 32768.);
        MATHUTILS_SATURATE16(Im);
        cfg.rxChPhaseComp[i].imag = (int16_t) Im;

    }
    /* Save Configuration to use later */
    memcpy((void *) &gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.compRxChanCfg,
           &cfg, sizeof(cfg));

    gMmwMssMCB.objDetCommonCfg.isCompRxChannelBiasCfgPending = 1;

    return 0;
}


/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for measurement configuration of range bias
 *      and channel phase offsets
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIMeasureRangeBiasAndRxChanPhaseCfg (int32_t argc, char* argv[])
{
    DPC_ObjectDetection_MeasureRxChannelBiasCfg   cfg;

    /* Sanity Check: Minimum argument check */
    if (argc != 4)
    {
        CLI_write ("Error: Invalid usage of the CLI command\n");
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&cfg, 0, sizeof(cfg));

    /* Populate configuration: */
    cfg.enabled          = (uint8_t) atoi (argv[1]);
    cfg.targetDistance   = (float) atof (argv[2]);
    cfg.searchWinSize   = (float) atof (argv[3]);

    /* Save Configuration to use later */
    memcpy((void *) &gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.measureRxChannelBiasCfg,
           &cfg, sizeof(cfg));

    gMmwMssMCB.objDetCommonCfg.isMeasureRxChannelBiasCfgPending = 1;

    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for BPM configuration supported by the mmw Demo
 *      Note that there is a generic BPM configuration command supported by
 *      utils/cli and mmwave. The generic BPM command is not supported by the
 *      demo as the mmw demo assumes a specific BPM pattern for the TX antennas.
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIBpmCfg (int32_t argc, char* argv[])
{
    int8_t              subFrameNum;
    MmwDemo_BpmCfg      bpmCfg;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    /* Sanity Check: Minimum argument check */
    if (argc != 5)
    {
        CLI_write ("Error: Invalid usage of the CLI command\n");
        return -1;
    }

    if(MmwDemo_CLIGetSubframe(argc, argv, 5, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration for DC range signature calibration */
    memset ((void *)&bpmCfg, 0, sizeof(MmwDemo_BpmCfg));

    /* Populate configuration: */
    bpmCfg.isEnabled = (bool) atoi(argv[2]) ;
    bpmCfg.chirp0Idx = (uint16_t) atoi(argv[3]) ;
    bpmCfg.chirp1Idx = (uint16_t) atoi(argv[4]) ;

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&bpmCfg, MMWDEMO_BPMCFG_OFFSET,
                      sizeof(MmwDemo_BpmCfg), subFrameNum);

    return 0;
}

static int32_t CLI_Remix_BpmCfg (bool a1, uint16_t a2, uint16_t a3)
{
    int8_t              subFrameNum = -1;
    MmwDemo_BpmCfg      bpmCfg;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        return 0;
    }

    /* Initialize configuration for DC range signature calibration */
    memset ((void *)&bpmCfg, 0, sizeof(MmwDemo_BpmCfg));

    /* Populate configuration: */
    bpmCfg.isEnabled = a1 ;
    bpmCfg.chirp0Idx = a2 ;
    bpmCfg.chirp1Idx = a3 ;

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&bpmCfg, MMWDEMO_BPMCFG_OFFSET,
                      sizeof(MmwDemo_BpmCfg), subFrameNum);

    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for configuring CQ RX Saturation monitor
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIChirpQualityRxSatMonCfg (int32_t argc, char* argv[])
{
    rlRxSatMonConf_t        cqSatMonCfg;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    /* Sanity Check: Minimum argument check */
    if (argc != 6)
    {
        CLI_write ("Error: Invalid usage of the CLI command\n");
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&cqSatMonCfg, 0, sizeof(rlRxSatMonConf_t));

    /* Populate configuration: */
    cqSatMonCfg.profileIndx                 = (uint8_t) atoi (argv[1]);

    if(cqSatMonCfg.profileIndx < RL_MAX_PROFILES_CNT)
    {

        cqSatMonCfg.satMonSel                   = (uint8_t) atoi (argv[2]);
        cqSatMonCfg.primarySliceDuration        = (uint16_t) atoi (argv[3]);
        cqSatMonCfg.numSlices                   = (uint16_t) atoi (argv[4]);
        cqSatMonCfg.rxChannelMask               = (uint8_t) atoi (argv[5]);

        /* Save Configuration to use later */
        gMmwMssMCB.cqSatMonCfg[cqSatMonCfg.profileIndx] = cqSatMonCfg;

        return 0;
    }
    else
    {
        return -1;
    }
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for configuring CQ Signal & Image band monitor
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIChirpQualitySigImgMonCfg (int32_t argc, char* argv[])
{
    rlSigImgMonConf_t       cqSigImgMonCfg;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    /* Sanity Check: Minimum argument check */
    if (argc != 4)
    {
        CLI_write ("Error: Invalid usage of the CLI command\n");
        return -1;
    }

    /* Initialize configuration: */
    memset ((void *)&cqSigImgMonCfg, 0, sizeof(rlSigImgMonConf_t));

    /* Populate configuration: */
    cqSigImgMonCfg.profileIndx              = (uint8_t) atoi (argv[1]);

    if(cqSigImgMonCfg.profileIndx < RL_MAX_PROFILES_CNT)
    {
        cqSigImgMonCfg.numSlices            = (uint8_t) atoi (argv[2]);
        cqSigImgMonCfg.timeSliceNumSamples  = (uint16_t) atoi (argv[3]);

        /* Save Configuration to use later */
        gMmwMssMCB.cqSigImgMonCfg[cqSigImgMonCfg.profileIndx] = cqSigImgMonCfg;

        return 0;
    }
    else
    {
        return -1;
    }
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for enabling analog monitors
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIAnalogMonitorCfg (int32_t argc, char* argv[])
{
    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    /* Sanity Check: Minimum argument check */
    if (argc != 3)
    {
        CLI_write ("Error: Invalid usage of the CLI command\n");
        return -1;
    }

    /* Save Configuration to use later */
    gMmwMssMCB.anaMonCfg.rxSatMonEn = atoi (argv[1]);
    gMmwMssMCB.anaMonCfg.sigImgMonEn = atoi (argv[2]);

    gMmwMssMCB.isAnaMonCfgPending = 1;

    return 0;
}


/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for the High Speed Interface
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLILvdsStreamCfg (int32_t argc, char* argv[])
{
    MmwDemo_LvdsStreamCfg   cfg;
    int8_t                  subFrameNum;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    if(MmwDemo_CLIGetSubframe(argc, argv, 5, &subFrameNum) < 0)
    {
        return -1;
    }

    /* Initialize configuration for DC range signature calibration */
    memset ((void *)&cfg, 0, sizeof(MmwDemo_LvdsStreamCfg));

    /* Populate configuration: */
    cfg.isHeaderEnabled = (bool)    atoi(argv[2]);
    cfg.dataFmt         = (uint8_t) atoi(argv[3]);
    cfg.isSwEnabled     = (bool)    atoi(argv[4]);

    /* If both h/w and s/w are enabled, HSI header must be enabled, because
     * we don't allow mixed h/w session without HSI header
     * simultaneously with s/w session with HSI header (s/w session always
     * streams HSI header) */
    if ((cfg.isSwEnabled == true) && (cfg.dataFmt != MMW_DEMO_LVDS_STREAM_CFG_DATAFMT_DISABLED))
    {
        if (cfg.isHeaderEnabled == false)
        {
            CLI_write("Error: header must be enabled when both h/w and s/w streaming are enabled\n");
            return -1;
        }
    }

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg,
                      MMWDEMO_LVDSSTREAMCFG_OFFSET,
                      sizeof(MmwDemo_LvdsStreamCfg), subFrameNum);

    return 0;
}

static int32_t CLI_Remix_LvdsStreamCfg (bool a1, uint8_t a2, bool a3)
{
    MmwDemo_LvdsStreamCfg   cfg;
    int8_t                  subFrameNum = -1;

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        return 0;
    }

    /* Initialize configuration for DC range signature calibration */
    memset ((void *)&cfg, 0, sizeof(MmwDemo_LvdsStreamCfg));

    /* Populate configuration: */
    cfg.isHeaderEnabled = a1;
    cfg.dataFmt         = a2;
    cfg.isSwEnabled     = a3;

    /* If both h/w and s/w are enabled, HSI header must be enabled, because
     * we don't allow mixed h/w session without HSI header
     * simultaneously with s/w session with HSI header (s/w session always
     * streams HSI header) */
    if ((cfg.isSwEnabled == true) && (cfg.dataFmt != MMW_DEMO_LVDS_STREAM_CFG_DATAFMT_DISABLED))
    {
        if (cfg.isHeaderEnabled == false)
        {
            return -1;
        }
    }

    /* Save Configuration to use later */
    MmwDemo_CfgUpdate((void *)&cfg,
                      MMWDEMO_LVDSSTREAMCFG_OFFSET,
                      sizeof(MmwDemo_LvdsStreamCfg), subFrameNum);

    return 0;
}


/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for configuring the data port
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIConfigDataPort (int32_t argc, char* argv[])
{
    uint32_t baudrate;
    bool  ackPing;
    UART_Params uartParams;
    uint8_t ackData[16];
    

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    /* Populate configuration: */
    baudrate = (uint32_t) atoi(argv[1]);
    ackPing = (bool) atoi(argv[2]);

    /* check if requested value is less than max supported value */
    if (baudrate > MMWDEMO_DATAUART_MAX_BAUDRATE_SUPPORTED)
    {
        CLI_write ("Ignored: Invalid baud rate (%d) specified\n",baudrate);
        return 0;
    }

    /* re-open UART port if requested baud rate is different than current */
    if (gMmwMssMCB.cfg.platformCfg.loggingBaudRate != baudrate)
    {
        /* close previous opened handle */
        /* since the sensor is not running at this time, it is safe to close
           the existing port */
        if (gMmwMssMCB.loggingUartHandle != NULL)
        {
            UART_close(gMmwMssMCB.loggingUartHandle);
            gMmwMssMCB.loggingUartHandle = NULL;
        }   
        
        /* Setup the default UART Parameters */
        UART_Params_init(&uartParams);
        uartParams.writeDataMode  = UART_DATA_BINARY;
        uartParams.readDataMode   = UART_DATA_BINARY;
        uartParams.clockFrequency = gMmwMssMCB.cfg.platformCfg.sysClockFrequency;
        uartParams.baudRate       = baudrate;
        uartParams.isPinMuxDone   = 1U;

        /* Open the Logging UART Instance: */
        gMmwMssMCB.loggingUartHandle = UART_open(1, &uartParams);
        if (gMmwMssMCB.loggingUartHandle == NULL)
        {
            CLI_write ("Error: Unable to open the Logging UART Instance\n");
            return -1;
        }
        gMmwMssMCB.cfg.platformCfg.loggingBaudRate = baudrate;
        CLI_write ("Data port baud rate changed to %d\n",baudrate);
    }

    /* regardless of baud rate update, ack back to the host over this UART 
       port if handle is valid and user has requested the ack back */
    if ((gMmwMssMCB.loggingUartHandle != NULL) && (ackPing == true))
    {
        memset(ackData,0xFF,sizeof(ackData));
        UART_writePolling (gMmwMssMCB.loggingUartHandle,
                           (uint8_t*)ackData,
                           sizeof(ackData));
    }

    return 0;
}


/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for querying Demo status
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLIQueryDemoStatus (int32_t argc, char* argv[])
{
    CLI_write ("Sensor State: %d\n",gMmwMssMCB.sensorState);
    CLI_write ("Data port baud rate: %d\n",gMmwMssMCB.cfg.platformCfg.loggingBaudRate);

    return 0;
}

/**
 *  @b Description
 *  @n
 *      This is the CLI Handler for save/restore calibration data to/from flash
 *
 *  @param[in] argc
 *      Number of arguments
 *  @param[in] argv
 *      Arguments
 *
 *  @retval
 *      Success -   0
 *  @retval
 *      Error   -   <0
 */
static int32_t MmwDemo_CLICalibDataSaveRestore(int32_t argc, char* argv[])
{
    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        CLI_write ("Ignored: This command is not allowed after sensor has started\n");
        return 0;
    }

    /* Validate inputs */
    if ( ((uint32_t) atoi(argv[1]) == 1) && ((uint32_t) atoi(argv[2] ) == 1))
    {
        CLI_write ("Error: Save and Restore can be enabled only one at a time\n");
        return -1;
    }

    /* Populate configuration: */
    gMmwMssMCB.calibCfg.saveEnable = (uint32_t) atoi(argv[1]);
    gMmwMssMCB.calibCfg.restoreEnable = (uint32_t) atoi(argv[2]);
    sscanf(argv[3], "0x%x", &gMmwMssMCB.calibCfg.flashOffset);

    gMmwMssMCB.isCalibCfgPending = 1;

    return 0;
}

//implementing the mmw_cli without cli as referenced in mss_main.c line 451

//Task_Struct MmwDemo_sensorConfig_task;
uint8_t sensorTaskStack[2048];



#include <ti/drivers/gpio/gpio.h>
#include <ti/drivers/mailbox/mailbox.h>
#include <ti/drivers/pinmux/pinmux.h>

static void sensorConfig_taskFxn(UArg a0, UArg a1);

extern uint8_t MmwDemo_isAllCfgInPendingState(void);

void set_Offsets()
{
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_ADCBUFCFG_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_BPMCFG_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_LVDSSTREAMCFG_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_GUIMONSEL_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_CFARCFGRANGE_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_CFARCFGDOPPLER_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_FOVRANGE_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_FOVDOPPLER_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_FOVAOA_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_MULTIOBJBEAMFORMING_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_CALIBDCRANGESIG_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_STATICCLUTTERREMOFVAL_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);
//    MmwDemo_CfgUpdate((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg, MMWDEMO_EXTMAXVEL_OFFSET, sizeof(gMmwMssMCB.cfg.ctrlCfg.u.frameCfg), 0);


    gMmwMssMCB.isCalibCfgPending = 1;
    gMmwMssMCB.isAnaMonCfgPending = 1;

    gMmwMssMCB.objDetCommonCfg.isMeasureRxChannelBiasCfgPending = 1;
    gMmwMssMCB.objDetCommonCfg.isCompRxChannelBiasCfgPending = 1;
}


static void sensorConfig_taskFxn(UArg a0, UArg a1){
    Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINK13_PADAZ, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
    Pinmux_Set_FuncSel(SOC_XWR16XX_PINK13_PADAZ, SOC_XWR16XX_PINK13_PADAZ_GPIO_2);
    GPIO_setConfig(SOC_XWR16XX_GPIO_2, GPIO_CFG_OUTPUT);


    //openCfg filling
    gMmwMssMCB.cfg.openCfg.adcOutCfg.fmt.b2AdcBits = 2;
    gMmwMssMCB.cfg.openCfg.adcOutCfg.fmt.b8FullScaleReducFctr = 0;
    gMmwMssMCB.cfg.openCfg.adcOutCfg.fmt.b2AdcOutFmt = 1;
    gMmwMssMCB.cfg.openCfg.calibMonTimeUnit = 100;
    gMmwMssMCB.cfg.openCfg.chCfg.txChannelEn = 3;
    gMmwMssMCB.cfg.openCfg.chCfg.rxChannelEn = 15;
    gMmwMssMCB.cfg.openCfg.chCfg.cascading = 0;
    gMmwMssMCB.cfg.openCfg.chCfg.cascadingPinoutCfg = 0;
    gMmwMssMCB.cfg.openCfg.customCalibrationEnableMask = 0;
    gMmwMssMCB.cfg.openCfg.defaultAsyncEventHandler = MMWave_DefaultAsyncEventHandler_MSS;
    gMmwMssMCB.cfg.openCfg.disableFrameStartAsyncEvent = 0;
    gMmwMssMCB.cfg.openCfg.disableFrameStopAsyncEvent = 0;
    gMmwMssMCB.cfg.openCfg.freqLimitHigh = 81;
    gMmwMssMCB.cfg.openCfg.freqLimitLow = 76;
    gMmwMssMCB.cfg.openCfg.lowPowerMode.lpAdcMode = 0x01;
    gMmwMssMCB.cfg.openCfg.useCustomCalibration = 1;

    //ctrlCfg filling
    gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode = MMWave_DFEDataOutputMode_FRAME;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.profileHandle[0] = NULL;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.profileHandle[1] = NULL;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.profileHandle[2] = NULL;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.profileHandle[3] = NULL;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.chirpEndIdx = 0;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.chirpStartIdx = 0;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.framePeriodicity = 8000000;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.frameTriggerDelay = 0;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.numAdcSamples = 256;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.numDummyChirpsAtEnd = 0;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.numFrames = 8;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.numLoops = 128;
    gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.triggerSelect = 1;

    rlProfileCfg_t          profileCfg;
    int32_t                 errCode;
    /* Chirp used in frame is not configured by Chirp config */

    memset ((void *)&profileCfg, 0, sizeof(rlProfileCfg_t));

    profileCfg.profileId             = 0;

    /* Translate from GHz to [1 LSB = gCLI_mmwave_freq_scale_factor * 1e9 / 2^26 Hz] units
     * of mmwavelink format */
    profileCfg.startFreqConst        = 0x558E4BBC;

    /* Translate below times from us to [1 LSB = 10 ns] units of mmwavelink format */
    profileCfg.idleTimeConst         = 10000;
    profileCfg.adcStartTimeConst     = 600;
    profileCfg.rampEndTime           = 6000;

    profileCfg.txOutPowerBackoffCode = 0;
    profileCfg.txPhaseShifter        = 0;

    /* Translate from MHz/us to [1 LSB = (gCLI_mmwave_freq_scale_factor * 1e6 * 900) / 2^26 kHz/uS]
     * units of mmwavelink format */
    profileCfg.freqSlopeConst        = 600;

    /* Translate from us to [1 LSB = 10 ns] units of mmwavelink format */
    profileCfg.txStartTime           = 0;

    profileCfg.numAdcSamples         = 256;
    profileCfg.digOutSampleRate      = 6000;
    profileCfg.hpfCornerFreq1        = 0x00;
    profileCfg.hpfCornerFreq2        = 0x00;
    profileCfg.rxGain                = 0;

    System_printf("adding profile\n");

    MMWave_addProfile(gMmwMssMCB.ctrlHandle, &profileCfg, &errCode);

    rlChirpCfg_t            chirpCfg;
    MMWave_ProfileHandle    profileHandle;

    memset ((void *)&chirpCfg, 0, sizeof(rlChirpCfg_t));

    /* Populate the chirp configuration: */
    chirpCfg.chirpStartIdx   = 0;
    chirpCfg.chirpEndIdx     = 0;
    chirpCfg.profileId       = 0;

    /* Translate from Hz to number of [1 LSB = (gCLI_mmwave_freq_scale_factor * 1e9) / 2^26 Hz]
     * units of mmwavelink format */
    chirpCfg.startFreqVar    = 0;

    /* Translate from KHz/us to number of [1 LSB = (gCLI_mmwave_freq_scale_factor * 1e6) * 900 /2^26 KHz/us]
     * units of mmwavelink format */
    chirpCfg.freqSlopeVar    = 0;

    /* Translate from us to [1 LSB = 10ns] units of mmwavelink format */
    chirpCfg.idleTimeVar     = 0;

    /* Translate from us to [1 LSB = 10ns] units of mmwavelink format */
    chirpCfg.adcStartTimeVar = 0;

    chirpCfg.txEnable        = 3;

    System_printf("getting profile handle\n");

    /* Get the profile handle to which the chirp is to be added: */
    if (MMWave_getProfileHandle (gMmwMssMCB.ctrlHandle, chirpCfg.profileId,
                                 &profileHandle, &errCode) < 0)
    {
            /* Error: Unable to get the profile handle. Return the error code */
        return;
    }


    System_printf("adding chirp\n");

    /* Add the chirp to the profile */
    if (MMWave_addChirp (profileHandle, &chirpCfg, &errCode) == NULL)
    {
        /* Error: Unable to add the chirp. Return the error code. */
        return;
    }


    set_Offsets();

    DPM_ioctl(gMmwMssMCB.objDetDpmHandle,
              DPC_OBJDET_IOCTL__STATIC_PRE_START_COMMON_CFG,
              &gMmwMssMCB.objDetCommonCfg.preStartCommonCfg,
              sizeof (DPC_ObjectDetection_PreStartCommonCfg));

    int result = MmwDemo_isAllCfgInPendingState();

    MmwDemo_openSensor(true);
    MmwDemo_configSensor();
    MmwDemo_startSensor();


    int count = 0;
    while (count<50)
    {
        Task_sleep(300);
        GPIO_toggle(SOC_XWR16XX_GPIO_2);
        count++;
    }

}




////ti wechat attempt
void CLI_Remix_profileCfg(int a1,float a2,float a3,float a4,float a5,int a6,int a7,float a8,float a9,int a10,int a11,int a12,int a13,int a14)
{
    rlProfileCfg_t          profileCfg;
    uint8_t                 index;
    int32_t                 errCode;
    MMWave_ProfileHandle    profileHandle;
    MMWave_ProfileHandle*   ptrBaseCfgProfileHandle;

    double mmwave_freq_scale_factor = SOC_getDeviceRFFreqScaleFactor(gMmwMssMCB.socHandle, &errCode);

    gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode = MMWave_DFEDataOutputMode_FRAME;

    /* Sanity Check: Profile configuration is valid only for the Frame or
                     Advanced Frame Mode: */
    if ((gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_FRAME) &&
        (gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_ADVANCED_FRAME))
    {
        //CLI_write ("Error: Configuration is valid only if the DFE Output Mode is Frame or Advanced Frame\n");
        return;
    }


    if (gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode == MMWave_DFEDataOutputMode_FRAME)
    {
        ptrBaseCfgProfileHandle = &gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.profileHandle[0U];
    }
    else
    {
        ptrBaseCfgProfileHandle = &gMmwMssMCB.cfg.ctrlCfg.u.advancedFrameCfg.profileHandle[0U];
    }

    /* Initialize the profile configuration: */
    memset ((void *)&profileCfg, 0, sizeof(rlProfileCfg_t));

    /* Populate the profile configuration: */
    profileCfg.profileId             = a1;

    /* Translate from GHz to [1 LSB = gCLI_mmwave_freq_scale_factor * 1e9 / 2^26 Hz] units
     * of mmwavelink format */

    profileCfg.startFreqConst        = (uint32_t)(a2*1000000000/53.644);

//    profileCfg.startFreqConst    = (uint32_t) ((float)a2 * (1U << 26) /
//                                            (mmwave_freq_scale_factor * 1e9));

    /* Translate below times from us to [1 LSB = 10 ns] units of mmwavelink format */
    profileCfg.idleTimeConst         = (uint32_t)((float)a3 * 1000 / 10);
    profileCfg.adcStartTimeConst     = (uint32_t)((float)a4 * 1000 / 10);
    profileCfg.rampEndTime           = (uint32_t)((float)a5 * 1000 / 10);

    profileCfg.txOutPowerBackoffCode = a6;
    profileCfg.txPhaseShifter        = a7;

    /* Translate from MHz/us to [1 LSB = (gCLI_mmwave_freq_scale_factor * 1e6 * 900) / 2^26 kHz/uS]
     * units of mmwavelink format */
    profileCfg.freqSlopeConst        =     (int16_t)((float)a8 * (1U << 26) /((mmwave_freq_scale_factor * 1e3) * 900.0));

    /* Translate from us to [1 LSB = 10 ns] units of mmwavelink format */
    profileCfg.txStartTime           = (int32_t)(((float)a9) * 1000 / 10);

    profileCfg.numAdcSamples         = a10;
    profileCfg.digOutSampleRate      = a11;
    profileCfg.hpfCornerFreq1        = a12;
    profileCfg.hpfCornerFreq2        = a13;
    profileCfg.rxGain                = a14;

    /* Search for a free space in the mmWave configuration block: */
    for (index = 0U; index < MMWAVE_MAX_PROFILE; index++)
    {
        /* Did we get a free entry? */
        if (ptrBaseCfgProfileHandle[index] == NULL)
        {
            /* YES: We can add the profile. */
            break;
        }
    }
    if (index == MMWAVE_MAX_PROFILE)
    {
        /* Error: All the profiles have been exhausted */
        return;
    }

    /* Add the profile to the mmWave module: */
    profileHandle = MMWave_addProfile (gMmwMssMCB.ctrlHandle, &profileCfg, &errCode);
    if (profileHandle == NULL)
    {
        /* Error: Unable to add the profile. Return the error code back */
        return;
    }

    /* Record the profile: */
    ptrBaseCfgProfileHandle[index] = profileHandle;

    return;
}

void CLI_Remix_chirpCfg(int a1,int a2,int a3,float a4,float a5,float a6,float a7,int a8)
{
    rlChirpCfg_t            chirpCfg;
    MMWave_ProfileHandle    profileHandle;
    int32_t                 errCode;

    double mmwave_freq_scale_factor = SOC_getDeviceRFFreqScaleFactor(gMmwMssMCB.socHandle, &errCode);

    /* Sanity Check: Chirp configuration is valid only for the Frame or
                     Advanced Frame Mode: */
    if ((gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_FRAME) &&
        (gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_ADVANCED_FRAME))
    {
        return;
    }

    /* Initialize the chirp configuration: */
    memset ((void *)&chirpCfg, 0, sizeof(rlChirpCfg_t));

    /* Populate the chirp configuration: */
    chirpCfg.chirpStartIdx   = a1;
    chirpCfg.chirpEndIdx     = a2;
    chirpCfg.profileId       = a3;

    /* Translate from Hz to number of [1 LSB = (gCLI_mmwave_freq_scale_factor * 1e9) / 2^26 Hz]
     * units of mmwavelink format */
    chirpCfg.startFreqVar    = (uint32_t) ((float)a4 * (1U << 26) /
                                            (mmwave_freq_scale_factor * 1e9));


    /* Translate from KHz/us to number of [1 LSB = (gCLI_mmwave_freq_scale_factor * 1e6) * 900 /2^26 KHz/us]
     * units of mmwavelink format */
    chirpCfg.freqSlopeVar    = (uint16_t) ((float)a5 * (1U << 26) /
                                           ((mmwave_freq_scale_factor * 1e6) * 900.0));

    /* Translate from us to [1 LSB = 10ns] units of mmwavelink format */
    chirpCfg.idleTimeVar     = (uint32_t)((float)a6 * 1000.0 / 10.0);

    /* Translate from us to [1 LSB = 10ns] units of mmwavelink format */
    chirpCfg.adcStartTimeVar = (uint32_t)((float)a7 * 1000.0 / 10.0);

    chirpCfg.txEnable        = a8;

    /* Get the profile handle to which the chirp is to be added: */
    if (MMWave_getProfileHandle (gMmwMssMCB.ctrlHandle, chirpCfg.profileId,
                                 &profileHandle, &errCode) < 0)
    {
        /* Error: Unable to get the profile handle. Return the error code */
        return;
    }

    /* Add the chirp to the profile */
    if (MMWave_addChirp (profileHandle, &chirpCfg, &errCode) == NULL)
    {
        /* Error: Unable to add the chirp. Return the error code. */
        return;
    }

    return;
}

void CLI_Remix_frameCfg(int a1,int a2,int a3,int a4,float a5,int a6,float a7)
{
    rlFrameCfg_t    frameCfg;

    /* Sanity Check: Frame configuration is valid only for the Frame or
                     Advanced Frame Mode: */
    if (gMmwMssMCB.cfg.ctrlCfg.dfeDataOutputMode != MMWave_DFEDataOutputMode_FRAME)
    {
        //CLI_write ("Error: Configuration is valid only if the DFE Output Mode is Chirp\n");
        return;
    }

    /* Initialize the frame configuration: */
    memset ((void *)&frameCfg, 0, sizeof(rlFrameCfg_t));

    /* Populate the frame configuration: */
    frameCfg.chirpStartIdx      = a1;
    frameCfg.chirpEndIdx        = a2;
    frameCfg.numLoops           = a3;
    frameCfg.numFrames          = a4;
    frameCfg.framePeriodicity   = (uint32_t)((float)a5 * 1000000 / 5);
    frameCfg.triggerSelect      = a6;
    frameCfg.frameTriggerDelay  = 0; //(uint32_t)((float)a7 * 1000000 / 5);
    frameCfg.numDummyChirpsAtEnd  = 0;
    frameCfg.numAdcSamples  = 0;

    /* Save Configuration to use later */
    memcpy((void *)&gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg, (void *)&frameCfg, sizeof(rlFrameCfg_t));
    return;
}


int CLI_Remix_sensorStart(void)
{
    bool doReconfig = true;
    int32_t     retVal = 0;

    /***********************************************************************************
     * Do sensor state management to influence the sensor actions
     ***********************************************************************************/

    DPM_ioctl(gMmwMssMCB.objDetDpmHandle,
              DPC_OBJDET_IOCTL__STATIC_PRE_START_COMMON_CFG,
              &gMmwMssMCB.objDetCommonCfg.preStartCommonCfg,
              sizeof (DPC_ObjectDetection_PreStartCommonCfg));

    /* Error checking initial state: no partial config is allowed
       until the first sucessful sensor start state */
    if ((gMmwMssMCB.sensorState == MmwDemo_SensorState_INIT) ||
         (gMmwMssMCB.sensorState == MmwDemo_SensorState_OPENED))
    {
        MMWave_CtrlCfg ctrlCfg;

        /* need to get number of sub-frames so that next function to check
         * pending state can work */
        //CLI_getMMWaveExtensionConfig (&ctrlCfg);
        memcpy((void*)&ctrlCfg,(void*)&gMmwMssMCB.cfg.ctrlCfg,sizeof(MMWave_CtrlCfg));
        gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames =
            MmwDemo_RFParser_getNumSubFrames(&ctrlCfg);

        if (MmwDemo_isAllCfgInPendingState() == 0)
        {
            System_printf ("Error: Full configuration must be provided before sensor can be started "
                       "the first time\n");

            /* Although not strictly needed, bring back to the initial value since we
             * are rejecting this first time configuration, prevents misleading debug. */
            gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames = 0;

            return -1;
        }
    }

    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_STARTED)
    {
        System_printf ("Ignored: Sensor is already started\n");
        return 0;
    }

    if (doReconfig == false)
    {
         /* User intends to issue sensor start without config, check if no
            config was issued after stop and generate error if this is the case. */
         if (! MmwDemo_isAllCfgInNonPendingState())
         {
             /* Message user differently if all config was issued or partial config was
                issued. */
             if (MmwDemo_isAllCfgInPendingState())
             {
                 System_printf ("Error: You have provided complete new configuration, "
                            "issue \"sensorStart\" (without argument) if you want it to "
                            "take effect\n");
             }
             else
             {
                 System_printf ("Error: You have provided partial configuration between stop and this "
                            "command and partial configuration cannot be undone."
                            "Issue the full configuration and do \"sensorStart\" \n");
             }
             return -1;
         }
    }
    else
    {
        /* User intends to issue sensor start with full config, check if all config
           was issued after stop and generate error if  is the case. */
        MMWave_CtrlCfg ctrlCfg;

        /* need to get number of sub-frames so that next function to check
         * pending state can work */
        //CLI_getMMWaveExtensionConfig (&ctrlCfg);
        memcpy((void*)&ctrlCfg,(void*)&gMmwMssMCB.cfg.ctrlCfg,sizeof(MMWave_CtrlCfg));
        gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames =
                    MmwDemo_RFParser_getNumSubFrames(&ctrlCfg);

        if (MmwDemo_isAllCfgInPendingState() == 0)
        {
            /* Message user differently if no config was issued or partial config was
               issued. */
            if (MmwDemo_isAllCfgInNonPendingState())
            {
                System_printf ("Error: You have provided no configuration, "
                           "issue \"sensorStart 0\" OR provide "
                           "full configuration and issue \"sensorStart\"\n");
            }
            else
            {
                System_printf ("Error: You have provided partial configuration between stop and this "
                           "command and partial configuration cannot be undone."
                           "Issue the full configuration and do \"sensorStart\" \n");
            }
            /* Although not strictly needed, bring back to the initial value since we
             * are rejecting this first time configuration, prevents misleading debug. */
            gMmwMssMCB.objDetCommonCfg.preStartCommonCfg.numSubFrames = 0;

            return -1;
        }
    }


    /***********************************************************************************
     * Retreive and check mmwave Open related config before calling openSensor
     ***********************************************************************************/

    /*  Fill demo's MCB mmWave openCfg structure from the CLI configs*/
    if (gMmwMssMCB.sensorState == MmwDemo_SensorState_INIT)
    {
        /* Get the open configuration: */
        //CLI_getMMWaveExtensionOpenConfig (&gMmwMCB.cfg.openCfg);
        /* call sensor open */
        System_printf("opening\n");
        retVal = MmwDemo_openSensor(true);
        System_printf("opened\n");
        if(retVal != 0)
        {
            return -1;
        }
        gMmwMssMCB.sensorState = MmwDemo_SensorState_OPENED;
    }
    else
    {
        /* openCfg related configurations like chCfg, lowPowerMode, adcCfg
         * are only used on the first sensor start. If they are different
         * on a subsequent sensor start, then generate a fatal error
         * so the user does not think that the new (changed) configuration
         * takes effect, the board needs to be reboot for the new
         * configuration to be applied.
         */
        MMWave_OpenCfg openCfg;
        //CLI_getMMWaveExtensionOpenConfig (&openCfg);
        memcpy((void*)&openCfg,(void*)&gMmwMssMCB.cfg.openCfg,sizeof(MMWave_OpenCfg));
        /* Compare openCfg->chCfg*/
        if(memcmp((void *)&gMmwMssMCB.cfg.openCfg.chCfg, (void *)&openCfg.chCfg,
                          sizeof(rlChanCfg_t)) != 0)
        {
            System_printf("chCfg changed\n");
            MmwDemo_debugAssert(0);
        }

        /* Compare openCfg->lowPowerMode*/
        if(memcmp((void *)&gMmwMssMCB.cfg.openCfg.lowPowerMode, (void *)&openCfg.lowPowerMode,
                          sizeof(rlLowPowerModeCfg_t)) != 0)
        {
            System_printf("lowPowerMode changed\n");
            MmwDemo_debugAssert(0);
        }
        /* Compare openCfg->adcOutCfg*/
        if(memcmp((void *)&gMmwMssMCB.cfg.openCfg.adcOutCfg, (void *)&openCfg.adcOutCfg,
                          sizeof(rlAdcOutCfg_t)) != 0)
        {
            System_printf("adcOutCfg changed\n");
            MmwDemo_debugAssert(0);
        }
    }



    /***********************************************************************************
     * Retrieve mmwave Control related config before calling startSensor
     ***********************************************************************************/
    /* Get the mmWave ctrlCfg from the CLI mmWave Extension */
    if(doReconfig)
    {
        /* if MmwDemo_openSensor has non-first time related processing, call here again*/
        /* call sensor config */
        //CLI_getMMWaveExtensionConfig (&gMmwMCB.cfg.ctrlCfg);
        // Frame config
        System_printf("FrameCfg: chirpStartIdx=%d, chirpEndIdx=%d, numLoops=%d, numFrames=%d, periodicity=%d [LSB=5ns]\n",
                      gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.chirpStartIdx,
                      gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.chirpEndIdx,
                      gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.numLoops,
                      gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.numFrames,
                      gMmwMssMCB.cfg.ctrlCfg.u.frameCfg.frameCfg.framePeriodicity);

        MMWave_ProfileHandle    profileHandle;
        MMWave_ChirpHandle      chirpHandle;
        int32_t                 errCode;


        MMWave_getProfileHandle(gMmwMssMCB.ctrlHandle, 0, &profileHandle, &errCode);

        MMWave_getChirpHandle(profileHandle, 1, &chirpHandle, &errCode);

        //MMWave_ProfileHandle profileHandle, uint32_t chirpIndex, MMWave_ChirpHandle* chirpHandle, int32_t* errCode);

        rlChirpCfg_t chirpCfg;
        MMWave_getChirpCfg(chirpHandle, &chirpCfg, &errCode);

        // Chirp config
        System_printf("ChirpCfg: startIdx=%d, endIdx=%d, profileId=%d, startFreqVar=%d, slopeVar=%d, idleTime=%d, adcStart=%d, txEnable=%d\n",
                    chirpCfg.chirpStartIdx,
                    chirpCfg.chirpEndIdx,
                    chirpCfg.profileId,
                    chirpCfg.startFreqVar,
                    chirpCfg.freqSlopeVar,
                    chirpCfg.idleTimeVar,
                    chirpCfg.adcStartTimeVar,
                    chirpCfg.txEnable);

        // Profile config


        rlProfileCfg_t profileCfg;
        MMWave_getProfileCfg(profileHandle, &profileCfg, &errCode);


        System_printf("ProfileCfg: profileId=%d, startFreqConst=%d, slopeConst=%d, idleTimeConst=%d, adcStartConst=%d, numAdcSamples=%d, digOutSampleRate=%d\n",
            profileCfg.profileId,
            profileCfg.startFreqConst,
            profileCfg.freqSlopeConst,
            profileCfg.idleTimeConst,
            profileCfg.adcStartTimeConst,
            profileCfg.numAdcSamples,
            profileCfg.digOutSampleRate);

        retVal = MmwDemo_configSensor();
        if(retVal != 0)
        {
            return -1;
        }
    }

    retVal = MmwDemo_startSensor();



    if(retVal != 0)
    {
        return -1;
    }



    /***********************************************************************************
     * Set the state
     ***********************************************************************************/
    gMmwMssMCB.sensorState = MmwDemo_SensorState_STARTED;
    return 0;
}


void MmwDemo_sensorConfig_task(void)
{

    /* Sanity Check: We need the mmWave handle to work. */
    if (gMmwMssMCB.ctrlHandle == NULL)
    {
        return;
    }

    /* Initialize the mmWave control configuration: */
    memset ((void *)&gMmwMssMCB.cfg.ctrlCfg, 0, sizeof(MMWave_CtrlCfg));

    CLI_Remix_sensorstop();
    CLI_Remix_ADCBufCfg(0,1,1,0);
    CLI_Remix_BpmCfg(0, 0, 0);
    CLI_Remix_LvdsStreamCfg(0, 0, 1);
    CLI_Remix_GuiMonSel(1,1,1,1,1,1);
    CLI_Remix_CfarCfg(0,0,0,0,0,0,0,0);
    CLI_Remix_CfarCfg(1,0,0,0,0,0,0,0);
    CLI_Remix_CfarFovCfg(0,1,300);
    CLI_Remix_CfarFovCfg(1,0,70);
    CLI_Remix_AoAFovCfg(-45,45,-45,45);
    CLI_Remix_MultiObjBeamForming(0,1);
    CLI_Remix_CalibDcRangeSig(0,0,0,0);
    CLI_Remix_ClutterRemoval(1);
    CLI_Remix_ExtendedMaxVelocity(0);


    gMmwMssMCB.cfg.openCfg.adcOutCfg.fmt.b2AdcBits = 2;
    gMmwMssMCB.cfg.openCfg.adcOutCfg.fmt.b8FullScaleReducFctr = 0;
    gMmwMssMCB.cfg.openCfg.adcOutCfg.fmt.b2AdcOutFmt = 2U;
    gMmwMssMCB.cfg.openCfg.calibMonTimeUnit = 100;
    gMmwMssMCB.cfg.openCfg.chCfg.txChannelEn = 3;
    gMmwMssMCB.cfg.openCfg.chCfg.rxChannelEn = 15;
    gMmwMssMCB.cfg.openCfg.chCfg.cascading = 0;
    gMmwMssMCB.cfg.openCfg.chCfg.cascadingPinoutCfg = 0;
    gMmwMssMCB.cfg.openCfg.customCalibrationEnableMask = 0;
    gMmwMssMCB.cfg.openCfg.defaultAsyncEventHandler = MMWave_DefaultAsyncEventHandler_MSS;
    gMmwMssMCB.cfg.openCfg.disableFrameStartAsyncEvent = 1;
    gMmwMssMCB.cfg.openCfg.disableFrameStopAsyncEvent = 1;
    gMmwMssMCB.cfg.openCfg.freqLimitHigh = 81;
    gMmwMssMCB.cfg.openCfg.freqLimitLow = 76;
    gMmwMssMCB.cfg.openCfg.lowPowerMode.lpAdcMode = 0x01;
    gMmwMssMCB.cfg.openCfg.useCustomCalibration = 0;

    CLI_Remix_profileCfg(0,77,100,6,60,0,0,29.982,0,256,6000,0,0,30);

    CLI_Remix_chirpCfg(1, 1, 0, 0, 0, 0.3, 1.0, 1);

    CLI_Remix_frameCfg(1,1,128,0,40,0x0001,0);

    set_Offsets();

    return;
}

////

/**
 *  @b Description
 *  @n
 *      This is the CLI Execution Task
 *
 *  @retval
 *      Not Applicable.
 */
bool remix_flag = 1;


void MmwDemo_CLIInit (uint8_t taskPriority)
{
    if (remix_flag)
    {
        MmwDemo_sensorConfig_task();

        while (1)
        {
                System_printf("starting\n");
                CLI_Remix_sensorStart();
                System_printf("started\n");
                Task_sleep(500);
                System_printf("stopping\n");
                CLI_Remix_sensorstop();
                System_printf("stopped\n");
                Task_sleep(500);
                System_printf("Completed 1 cycle\n");
        }

        return;
    }
    else
    {
        CLI_Cfg     cliCfg;
        char        demoBanner[256];
        uint32_t    cnt;

        /* Create Demo Banner to be printed out by CLI */
        sprintf(&demoBanner[0],
                           "******************************************\n" \
                           "xWR16xx MMW Demo %02d.%02d.%02d.%02d\n"  \
                           "******************************************\n",
                            MMWAVE_SDK_VERSION_MAJOR,
                            MMWAVE_SDK_VERSION_MINOR,
                            MMWAVE_SDK_VERSION_BUGFIX,
                            MMWAVE_SDK_VERSION_BUILD
                );


    //    Task_Params taskParams;
    //
    //    // Configure task
    //    Task_Params_init(&taskParams);
    //    taskParams.stack = sensorTaskStack;
    //    taskParams.stackSize = 2048;
    //    taskParams.priority = taskPriority;
    //
    //    Task_construct(&MmwDemo_sensorConfig_task, sensorConfig_taskFxn, &taskParams, NULL);


       // return;

        /* Initialize the CLI configuration: */
        memset ((void *)&cliCfg, 0, sizeof(CLI_Cfg));

        /* Populate the CLI configuration: */
        cliCfg.cliPrompt                    = "mmwDemo:/>";
        cliCfg.cliBanner                    = demoBanner;
        cliCfg.cliUartHandle                = gMmwMssMCB.commandUartHandle;
        cliCfg.taskPriority                 = taskPriority;
        cliCfg.socHandle                    = gMmwMssMCB.socHandle;
        cliCfg.mmWaveHandle                 = gMmwMssMCB.ctrlHandle;
        cliCfg.enableMMWaveExtension        = 1U;
        cliCfg.usePolledMode                = true;
        cliCfg.overridePlatform             = false;
        cliCfg.overridePlatformString       = NULL;

        cnt=0;
        cliCfg.tableEntry[cnt].cmd            = "sensorStart";
        cliCfg.tableEntry[cnt].helpString     = "[doReconfig(optional, default:enabled)]";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLISensorStart;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "sensorStop";
        cliCfg.tableEntry[cnt].helpString     = "No arguments";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLISensorStop;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "guiMonitor";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <detectedObjects> <logMagRange> <noiseProfile> <rangeAzimuthHeatMap> <rangeDopplerHeatMap> <statsInfo>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIGuiMonSel;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "cfarCfg";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <procDirection> <averageMode> <winLen> <guardLen> <noiseDiv> <cyclicMode> <thresholdScale> <peakGroupingEn>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLICfarCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "multiObjBeamForming";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <enabled> <threshold>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIMultiObjBeamForming;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "calibDcRangeSig";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <enabled> <negativeBinIdx> <positiveBinIdx> <numAvgFrames>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLICalibDcRangeSig;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "clutterRemoval";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <enabled>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIClutterRemoval;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "adcbufCfg";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <adcOutputFmt> <SampleSwap> <ChanInterleave> <ChirpThreshold>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIADCBufCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "compRangeBiasAndRxChanPhase";
        cliCfg.tableEntry[cnt].helpString     = "<rangeBias> <Re00> <Im00> <Re01> <Im01> <Re02> <Im02> <Re03> <Im03> <Re10> <Im10> <Re11> <Im11> <Re12> <Im12> <Re13> <Im13> ";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLICompRangeBiasAndRxChanPhaseCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "measureRangeBiasAndRxChanPhase";
        cliCfg.tableEntry[cnt].helpString     = "<enabled> <targetDistance> <searchWin>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIMeasureRangeBiasAndRxChanPhaseCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "aoaFovCfg";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <minAzimuthDeg> <maxAzimuthDeg> <minElevationDeg> <maxElevationDeg>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIAoAFovCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "cfarFovCfg";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <procDirection> <min (meters or m/s)> <max (meters or m/s)>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLICfarFovCfg;
        cnt++;
        cliCfg.tableEntry[cnt].cmd            = "extendedMaxVelocity";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <enabled>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIExtendedMaxVelocity;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "bpmCfg";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <enabled> <chirp0Idx> <chirp1Idx>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIBpmCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "CQRxSatMonitor";
        cliCfg.tableEntry[cnt].helpString     = "<profile> <satMonSel> <priSliceDuration> <numSlices> <rxChanMask>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIChirpQualityRxSatMonCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "CQSigImgMonitor";
        cliCfg.tableEntry[cnt].helpString     = "<profile> <numSlices> <numSamplePerSlice>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIChirpQualitySigImgMonCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "analogMonitor";
        cliCfg.tableEntry[cnt].helpString     = "<rxSaturation> <sigImgBand>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIAnalogMonitorCfg;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "lvdsStreamCfg";
        cliCfg.tableEntry[cnt].helpString     = "<subFrameIdx> <enableHeader> <dataFmt> <enableSW>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLILvdsStreamCfg;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "configDataPort";
        cliCfg.tableEntry[cnt].helpString     = "<baudrate> <ackPing>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIConfigDataPort;
        cnt++;

        cliCfg.tableEntry[cnt].cmd            = "queryDemoStatus";
        cliCfg.tableEntry[cnt].helpString     = "";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLIQueryDemoStatus;
        cnt++;
    
        cliCfg.tableEntry[cnt].cmd            = "calibData";
        cliCfg.tableEntry[cnt].helpString    = "<save enable> <restore enable> <Flash offset>";
        cliCfg.tableEntry[cnt].cmdHandlerFxn  = MmwDemo_CLICalibDataSaveRestore;
        cnt++;
    
        /* Open the CLI: */
        if (CLI_open (&cliCfg) < 0)
        {
            System_printf ("Error: Unable to open the CLI\n");
            return;
        }
        System_printf ("Debug: CLI is operational\n");
        return;
    }
}




Hi all, I appreciate that the code I've pasted is rather large (its a refactored version of the mmw_cli.c from the out_of_box_1642_mss demo) but the bulk of what I'm trying to do is from line 2304 in which I'm calling the CLI functions without the need for the uart connection to try and setup and capture frames. I thought I had configured everything correctly and reimplemented the functions correctly but I have an issue in which there are no frames being captured, the result buffer in dss_main on the c674x core isnt getting any data and the result buffer is consistently of 0 size and then eventually hangs on a semephore_pend inside a dpm_execute and similarly in mss_main on the cortexr4 core it hangs on a semephore_pend inside a sensorstop. I would really appreciate it if someone was able to take the time to see if there's something glaringly obvious that I've missed. many thanks, Rhys