/**************************************************************
$Workfile:   bmetl.c  $
***************************************************************
**                                                                                                        
** FIRMWARE, Copyright (C) 2000-2002
** Ikanos Communication, Fremont, CA
** All rights reserved.
**
** The information and contents of this file are the
** proprietary information of Ikanos Communication and may not
** be disclosed or used without the formal written approval of
** Ikanos Communication
**
$Revision: 1.2 $
$Date: 2007/01/23 05:54:22 $
**************************************************************/                    



/* #includes */
#include <stdio.h>
#include <string.h>
#ifdef USE_VXWORKS /* IXDP425 */
#include "vxWorks.h"
#else
#include <v2pthread.h>
#endif
#include "ipos.h"
#include "ecmd.h"


#include "appconfig.h"
#include "pprofile.h"
#include "perfhandler.h"

#include "oamp.h"
#include "bmetl.h"

#include "oampdb.h"
#include "eventlog.h"
#include "uiUtil.h"
#include "diag.h"



#ifdef	USE_RFM
    #include "rfmapp.h"
#endif

#include "rmmapp.h"

/* local typedefs	*/
typedef struct
{

    eCommands Command;

}   tAPI_REQUEST;

#define PM_DEFAULT_SECOND_THRESHOLD  (2)
#define PM_DEFAULT_COUNT_THRESHOLD  (10)

#define MAX_FPGA_REGS    1031


/* global vars */

/* command string	*/


tTlCmdString TlCmdString[MAX_TL_CMDS] = {
/* A Cmds */
/* B Cmds */
    {"bitswapreq","",BIT_SWAP_REQ},
    {"bstart","",BME_START},
    {"breset","",BME_RESET},
/* C Cmds */
    {"clrcntr","",CLEAR_ALL_COUNTERS},
	{"clrrcntr","",CLEAR_REMOTE_CNTRS},
    {"cancel","",CANCEL_CMD},
/* D Cmds */
    {"devver","",DEVICE_VERSIONS},
    {"detectsig","",DETECT_SIGNALS},
/* E Cmds */
    {"emiconfig", "", EMI_CONFIG},
    {"evlogs", "", EVENT_LOG_STATUS},
    {"evloge", "", EVENT_LOG_ENABLE},
    {"evlogc","", EVENT_LOG_CLEAR},
    {"evlogp","", EVENT_LOG_PRINT},
    {"eorxdata","",EOC_GET_DATA},
    {"eotxdata","",EOC_SEND_DATA_STREAM},
    {"eomsgrcv","",EOC_MSG_RECEIVE},
    {"eoctrltx","",EOC_CONTROL_SEND},
    {"eosetdata","",EOC_SET_DATA},
    {"eodatarep","",EOC_DATA_REPLY},
    {"eoreldata","",EOC_RELAY_DATA_STREAM}, 
/* F Cmds */
    {"fifods", "", FIFO_DISPLAY_STATUS},
    {"fifode","",FIFO_DISPLAY_ENABLE},
/* G Cmds */
    {"getreoc","", GET_EOC_PROTOCOL_VER},
    {"getsnr","", GET_NE_SNR_ATTN},
    {"getendtype","", GET_HOST_ENDIAN_TYPE},
    {"getcntr","",GET_COUNTERS},
    {"getpmcntr","",GET_PM_COUNTERS},
    {"gselft","",GET_SELFTEST_RESULTS},
    {"getpprof","", GET_PORT_PROFILE},
    {"getdver","", GET_DEVICE_VERSIONS},
    {"getrver","", GET_REMOTE_VERSION},
    {"getrenet","", GET_REMOTE_ENET_STATUS},
	{"getrenetrptflag","",GET_REMENET_RPT_FLAG},
    {"getrerrs","", GET_REMOTE_ERRORED_SECONDS},
	{"getrmdio","",GET_REMOTE_MDIO_REGS},
	{"getrmodid","",GET_REMOTE_MODEM_ID},
	{"getrgpio","",GET_REMOTE_GPIO_PINS},
	{"getrenetcfg","",GET_REMOTE_ENET_CFG},
	{"getrtxpwr","",GET_REMOTE_TXPWR},
    {"getrlrndenetaddr","",GET_REMOTE_LEARNED_ENET_ADDR},
/* H Cmds */
    {"hostreset","",HOST_HOT_RESET},
/* I Cmds */
/* J Cmds */
/* K Cmds */
/* L Cmds */
    {"lpbk","",SET_LOOPBACK},
    {"logc","", USER_LOG_CLEAR},
    {"logp","", USER_LOG_PRINT},
/* M Cmds */
    {"msgts","", MSG_TRACING_STATUS},
    {"msgte","",MSG_TRACING_ENABLE},
    {"msgfilval","", MSG_FILTER_VALUE},
    {"msgfilter","", MSG_FILTER},
/* N Cmds */
/* O Cmds */
/* P Cmds */
/*{"portbringup","", PORT_BRINGUP}, */
/* {"portteardown","", PORT_TEARDOWN},*/
    {"pdes","",PORT_DESTROY},
    {"pprov","",PORT_PROVISION},
    {"pstat","",PORT_STATUS_BRIEF},
    {"pstatex","",PORT_STATUS_EXTENDED},
    {"pinst","",PORT_INSTANTIATE},
    {"preset","",PORT_RESET},
    {"pstart","",PORT_START},
    {"pstop","",PORT_STOP},
    {"permon","",PERFORMANCE_MONITORING},
    {"perrep","",PERIODIC_REPORTS_ENABLE},
    {"pmconfig","",PM_CONFIG_PARAMS},
    {"pmtrigger","",PM_TRIGGER_FAILURES},
/* Q Cmds */
/* R Cmds */
    {"rebootcpe","",REMOTE_REBOOT},
/* S Cmds */
    {"setpprof","",SET_PORT_PROFILE_PARAMETER},
    {"sysstatus","",SYSTEM_STATUS},
    {"sendsig","",SEND_SIGNALS},
    {"sysprov","",SYSTEM_PROVISION},
    {"setendtype","", SET_HOST_ENDIAN_TYPE},
    {"sendvm1","",SEND_VIRTUAL_MESSAGE_1},
    {"showdver","", SHOW_DEVICE_VERSIONS},
    {"showerrs","", SHOW_ERRORED_SECONDS},
    {"showenet","", SHOW_ETHERNET_STATUS},
    {"setrphylb","", SET_REMOTE_ENET_LB},
    {"seteflow","", SET_ENET_FLOW_CONTROL},
	{"setrmdio","", SET_REMOTE_MDIO_REG},
	{"setrenetcfg","",SET_REMOTE_ENET_CFG},
	{"setaenetrpt","",SET_REMENET_STATUS_RPT},
/* T Cmds */
    {"thresrep","",THRESHOLD_REPORTS},
/* U Cmds */
    {"uprep","",UPDATED_REPORTS_ENABLE},
/* V Cmds */

/* remote download commands	*/

#ifdef	USE_RFM
#define	RFM_LOAD_IMAGE		0x200
#define	RFM_DOWNLOAD_CPE	RFM_LOAD_IMAGE+1
#define	RFM_ACTIVATE_CPE	RFM_LOAD_IMAGE+2	
#define	RFM_GET_CPE_VERSION	RFM_LOAD_IMAGE+3	
#define	RFM_SET_DISPLAY		RFM_LOAD_IMAGE+4	


    {"ldimage",     "", RFM_LOAD_IMAGE},
    {"dnldcpe",     "", RFM_DOWNLOAD_CPE},
    {"actcpe",      "", RFM_ACTIVATE_CPE},
    {"getcpever",   "", RFM_GET_CPE_VERSION},
    {"setdisplay",  "", RFM_SET_DISPLAY},
#endif

#define	OPTIONAL_CMD			0x300
    {"optionalCmd", "",     OPTIONAL_CMD},
    {"setrfpgamdio","", SET_REMOTE_FPGA_MDIO_REG},
    {"getrfpgamdio","",GET_REMOTE_FPGA_MDIO_REGS},
/* W Cmds */
/* X Cmds */
/* Y Cmds */
/* Z Cmds */
    {{0},{0},0},
};

/* YING: stubs for extern vars */
int     EventLogEnable;             /* local for now	*/
extern  U8  HostCpuEndianType;          /* local for now	*/

extern ipos_pm_trigger PmTrigger;

/* Local function prototypes */
eTlCmdType parseTlCmdString ( U8 *bCmdString, tAPI_REQUEST *pApiReq, ipos_port_id *pPid, U8 *cmdTag);

void displayTLHelp (void);

void displayTLCmdSyntax (eCommands Cmd,  U8 bDetailSyntax);

void sendTlCmdResponse (eCommands Cmd, eApiRv CmdStatus, int bmeNum,int portNum);
extern void setOptBandType(int typeInUse);
extern int  oampHostReset(int bmeNum, U8 *pCodeAddr, U8 cmdTag, U32 cntRpt);
extern int  oampBmeProvision(int    bmeNum, ipos_bme_provision *pBmeProvision, U8 cmdTag, U32 cntRpt);
extern int  oampEocGetData(ipos_port_id *pPid, U8 opCode, U8 cmdTag, U32 cntRpt);
extern int  oampDetectSignal(ipos_port_id *pPid, ipos_test_signals * pTestSignals, U8 cmdTag, U32 sigType);
extern void uiDnldCpe(ipos_port_id	pid);

extern void uiGetEocProtocolVer( ipos_port_id pid );
extern void uiGetRemoteEthernetStatus( ipos_port_id pid );
extern void uiGetRemoteEnetAutoRptFlag( ipos_port_id pid );
extern void uiGetRemoteEnetCfg( ipos_port_id pid );
extern void uiGetRemoteGPIOPin( ipos_port_id pid );
extern void uiGetRemoteModemId( ipos_port_id pid );
extern void uiGetRemoteTxPower( ipos_port_id pid );
extern void uiGetRemoteLearnedEnetAddress( ipos_port_id pid );
extern void uiSetAutoEnetStatusRpt( ipos_port_id pid, U8 reportEn);
extern void uiSetRemoteEthernetLb( ipos_port_id pid, U8 lbOption );
extern void uiGetRemoteFpgaMDIOReg( ipos_port_id pid,U16 mdioReg_no);
extern void uiSetRemoteFpgaMDIOReg( ipos_port_id pid, U16 mdioReg_no, U16 mdioReg_value);

extern void uiSetRemoteMDIOReg( ipos_port_id pid, U8 mdioReg_no, U16 mdioReg_value);
extern void uiSetRemoteEthernetFlow( ipos_port_id pid, U8 flowCtrlOption );
extern void uiSetRemotePhyParams( ipos_port_id pid);
extern void uiSetClearRemoteCounters( ipos_port_id pid);
extern void uiShowErroredSeconds( ipos_port_id pid );
extern void uiShowEthernetStatus( ipos_port_id pid );
extern void uiSendVirtualMessage1( ipos_port_id pid );

/* YING: Exteranl Functions to be evaluated	*/

#if 0


/* extern functions */
extern void InitEventLogs(void);
extern void PrintEventLogs(void);
extern U32 GetPerfParameter (tBmeStruct *ptrBmeStruc, int portNum, eReportType report_type, eParaType parameter_type);
extern void *GetThresholdReport(tBmeStruct *ptrBmeStruc, int portNum, eReportType report_type);
extern void DisplayThresholdReport(eReportType report_type, void *TR);
#endif





/* function definitions */

int ReceiveTLCommand( U8 *bTlStr)
{
    eTlCmdType CmdType;

    tAPI_REQUEST ApiRequest;

    ipos_port_id Pid;

    U8  cmdTag;     

    int status = 0;

    CmdType = parseTlCmdString (bTlStr, &ApiRequest, &Pid, &cmdTag);

    return(status);
} /*ReceiveTLCommand*/



eTlCmdType parseTlCmdString ( U8 *bCmdString, tAPI_REQUEST *pApiReq, ipos_port_id *pPid, U8 *cmdTag)
{
/*the below three variables moved from global to local scope as these are not outside of this function */
    U8 bCmd[MAX_CMD_LENGTH+1];
    U8 bCmdTag[MAX_NUM_OF_PORTS];
    U8 remDldImgFlag = 0;

    U8 bArrIndex = 0, bParmCnt = 0, bParam1, bParam2, bParam3, bDetailSyntax = FALSE;


    U8 *bValidPtr, *bTmpPtr;

    int  index = 0, strIndex = 0, sumIndex = 0, iBmeNum =0, iPortNum = 0, iTmpVar = 0, status = 0;

    tCmdInfo CmdInfo[MAX_NUM_OF_PARAMS];

    eTlCmdType CmdType = WRONG_CMD;

    eProfileMgmtRv RetVal;

//    eReportType RepType;

//    eParaType ParaType;

   // U32 PerfParm;

   // void *pThresRep = NULL;

    U32 TmpInt32;

    int     TmpArray[256];
    char    TmpString[256];
#ifdef VTU_O
    int  mdioReg_no;
    int mdioReg_value;
#endif

    ipos_port_profile   *pPortProfile;

    int i=0/*,sz=0*/;

    pPid->bmeNum = 0;
    pPid->portNum = 0;

    memset (bCmd, 0, sizeof(bCmd));

    if (strlen(bCmdString) == 0)  return CONFIG_CMD;


    /* check if it is help cmd */
    if (((strlen(bCmdString) == 1) && (*bCmdString == '?')) || ((strlen(bCmdString) == 4) && (!strcmp(bCmdString,"help"))))
    {
        displayTLHelp ();
        return HELP_CMD;
    }

    /* check if it is detail help syntax command */
    if ((bCmdString[0] == '?') && (strlen (bCmdString) > 1))
    {
        /* get the cmd - if ??cmd, detail syntax cmd. cmd starts frm arrayindex 2 */
        if (bCmdString[1] == '?')
        {
            bDetailSyntax = TRUE;
            bTmpPtr = &bCmdString[2];
        } else /* get the cmd - cmd starts frm arrayindex 1 */
        {
            bTmpPtr = &bCmdString[1];
        }

        /* check in TlCmdString array for a matching cmd */
        for (strIndex=0; strIndex < MAX_TL_CMDS; strIndex++)
        {
            /* If TlCmdString array end is reached, come out */
            if (!TlCmdString[strIndex].Cmd[0])
            {
                /* TL command not supported. Error */
                printf ("\nTL Command %s unsupported. strIndex %d. Error!", bTmpPtr, strIndex);
                return WRONG_CMD;
            }

            /* skip if the first char is not matching */
            if (*bTmpPtr != TlCmdString[strIndex].Cmd[0])
                continue;

            /* check if the cmd strings are matching */
            if (!strcmp(TlCmdString[strIndex].Cmd, bTmpPtr))
                break;
        }   

        /* call the help function */
        displayTLCmdSyntax(TlCmdString[strIndex].ApiCmd, bDetailSyntax);
        return HELP_CMD;
    }


    bTmpPtr = bCmdString;
    while (1)
    {
        /* skip any characters other than starting with an alphabet */
        if ((*bTmpPtr == ';') || (*bTmpPtr == '\0'))
        {
            /* reached end of bCmdString. No valid char to parse. Error */
            printf ("\nNo valid char to parse. Error TL Command!");
            return WRONG_CMD;
        }

        else if (((*bTmpPtr >= 'a') && (*bTmpPtr <= 'z')) || ((*bTmpPtr >= 'A') && (*bTmpPtr <= 'Z')))
            break;

        bTmpPtr++;
    }


    bValidPtr = bTmpPtr;
    CmdInfo[bArrIndex].Index = 0;
    bParmCnt = _COMMAND_;

    sumIndex = 0; /* cmd aggregate index */

    /* check for the delimiter ';'. if not present, error */
    if (strchr(bTmpPtr, ';') == NULL)
    {
        printf ("\nCommand is not delimited properly. Error!");
        return WRONG_CMD;
    }


    /* read till the delimiter ';' */
    while (*bTmpPtr) /* read till string null char */
    {
        bArrIndex++;
        index = 0;

        /* read till the delimiter ':'. store the COMMAND */
        while ((*bTmpPtr != ':') && (*bTmpPtr != ';'))
        {
            index++;    /* individual parameter index */
            sumIndex++; /* aggregate index */
            bTmpPtr++;
        }

        CmdInfo[bArrIndex-1].Length = index;

        /* check if command length exceeds the max length */
        if ((bArrIndex == 1) && (index > MAX_CMD_LENGTH))
        {
            printf ("\nCmd array index %d exceeded boundary. Error!", CmdInfo[0].Length);
            return WRONG_CMD;
        }

        bParmCnt++;

        /* skip ':' */
        if (*bTmpPtr != ';')
        {
            bTmpPtr++;
            sumIndex++;

            CmdInfo[bArrIndex].Index = sumIndex;
        } else
            break;  
    }   

    /* copy the command string */
    memcpy (( U8 *)bCmd, ( U8 *)bValidPtr, CmdInfo[_COMMAND_].Length);  
    bCmd[CmdInfo[_COMMAND_].Length] = 0; /* null terminate the string */

    /* check in TlCmdString array for a matching cmd */
    for (strIndex=0; strIndex < MAX_TL_CMDS; strIndex++)
    {
        /* If TlCmdString array end is reached, come out */
        if (!TlCmdString[strIndex].Cmd[0])
        {
            /* TL command not supported. Error */
            printf ("\nTL Command %s unsupported. strIndex %d. Error!", bCmd, strIndex);
            return WRONG_CMD;
        }

        /* skip if the first char is not matching */
        if (bCmd[0] != TlCmdString[strIndex].Cmd[0])
            continue;

        /* check if the strings are matching */
        if (!strcmp(TlCmdString[strIndex].Cmd, bCmd))
        {
            pApiReq->Command = TlCmdString[strIndex].ApiCmd;
            break;
        }
    }

    /* get the command tag value */
    if (bParmCnt > _CTAG_)
    {
        if (CmdInfo[_CTAG_].Length)
        {
            if (CmdInfo[_CTAG_].Length > MAX_TAG_LENGTH)
            {
                printf ("\nTag array index %d exceeded boundary. Error!", CmdInfo[_CTAG_].Length);
                return WRONG_CMD;
            }

            /* update CTag value in the TlCmdString array structure */
            memcpy(( U8 *)TlCmdString[strIndex].CTag, ( U8 *)&bValidPtr[CmdInfo[_CTAG_].Index], 
                   CmdInfo[_CTAG_].Length);

            /* null terminate */
            TlCmdString[strIndex].CTag[CmdInfo[_CTAG_].Length] = 0;

            /* convert the command tag value	*/
            *cmdTag=atoi(( U8 *)TlCmdString[strIndex].CTag);
        } else
        {
            /* no ctag */
        }

    }

    /* get bme number */
    if (bParmCnt > _BMENUM_)
    {
        /* for config commands, 3rd parameter is enable parameter. can be enable 1 / disable 0 */
        if (((TlCmdString[strIndex].ApiCmd >= GET_HOST_ENDIAN_TYPE) && (TlCmdString[strIndex].ApiCmd <= MSG_FILTER))
            || (TlCmdString[strIndex].ApiCmd == SET_PORT_PROFILE_PARAMETER)
            || (TlCmdString[strIndex].ApiCmd == GET_PORT_PROFILE)

#ifdef	USE_RFM
            || (TlCmdString[strIndex].ApiCmd == RFM_LOAD_IMAGE)
            ||(TlCmdString[strIndex].ApiCmd == RFM_SET_DISPLAY)
#endif			

           )
        {
            /* do nothing */
        } else
        {
            if (CmdInfo[_BMENUM_].Length > MAX_NUM_OF_BMES)
            {
                printf("\nBme number exceeds the max length %i",MAX_NUM_OF_BMES);
                return WRONG_CMD;
            }


            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index],CmdInfo[_BMENUM_].Length);
            bCmd[CmdInfo[_BMENUM_].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nbme number omitted. Error!");
                return WRONG_CMD;
            }

            iBmeNum = atoi(( U8 *)bCmd);
            if ((iBmeNum < 1) || (iBmeNum > MAX_NUM_OF_BMES+1)) /* 1 based Index */
            {
                printf ("\nwrong bme number %d. Error!", iBmeNum);
                return WRONG_CMD;
            }
            pPid->bmeNum = iBmeNum;
        }
    }


    /* for config commands, skip portnum parsing */
    if (bParmCnt > _PORTNUM_)
    {
        if (((TlCmdString[strIndex].ApiCmd >= GET_HOST_ENDIAN_TYPE) && (TlCmdString[strIndex].ApiCmd <= MSG_FILTER)) 
            || (TlCmdString[strIndex].ApiCmd == BME_START) || (TlCmdString[strIndex].ApiCmd == BME_RESET)
            || (TlCmdString[strIndex].ApiCmd == SET_PORT_PROFILE_PARAMETER) 
            || (TlCmdString[strIndex].ApiCmd == GET_PORT_PROFILE)
            || (TlCmdString[strIndex].ApiCmd == PERIODIC_REPORTS_ENABLE)  
            || (TlCmdString[strIndex].ApiCmd == SYSTEM_STATUS) || (TlCmdString[strIndex].ApiCmd == DEVICE_VERSIONS) 
			||(TlCmdString[strIndex].ApiCmd == SYSTEM_PROVISION) 

#ifdef	USE_RFM			
            || (TlCmdString[strIndex].ApiCmd == RFM_LOAD_IMAGE)
            ||(TlCmdString[strIndex].ApiCmd == RFM_SET_DISPLAY)
#endif
           )
        {
            /* do nothing */
            pPid->portNum = 0x0; /* not a port based command */
        } else
        {
            if (CmdInfo[_PORTNUM_].Length > 2)
            {
                printf("\nPort number exceeds the max length 2");
                return WRONG_CMD;
            }

            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_].Index],CmdInfo[_PORTNUM_].Length);
            bCmd[CmdInfo[_PORTNUM_].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nport number omitted. Error!");
                return WRONG_CMD;
            }

            iPortNum = atoi(( U8 *)bCmd);
            if ((iPortNum < 1) || (iPortNum > IPOS_MAX_PORT_PER_BME))   /* 1-based Index */
            {
                printf ("\nwrong port number %d. Error!", iPortNum);
                return WRONG_CMD;
            }

            pPid->portNum = iPortNum;


            /* update the tag value for the resp port */
            if (!TlCmdString[strIndex].CTag[0])
                bCmdTag[iPortNum] = 0;
            else
                sscanf (&TlCmdString[strIndex].CTag[0], "%02x",(unsigned int*) &bCmdTag[iPortNum]);            

        }
    }

    switch (TlCmdString[strIndex].ApiCmd)
    {
#ifndef BUP_DIAGS
        /* CONFIG_CMD */
        case EMI_CONFIG:
            if (bParmCnt < (_PORTNUM_+1))
            {
                printf ("\nInsufficient %d parameters for EMI_CONFIG. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* sram / sdram */
            if (!CmdInfo[_PORTNUM_].Length)
            {
                printf ("\nNo memory type specified. Error!");
                return WRONG_CMD;   
            }

            if (CmdInfo[_PORTNUM_].Length > MAX_CMD_LENGTH)
            {
                printf("\nMem type length %d exceeds the max cmd length %d", CmdInfo[_PORTNUM_].Length, MAX_CMD_LENGTH);
                return WRONG_CMD;
            }

            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_].Index],CmdInfo[_PORTNUM_].Length);
            bCmd[CmdInfo[_PORTNUM_].Length] = 0;

            break;

        case EVENT_LOG_STATUS:
            if (bParmCnt != (_BMENUM_))
            {
                printf ("\nWrong parameter count %d for ApiCmd EVENT_LOG_STATUS. Error!", bParmCnt);
                return WRONG_CMD;
            }
            printf("\nEventLogStatus flag %d", EventLogEnable);

            break;


        case EVENT_LOG_ENABLE:
            if (bParmCnt != (_BMENUM_+1))
            {
                printf ("\nWrong parameter count %d for ApiCmd EVENT_LOG_ENABLE. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* enable / disable flag */
            if (CmdInfo[_BMENUM_].Length > MAX_CMD_LENGTH)
            {
                printf("\nEnable flag length %d exceeds the max cmd length %d", CmdInfo[_BMENUM_+2].Length, MAX_CMD_LENGTH);
                return WRONG_CMD;
            }

            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index],CmdInfo[_BMENUM_].Length);
            bCmd[CmdInfo[_BMENUM_].Length] = 0;
            if (!bCmd[0])
            {
                printf ("\nEvent log enable option omitted. By default enable is chosen.");
                iTmpVar = 1;
            } else
                iTmpVar = atoi(bCmd);

            if (iTmpVar == 1)
            {
                EventLogEnable = TRUE;  
            } else if (iTmpVar == 0)
            {
                EventLogEnable = FALSE;
            } else
            {
                printf ("\nUnknown option. Error!");
                return WRONG_CMD;   
            }

            break;

        case EVENT_LOG_CLEAR:
            if (bParmCnt != _BMENUM_)
            {
                printf ("\nWrong parameter count %d for ApiCmd EVENT_LOG_CLEAR. Error!", bParmCnt);
                return WRONG_CMD;
            }

            InitEventLogs();

            break;

        case EVENT_LOG_PRINT:
            if (bParmCnt != _BMENUM_)
            {
                printf ("\nWrong parameter count %d for ApiCmd EVENT_LOG_PRINT. Error!", bParmCnt);
                return WRONG_CMD;
            }
            PrintEventLogs();

            break;

        case USER_LOG_PRINT:
            if (bParmCnt != _BMENUM_)
            {
                printf ("\nWrong parameter count %d for ApiCmd USER_LOG_PRINT. Error!", bParmCnt);
                return WRONG_CMD;
            }
            PrintUserLogs();

            break;

        case USER_LOG_CLEAR:
            if (bParmCnt != _BMENUM_)
            {
                printf ("\nWrong parameter count %d for ApiCmd USER_LOG_CLEAR. Error!", bParmCnt);
                return WRONG_CMD;
            }

            InitUserLogs();

            break;

        case GET_HOST_ENDIAN_TYPE:
            if (bParmCnt != (_BMENUM_))
            {
                printf ("\nWrong parameter count %d for ApiCmd GET_HOST_ENDIAN_TYPE. Error!", bParmCnt);
                return WRONG_CMD;
            }

            if (HostCpuEndianType == LITTLE_ENDIAN_FORMAT)
                printf("\nHostCpuEndianType is LITTLE_ENDIAN");
            else if (HostCpuEndianType == BIG_ENDIAN_FORMAT)
                printf("\nHostCpuEndianType is BIG_ENDIAN");
            else
                printf("\nUnknown Endian Type %d", HostCpuEndianType);

            break;

        case SET_HOST_ENDIAN_TYPE:
            if (bParmCnt != (_BMENUM_+1))
            {
                printf ("\nWrong parameter count %d for ApiCmd SET_HOST_ENDIAN_TYPE. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* endian type */
            if (CmdInfo[_BMENUM_].Length > MAX_CMD_LENGTH)
            {
                printf("\nendian type length %d exceeds the max cmd length %d", CmdInfo[_BMENUM_].Length, MAX_CMD_LENGTH);
                return WRONG_CMD;
            }

            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index],CmdInfo[_BMENUM_].Length);
            bCmd[CmdInfo[_BMENUM_].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nEndian type option omitted. By default BigEndian is chosen.");
                iTmpVar = BIG_ENDIAN_FORMAT;
            } else
                iTmpVar = atoi(bCmd);

            if (iTmpVar == LITTLE_ENDIAN_FORMAT)
            {
                HostCpuEndianType = LITTLE_ENDIAN_FORMAT;
            } else if (iTmpVar == BIG_ENDIAN_FORMAT)
            {
                HostCpuEndianType = BIG_ENDIAN_FORMAT;
            } else
            {
                printf ("\nUnknown Endian Type %d. Error!", iTmpVar);
                return WRONG_CMD;
            }

            break;

#endif // BUP
            /* Control Commands */
        case BME_START:
            if (bParmCnt != (_BMENUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd BME_START. Error!", bParmCnt);
                return WRONG_CMD;
            }
            printf("Fusiv oampBmeStart() ../\n");
            oampBmeStart(pPid->bmeNum,NULL,0,*cmdTag);      /* Note:current implementation: firmware addr is 
                                                                    defined in bmeconfig.h */
            CmdType = CTRL_CMD;
            break;

#ifndef BUP_DIAGS
        case BME_RESET:
            if (bParmCnt != (_BMENUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd BME_RESET. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampBmeReset(pPid->bmeNum,NULL,0,*cmdTag);      /* Note:current implementation: firmware addr is 
                                                                    defined in bmeconfig.h */
            CmdType = CTRL_CMD;
            break;

        case HOST_HOT_RESET:

            for (i=1; i<=MAX_NUM_OF_BMES; i++)
              oampHostReset(i,NULL,0,*cmdTag);      /* Note:current implementation: firmware addr is 
                                                                    defined in bmeconfig.h */

            CmdType = CTRL_CMD;
            break;

        case GET_PORT_PROFILE:
            if (bParmCnt != (_PORTNUM_))
            {
                printf ("\nwrong parameter count %d for ApiCmd GET_PORT_PROFILE. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* profile number */
            if (CmdInfo[_BMENUM_].Length > MAX_CMD_LENGTH)
            {
                printf("\nProfile num length %d exceeds the max cmd length %d", CmdInfo[_BMENUM_].Length, MAX_CMD_LENGTH);
                return WRONG_CMD;
            }

            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index],CmdInfo[_BMENUM_].Length);
            bCmd[CmdInfo[_BMENUM_].Length] = 0;
            if (!bCmd[0])
            {
                printf ("\nprofile number omitted. Error!");
                return WRONG_CMD;
            }

            iTmpVar = atoi(( U8 *)bCmd);
            bParam1 = ( U8)iTmpVar;

            getPortProfileDisplay(bParam1);

            break;

        case SET_PORT_PROFILE_PARAMETER: /* profile number, parameter, data - size 10 */
            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd SET_PORT_PROFILE_PARAMETER. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* profile number */
            if (CmdInfo[_BMENUM_].Length > MAX_CMD_LENGTH)
            {
                printf("\nProfile num length %d exceeds the max cmd length %d", CmdInfo[_BMENUM_].Length, MAX_CMD_LENGTH);
                return WRONG_CMD;
            }

            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index],CmdInfo[_BMENUM_].Length);
            bCmd[CmdInfo[_BMENUM_].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nprofile number omitted. Error!");
                return WRONG_CMD;
            }

            iTmpVar = atoi(( U8 *)bCmd);
            bParam1 = ( U8)iTmpVar;

            /* parameter type, always one  U8 */

            for (i = 0; i < 1; i++)
            {
                sscanf(&bValidPtr[CmdInfo[_PORTNUM_].Index+(i*2)], "%02x", &TmpArray[i]);
                bCmd[i]=( U8)TmpArray[i];
            }

            bCmd[CmdInfo[_PORTNUM_].Length] = 0;
            bParam3=bCmd[0];

            /* data - size 10 */
            if (CmdInfo[_PORTNUM_+1].Length > 10)
            {
                printf ("\nData count %d exceeded for ApiCmd SET_PORT_PROFILE_PARAMETER. Error!", CmdInfo[_PORTNUM_+2].Length);
                return WRONG_CMD;
            }

            if (!CmdInfo[_PORTNUM_+1].Length)
            {
                printf ("\ndata omitted. Error!");
                return WRONG_CMD;
            }

            sscanf(&bValidPtr[CmdInfo[_PORTNUM_+1].Index], "%lx", &TmpInt32);

            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            bParam2=PORT_PROVISION; /* Cmd type will always be PORT_PROVISION */

            RetVal= setPortParameter (bParam1, bParam2, bParam3, &TmpInt32); 

            if (RetVal != PROFILE_MGMT_REQ_SUCCESS)
            {
                printf ("\nError in setPortParameter. Return value %d", RetVal);
                return WRONG_CMD;
            }

            CmdType = CTRL_CMD;
            break;

        case PORT_PROVISION: /* profile number */

            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_PROVISION. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* profile number */
            memcpy ((BYTE *)bCmd,(BYTE *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;
            if (!bCmd[0])
            {
                printf ("\nprofile number omitted. Default port profile selected!");
                bParam1 = 0;
            } else
            {
                iTmpVar = atoi((BYTE *)bCmd);
                bParam1 = (BYTE)iTmpVar;
            }

            pPortProfile = getPortProfile(bParam1);


            if (pPortProfile==NULL)
            {
                printf ("\nError in getPortProfileNum. Return value NULL");
                return WRONG_CMD;   
            }

			setOptBandType(pPortProfile->BandMod.bandModifier>>6);
            oampPortProvision(pPid,pPortProfile,*cmdTag, 0);

            CmdType = CTRL_CMD;
            break;


        case PORT_INSTANTIATE:
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_INSTANTIATE. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortInstantiate(pPid,*cmdTag, 0);

            CmdType = CTRL_CMD; 
            break;

        case PORT_RESET:    /* PortStartParm */
            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_RESET. Error!", bParmCnt);
                return WRONG_CMD;
            }

            if (CmdInfo[_PORTNUM_+1].Length>1)
            {
                printf("\nwrong start option: 0 or 1!");
                return	WRONG_CMD;
            }
            /* get the port reset option	*/
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bParam1=atoi(bCmd);

            oampPortReset(pPid, bParam1, *cmdTag,0);

            CmdType = CTRL_CMD; 
            break;

        case PORT_START:    /* PortStartParm */

            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_START. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortStart(pPid,*cmdTag, 0);

            CmdType = CTRL_CMD; 
            break;

        case PORT_STOP:     /* PortStopParm */
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_STOP. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortStop(pPid,*cmdTag, 0);

            CmdType = CTRL_CMD; 
            break;

        case PORT_DESTROY:      /* PortStopParm */
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_DESTROY. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortDestroy(pPid,*cmdTag, 0);

            CmdType = CTRL_CMD; 
            break;


        case SYSTEM_PROVISION:          /* itu vendor id */
            if (bParmCnt != (_BMENUM_+10))
            {
                printf ("\nwrong parameter count %d for ApiCmd SYSTEM_PROVISION. Error!", bParmCnt);
                return WRONG_CMD;
            }


            {                               /* local function to parse the system provision command	*/

                ipos_bme_provision  bmeProvision;
                int                 j;              

                /* vendorIdT1E1	*/
                sscanf(&bValidPtr[CmdInfo[_BMENUM_+1].Index], "%x",
                       &iTmpVar);

                bmeProvision.vendorIdT1E1=(U16) iTmpVar;
                bCmd[CmdInfo[_BMENUM_+1].Length] = 0;


                /* vendorID ITU	*/
                for (i = 0; i < (CmdInfo[_BMENUM_+2].Length); i++)
                {
                    sscanf(&bValidPtr[CmdInfo[_BMENUM_+2].Index+i], "%x", 
                           &TmpArray[i]);
                    bmeProvision.vendorIdITU[i]=( U8)TmpArray[i];
                }

                bCmd[CmdInfo[_BMENUM_+2].Length] = 0;

                /* revision Number	*/
                sscanf(&bValidPtr[CmdInfo[_BMENUM_+3].Index], "%x", 
                      (unsigned int *) &bmeProvision.revisionNum);

                bCmd[CmdInfo[_BMENUM_+3].Length] = 0;

                /* serial number	*/
                for (i = 0; i < (CmdInfo[_BMENUM_+4].Length); i++)
                {
                    sscanf(&bValidPtr[CmdInfo[_BMENUM_+4].Index+i], "%x", 
                           &TmpArray[i]);
                    bmeProvision.serialNum[i]=( U8)TmpArray[i];
                }
                bCmd[CmdInfo[_BMENUM_+4].Length] = 0;

                /* utopia option	*/
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_+5].Index],CmdInfo[_BMENUM_+5].Length);
                bCmd[CmdInfo[_BMENUM_+5].Length] = 0;
                if (!bCmd[0])
                {
                    printf ("\nError: Missing parameter.");         
                    return WRONG_CMD;
                }
                iTmpVar = atoi(( U8 *)bCmd);
                bParam1 = ( U8)iTmpVar;
                bmeProvision.utopiaOption = bParam1;

                /* utopia size	*/
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_+6].Index],CmdInfo[_BMENUM_+6].Length);
                bCmd[CmdInfo[_BMENUM_+6].Length] = 0;
                if (!bCmd[0])
                {
                    printf ("\nError: Missing parameter.");         
                    return WRONG_CMD;
                }
                iTmpVar = atoi(( U8 *)bCmd);
                bParam1 = ( U8)iTmpVar;
                bmeProvision.utopiaDataSize = bParam1;

                /* CHip option mask 	*/
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_+7].Index],CmdInfo[_BMENUM_+7].Length);
                bCmd[CmdInfo[_BMENUM_+7].Length] = 0;
                if (!bCmd[0])
                {
                    printf ("\nError: Missing parameter.");         
                    return WRONG_CMD;
                }
                iTmpVar = atoi(( U8 *)bCmd);
                bParam1 = ( U8)iTmpVar;
                bmeProvision.optionMask = bParam1;

#ifdef INI_SUPPORT

				{

					int uMode = oampGetUtopiaMode;

					printf("Utopia mode = %x\n", uMode);

					// > 0 = PTM
					if (uMode > 0 ) 
                bmeProvision.optionMask |= SUPPORT_INI;
					else
						bmeProvision.optionMask &= (~SUPPORT_INI);
				}
#endif




                /*	Band Plan	*/
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_+8].Index],CmdInfo[_BMENUM_+8].Length);
                bCmd[CmdInfo[_BMENUM_+8].Length] = 0;
                if (!bCmd[0])
                {
                    printf ("\nError: Missing parameter.");         
                    return WRONG_CMD;
                }
                iTmpVar = atoi(( U8 *)bCmd);
                bParam1 = ( U8)iTmpVar;
                bmeProvision.bandPlan = bParam1; 

                /*	imux port	*/
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_+9].Index],CmdInfo[_BMENUM_+9].Length);
                bCmd[CmdInfo[_BMENUM_+9].Length] = 0;
                if (!bCmd[0])
                {
                    printf ("\nError: Missing parameter.");         
                    return WRONG_CMD;
                }
                iTmpVar = atoi(( U8 *)bCmd);
                bParam1 = ( U8)iTmpVar;
                bmeProvision.numPort = bParam1;
				
                bmeProvision.psdMaskLevelIndx = oampGetPsdIndex;

                for (j =0;j<3;j++)
                {
                    bmeProvision.k0[j] = oampGetK0_array(j);
                    bmeProvision.k1[j] = oampGetK1_array(j);
                }

				bmeProvision.optionMask |= oampGetOptionMask;

				bmeProvision.custId = oampGetCustID();
                for(j=0;j<3;j++)
                    bmeProvision.keys[j] = oampGetKeys(j);

				bmeProvision.ife2PwrMode = oampGetIFE2PwrMode;

                bmeProvision.OamOptionMask = oampGetOamOptionMask;
                printf ("\nOamoptionMask %x", bmeProvision.OamOptionMask);

                printf ("\noptionMask %x", bmeProvision.optionMask);

                for (j =0;j<3;j++)
                {
                    bmeProvision.k0_hi[j] = oampGetK0_hi_array(j);
                    bmeProvision.k1_hi[j] = oampGetK1_hi_array(j);
                }

                copyMaxPsdArray (bmeProvision.MaxPsd);

                oampBmeProvision(pPid->bmeNum, &bmeProvision,*cmdTag,0);
            }

            CmdType = CTRL_CMD; 
            break;

        case EOC_CONTROL_SEND:  /* EOC Opcode */

            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd EOC_CONTROL_SEND. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* EocOpcode */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nEocOpcode omitted.Error!");          
                return WRONG_CMD;
            }

            iTmpVar = atoi(( U8 *)bCmd);

            bParam1 = ( U8)iTmpVar;

            oampEocControlSend(pPid,bParam1,*cmdTag,0);

            CmdType = CTRL_CMD; 
            break;

        case EOC_SET_DATA:  /* EOC Opcode, EocRegisterData - data size 128 */

            if (bParmCnt != (_PORTNUM_+3))
            {
                printf ("\nwrong parameter count %d for ApiCmd EOC_SET_DATA. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* EocOpcode */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nEocOpcode omitted.Error!");          
                return WRONG_CMD;
            }

            //iTmpVar = atoi(( U8 *)bCmd);
            sscanf (bCmd, "%x", &iTmpVar);
            /* todo: if needed flip the  U8s */
            bParam1 = ( U8)iTmpVar;
            /* todo: error checking of opcode required ? */

            /* EocRegisterData */
            if (!CmdInfo[_PORTNUM_+2].Length)
            {
                printf ("\nEocRegisterData omitted.Error!");            
                return WRONG_CMD;
            }

            if (CmdInfo[_PORTNUM_+2].Length > (128*2))
            {
                printf ("\nEocRegisterData length %d exceeded max 128 size.Error!", CmdInfo[_PORTNUM_+2].Length);           
                return WRONG_CMD;
            }

            TmpString[0]=(U8) CmdInfo[_PORTNUM_+2].Length / 2;
            for (index = 0; index < TmpString[0]; index++)
            {
                sscanf(&bValidPtr[CmdInfo[_PORTNUM_+2].Index+(index * 2)], "%2x", 
                       &iTmpVar);

                TmpString[index+1]=(U8) iTmpVar;

            }           
            oampEocSetData(pPid,bParam1,TmpString,*cmdTag,0);

            CmdType = CTRL_CMD; 
            break;


        case BIT_SWAP_REQ:  /* Bit Swap Request - data size 22 bytes */

            if (bParmCnt != (_PORTNUM_+3))
            {
                printf ("\nwrong parameter count %d for ApiCmd EOC_SET_DATA. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /*  BitSwap Opcode */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nBitSwap Opcode omitted.Error!");          
                return WRONG_CMD;
            }

            //iTmpVar = atoi(( U8 *)bCmd);
            sscanf (bCmd, "%x", &iTmpVar);
            /* todo: if needed flip the  U8s */
            bParam1 = ( U8)iTmpVar;
            /* todo: error checking of opcode required ? */

            /* Bit Swap Request Message */
            if (!CmdInfo[_PORTNUM_+2].Length)
            {
                printf ("\nBit Swap Request Message omitted.Error!");            
                return WRONG_CMD;
            }

            if (CmdInfo[_PORTNUM_+2].Length > (12*2))
            {
                printf ("\nBit Swap Request Message length %d exceeded max 12 size.Error!", CmdInfo[_PORTNUM_+2].Length);           
                return WRONG_CMD;
            }

            TmpString[0]=(U8) CmdInfo[_PORTNUM_+2].Length / 2;
            for (index = 0; index < TmpString[0]; index++)
            {
                sscanf(&bValidPtr[CmdInfo[_PORTNUM_+2].Index+(index * 2)], "%2x", 
                       &iTmpVar);

                TmpString[index+1]=(U8) iTmpVar;

            }           
            oampBitSwapReq (pPid,bParam1,TmpString,*cmdTag,0);

            CmdType = CTRL_CMD; 
            break;

        case EOC_DATA_REPLY: /* EOC Opcode, Length, EocData - data size 128 */

            if (bParmCnt != (_PORTNUM_+4))
            {
                printf ("\nwrong parameter count %d for ApiCmd EOC_DATA_REPLY. Error!", bParmCnt);
                return WRONG_CMD;
            }

            {                                       /* Local function for EOC_DATA_REPLY parsing */

                U8  opCode, len, reg[128];
                /* EocOpcode */
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
                bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

                if (!bCmd[0])
                {
                    printf ("\nEocOpcode omitted.Error!");          
                    return WRONG_CMD;
                }

                iTmpVar = atoi(( U8 *)bCmd);
                opCode = ( U8)iTmpVar;

                /* Length */
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+2].Index],CmdInfo[_PORTNUM_+2].Length);
                bCmd[CmdInfo[_PORTNUM_+2].Length] = 0;

                if (!bCmd[0])
                {
                    printf ("\nLength of data omitted. Error!");            
                    return WRONG_CMD;
                }

                iTmpVar = atoi(( U8 *)bCmd);
                len = ( U8) iTmpVar;

                /* EocData - data size 128 */
                if (!CmdInfo[_PORTNUM_+3].Length)
                {
                    printf ("\nEocData omitted.Error!");            
                    return WRONG_CMD;
                }

                if (CmdInfo[_PORTNUM_+3].Length > (128*2))
                {
                    printf ("\nEocData length %d exceeded max 128 size.Error!", CmdInfo[_PORTNUM_+3].Length);           
                    return WRONG_CMD;
                }

                for (index = 0; index < (CmdInfo[_PORTNUM_+3].Length); index++)
                {
                    sscanf(&bValidPtr[CmdInfo[_PORTNUM_+3].Index+index], "%1x", 
                           &iTmpVar);
                    reg[index]=iTmpVar;
                }

                oampEocDataReply(pPid,opCode,len, reg, *cmdTag, 0);
            }

            CmdType = CTRL_CMD;
            break;

        case EOC_SEND_DATA_STREAM: /* data - 250 size */

            {   
                U8  len, reg[500];

                if (bParmCnt != (_PORTNUM_+2))
                {
                    printf ("\nwrong parameter count %d for ApiCmd EOC_SEND_DATA_STREAM. Error!", bParmCnt);
                    return WRONG_CMD;
                }

                if (!CmdInfo[_PORTNUM_+1].Length)
                {
                    printf ("\nStreamData omitted.Error!");         
                    return WRONG_CMD;
                }

                if (CmdInfo[_PORTNUM_+1].Length > (250*2))
                {
                    printf ("\ndata size exceeded %d for ApiCmd EOC_SEND_DATA_STREAM. Error!",
                            CmdInfo[_PORTNUM_+1].Length);
                    return WRONG_CMD;
                }

                len=CmdInfo[_PORTNUM_+1].Length;

                for (index = 0; index < (CmdInfo[_PORTNUM_+1].Length); index++)
                {
                    sscanf(&bValidPtr[CmdInfo[_PORTNUM_+1].Index+index], "%1x", 
                           &iTmpVar);
                    reg[index]=iTmpVar;
                }


                oampEocSendDataStream(pPid, len, reg, *cmdTag, 0);
            }

            CmdType = CTRL_CMD; 
            break;

        case EOC_GET_DATA:  /* EOC Opcode */
            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd EOC_GET_DATA. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* EocOpcode */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nEocOpcode omitted.Error!");          
                return WRONG_CMD;
            }

            //iTmpVar = atoi(( U8 *)bCmd);
            sscanf (bCmd, "%x", &iTmpVar);

            printf("Eoc Opcode = %x\n", iTmpVar);
            /* todo: if needed flip the  U8s */
            bParam1 = ( U8)iTmpVar;
            /* todo: error checking of opcode required ? */
            oampEocGetData(pPid,bParam1,*cmdTag,0);
            CmdType = CTRL_CMD;
            break;

        case CLEAR_ALL_COUNTERS:
			if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd CLEAR_ALL_COUNTERS. Error!", bParmCnt);
                return WRONG_CMD;
            }
            
            oampPortClrNeCntr(pPid,*cmdTag, 0);
            CmdType = CTRL_CMD;
            break;

            /* Status Request Commands */
        case PORT_STATUS_BRIEF:
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_STATUS_BRIEF. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortGetStatusBrief(pPid,*cmdTag, 0);

            CmdType = STATUS_REQUEST_CMD;
            break;

        case PORT_STATUS_EXTENDED:
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_STATUS_EXTENDED. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortGetStatus(pPid,*cmdTag, 0);

            CmdType = STATUS_REQUEST_CMD;
            break;

        case PERFORMANCE_MONITORING:    /* Report type, Parameter type */

#if 0
            if (bParmCnt != (_PORTNUM_+3))
            {
                printf ("\nwrong parameter count %d for ApiCmd PERFORMANCE_MONITORING. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* Report type */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nReportType omitted.By default NE_15MIN type (0) is chosen!");            
                RepType = 0;
            } else
            {
                iTmpVar = atoi(( U8 *)bCmd);
                /* todo: if needed flip the  U8s */
                RepType = (eReportType)iTmpVar;
            }

            /* todo: error checking of reporttype required ? */
            if ((RepType < NE_15MIN) && (RepType > FE_24HOUR))
            {
                printf ("\nWrong Report type %d. Error!", RepType);
                return WRONG_CMD;
            }

            /* Parameter type */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+2].Index],CmdInfo[_PORTNUM_+2].Length);
            bCmd[CmdInfo[_PORTNUM_+2].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nParameterType omitted.By default CV_SLOW_15MIN type (0) is chosen!");            
                ParaType = 0;
            } else
            {
                iTmpVar = atoi(( U8 *)bCmd);
                /* todo: if needed flip the  U8s */
                ParaType = (eParaType)iTmpVar;
            }

            /* todo: error checking of reporttype required ? */
            if ((ParaType < CV_SLOW_15MIN) && (ParaType > UASEC_24HOUR))
            {
                printf ("\nWrong Parameter type %d. Error!", ParaType);
                return WRONG_CMD;
            }

            PerfParm = GetPerfParameter (&Bme[iBmeNum], iPortNum, RepType, ParaType);

#ifdef _DEBUG_
            printf ("\nPerformance parameter %d : %lx", ParaType, PerfParm);
#endif /* _DEBUG_ */			

            CmdType = PERFORMANCE_REPORT_CMD;
#endif

            break;

        case THRESHOLD_REPORTS: /* Report type */
#if 0
            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd THRESHOLD_REPORTS. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* Report type */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nReportType omitted.By default NE_15MIN type (0) is chosen!");            
                RepType = 0;
            } else
            {
                iTmpVar = atoi(( U8 *)bCmd);
                /* todo: if needed flip the  U8s */
                RepType = (eReportType)iTmpVar;
            }

            /* todo: error checking of reporttype required ? */
            if ((RepType < NE_15MIN) && (RepType > FE_24HOUR))
            {
                printf ("\nWrong Report type %d. Error!", RepType);
                return WRONG_CMD;
            }

            if ((pThresRep = GetThresholdReport (&Bme[iBmeNum], iPortNum, RepType)) == NULL)
            {
                printf ("\nThreshold Report returns NULL. Error!");
                return WRONG_CMD;
            }

            DisplayThresholdReport (RepType, pThresRep);

            CmdType = THRESHOLD_REPORT_CMD;
#endif			
            break;

        case SYSTEM_STATUS:
            CmdType = STATUS_REQUEST_CMD;
            break;

        case GET_NE_SNR_ATTN:
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_STATUS_EXTENDED. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortGetNeSnr(pPid,*cmdTag, 0);

            CmdType = STATUS_REQUEST_CMD;
            break;

        case GET_COUNTERS:
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PORT_STATUS_EXTENDED. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortGetCounters(pPid,*cmdTag, 0);

            CmdType = STATUS_REQUEST_CMD;
            break;
            
        case GET_PM_COUNTERS:
            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd GET_PM_COUNTERS. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampPortGetPMCounters(pPid,*cmdTag, 0);

            CmdType = STATUS_REQUEST_CMD;

            break;

        case PM_CONFIG_PARAMS:

            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd PM_CONFIG_PARAMS. Error!", bParmCnt);
                return WRONG_CMD;
            }

            {
                ipos_pm_config pmConfig;

                pmConfig.FEC_Second_Threshold    = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.NeES_Second_Threshold   = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.NeSES_Second_Threshold  = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.NeLOS_Second_Threshold  = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.NeUnavl_Second_Threshold  = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.FeFEC_Second_Threshold  = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.FeES_Second_Threshold   = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.FeSE_Second_Threshold = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.FeLOS_Second_Threshold = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.FeUnavl_Second_Threshold = PM_DEFAULT_SECOND_THRESHOLD;
                pmConfig.LOS_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.LOF_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.LPR_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.LOM_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.ESE_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.NCD_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.LCD_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.NCD_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.LCD_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FEC_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.CRC_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.HEC_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FEC_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.CRC_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.HEC_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeLOS_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeLOF_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeLPR_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeLOM_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeESE_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeNCD_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeLCD_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeNCD_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeLCD_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FePO_Threshold    = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeFEC_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeCRC_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeHEC_S_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeFEC_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeCRC_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;
                pmConfig.FeHEC_F_Threshold = PM_DEFAULT_COUNT_THRESHOLD;

                oampPmConfig(pPid, &pmConfig, *cmdTag, 0);

                CmdType = CTRL_CMD;
            }

            break;

        case PM_TRIGGER_FAILURES:

            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd GET_PM_COUNTERS. Error!", bParmCnt);
                return WRONG_CMD;
            }

            {

                oampPortPmTriggerFailures(pPid, &PmTrigger, *cmdTag, 0);

                CmdType = CTRL_CMD;
            }

            break;

        case PERIODIC_REPORTS_ENABLE:   /* Reports Enable */
            {
                ipos_report_config  reportConfig;

                if (bParmCnt != (_PORTNUM_+4))
                {
                    printf ("\nwrong parameter count %d for ApiCmd PERIODIC_REPORTS_ENABLE. Error!", bParmCnt);
                    return WRONG_CMD;
                }

                /* Report type */
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
                bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

                if (!bCmd[0])
                {
                    printf ("\nEnable option omitted.By default Enable option (0) is chosen!");         
                    bParam1 = 0;
                } else
                {
                    iTmpVar = atoi(( U8 *)bCmd);
                    /* todo: if needed flip the  U8s */
                    bParam1 = ( U8)iTmpVar;
                }

                if (bParam1 > 7)
                {
                    printf("\nWrong enable flag value.");
                    return WRONG_CMD;
                }

                reportConfig.ReportsEnable = bParam1;

                /* Alarm count frequency */
                reportConfig.AlarmCountFreq = atoi(&bValidPtr[CmdInfo[_PORTNUM_+2].Index]);
                printf("\n alm freq %d",reportConfig.AlarmCountFreq);
                bCmd[CmdInfo[_PORTNUM_+2].Length] = 0;

                /* System status frequency */
                reportConfig.SystemStatusFreq = atoi(&bValidPtr[CmdInfo[_PORTNUM_+3].Index]);
                printf("\n status freq %d",reportConfig.SystemStatusFreq);
                bCmd[CmdInfo[_PORTNUM_+3].Length] = 0;

                oampPeriodicReportsEnable(pPid, &reportConfig, *cmdTag, 0);
            }

            CmdType = STATUS_REQUEST_CMD;
            break;

        case UPDATED_REPORTS_ENABLE:    /* Reports Enable */
#ifdef	NOTI
            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd UPDATED_REPORTS_ENABLE. Error!", bParmCnt);
                return WRONG_CMD;
            }

            /* Report type */
            memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
            bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;

            if (!bCmd[0])
            {
                printf ("\nEnable option omitted.By default Enable option (0) is chosen!");         
                bParam1 = 0;
            } else
            {
                iTmpVar = atoi(( U8 *)bCmd);
                /* todo: if needed flip the  U8s */
                bParam1 = ( U8)iTmpVar;
            }

            if (bParam1 > 1)
            {
                printf("\nWrong enable flag value.");
                return WRONG_CMD;
            }

            Bme[iBmeNum].Port[iPortNum].PortParms.UpdatedReportParms.ReportsEnable = bParam1;

            CmdType = STATUS_REQUEST_CMD;
#endif			
            break;

        case DEVICE_VERSIONS:

            if (bParmCnt != (_BMENUM_+1))
            {
                printf ("\nwrong parameter count %d for ApiCmd BME_START. Error!", bParmCnt);
                return WRONG_CMD;
            }

            oampBmeGetVersion(pPid->bmeNum,0,*cmdTag);      /* Note:current implementation: firmware addr is 
                                                                    defined in bmeconfig.h */
            CmdType = CTRL_CMD;
            break;

        case GET_SELFTEST_RESULTS:
            CmdType = STATUS_REQUEST_CMD;
            break;

            /* Autonomous APIs */
        case EOC_RELAY_DATA_STREAM: /* data size - 250 */
            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd EOC_RELAY_DATA_STREAM. Error!", bParmCnt);
                return WRONG_CMD;
            }

            if (!CmdInfo[_PORTNUM_+1].Length)
            {
                printf ("\nStreamData omitted.Error!");         
                return WRONG_CMD;
            }

            if (CmdInfo[_PORTNUM_+1].Length > (250*2))
            {
                printf ("\ndata size exceeded %d for ApiCmd EOC_RELAY_DATA_STREAM. Error!",
                        CmdInfo[_PORTNUM_+1].Length);
                return WRONG_CMD;
            }

#if 0
            for (index = 0; index < (CmdInfo[_PORTNUM_+1].Length/2); index++)
            {
                sscanf(&bValidPtr[CmdInfo[_PORTNUM_+1].Index+(index*2)], "%02x", 
                       &TmpArray[index]);
                Bme[iBmeNum].Port[iPortNum].PortParms.EocRelayDataStrParms.DataStream[index]=( U8)TmpArray[index];
#ifdef _DEBUG_
                printf ("\nindex %d val %x", index, Bme[iBmeNum].Port[iPortNum].PortParms.EocRelayDataStrParms.DataStream[index]);
#endif /* _DEBUG_ */
            }
#endif		


#ifdef _DEBUG_
            printf ("\nDatasize %d", CmdInfo[_PORTNUM_+1].Length);
#endif /* _DEBUG_ */

            CmdType = AUTONOMOUS_CMD;
            break;

        case EOC_MSG_RECEIVE: /* Opcode , data - size 128 */
            CmdType = AUTONOMOUS_CMD;
            break;

            /* Debug APIs */
        case SET_LOOPBACK:  /* Loopback mode */
            if (bParmCnt != (_PORTNUM_+2))
            {
                printf ("\nwrong parameter count %d for ApiCmd SET_LOOPBACK. Error!", bParmCnt);
                return WRONG_CMD;
            }
            {
                int    lbType;

                sscanf(&bValidPtr[CmdInfo[_PORTNUM_+1].Index], "%d", &lbType);

                // Bme[iBmeNum].Port[iPortNum].PortParms.SetLpbkParms.LoopbackMode = bParam1;            
                oampLbStart(pPid, *cmdTag, 0, lbType);
                CmdType = DEBUG_CMD;
            }
            break;

        case DETECT_SIGNALS: 
        case SEND_SIGNALS:
			{
			  ipos_test_signals tstSignals;
 
				memset((U8 *)&(tstSignals), 0, sizeof(ipos_test_signals));

				if (bParmCnt != (_PORTNUM_+7))
				{
					printf ("\nwrong parameter count %d for ApiCmd SEND_TONES. Error!", bParmCnt);
					return WRONG_CMD;
				}
				
				memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
				bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;
				
				if (!bCmd[0])
				{
					printf ("\nSigType omitted.Error!");           
					return WRONG_CMD;
				} 
				else
				{
					iTmpVar = atoi(( U8 *)bCmd);
					tstSignals.SigType = (U8) iTmpVar;
				}
				
				memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+2].Index],CmdInfo[_PORTNUM_+2].Length);
				bCmd[CmdInfo[_PORTNUM_+2].Length] = 0;
				
				if (!bCmd[0])
				{
					printf ("\nnumTones omitted.Error!");           
					return WRONG_CMD;
				} 
				else
				{
					iTmpVar = atoi(( U8 *)bCmd);
					tstSignals.NumTones = (U8) iTmpVar;
				}
				
				memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+3].Index],CmdInfo[_PORTNUM_+3].Length);
				bCmd[CmdInfo[_PORTNUM_+3].Length] = 0;
				
				if (!bCmd[0])
				{
					printf ("\nTone1 omitted.Error!");           
					return WRONG_CMD;
				} 
				else
				{
					iTmpVar = atoi(( char *)bCmd);
					tstSignals.Tone1 = (U16) iTmpVar;
				}
				
				memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+4].Index],CmdInfo[_PORTNUM_+4].Length);
				bCmd[CmdInfo[_PORTNUM_+4].Length] = 0;
				
				if (!bCmd[0])
				{
					printf ("\nTone2 omitted.Error!");           
					return WRONG_CMD;
				} 
				else
				{
					iTmpVar = atoi(( char *)bCmd);
					tstSignals.Tone2 = (U16) iTmpVar;
				}
									  
				memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+5].Index],CmdInfo[_PORTNUM_+5].Length);
				bCmd[CmdInfo[_PORTNUM_+5].Length] = 0;
				
				if (!bCmd[0])
				{
					printf ("\nTone3 omitted.Error!");           
					return WRONG_CMD;
				} 
				else
				{
					iTmpVar = atoi(( char *)bCmd);
					tstSignals.Tone3 = (U16) iTmpVar;
				}
									  
				memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+6].Index],CmdInfo[_PORTNUM_+6].Length);
				bCmd[CmdInfo[_PORTNUM_+6].Length] = 0;
				
				if (!bCmd[0])
				{
					printf ("\nSweepInterval omitted.Error!");           
					return WRONG_CMD;
				} 
				else
				{
					iTmpVar = atoi(( char *)bCmd);
					tstSignals.SweepInterval = (U16) iTmpVar;
				}
				
				if ( tstSignals.SigType >= HPI_RX_POWER )
				{
					oampDetectSignal(pPid, &tstSignals, *cmdTag, tstSignals.SigType);
				}
				else
				{
					oampSendSignal(pPid, &tstSignals, *cmdTag, tstSignals.SigType);
				}

				CmdType = DEBUG_CMD;
			}
				break;



#ifdef	USE_RFM

        case    RFM_LOAD_IMAGE:
            {

                char    hostName[128];
                char    fileName[128];
                int     /*errCode,*/i;

                for (i=0;i<128;i++)
                {
                    hostName[i]=0;
                    fileName[i]=0;

                }


                if (bParmCnt != (_PORTNUM_+1))
                {
                    printf ("\nwrong parameter count %d for ApiCmd RFM_LOAD_IMAGE. Error!", bParmCnt);
                    return WRONG_CMD;
                }

                /* profile number */
                if (CmdInfo[_BMENUM_].Length > MAX_CMD_LENGTH)
                {
                    printf("\nRFM_LOAD_IMAGE length %d exceeds the max cmd length %d", CmdInfo[_BMENUM_].Length, MAX_CMD_LENGTH);
                    return WRONG_CMD;
                }

                if (CmdInfo[_PORTNUM_].Length > MAX_CMD_LENGTH)
                {
                    printf("\nRFM_LOAD_IMAGE length %d exceeds the max cmd length %d", CmdInfo[_BMENUM_].Length, MAX_CMD_LENGTH);
                    return WRONG_CMD;
                }

                memcpy(fileName,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index], CmdInfo[_BMENUM_].Length);
                bCmd[CmdInfo[_BMENUM_].Length] = 0;

                //memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index],CmdInfo[_BMENUM_].Length);
                memcpy(hostName,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_].Index],CmdInfo[_PORTNUM_].Length) ;
                bCmd[CmdInfo[_PORTNUM_].Length] = 0;

                printf("\nLoading file %s from host %s...\n",fileName, hostName);
				remDldImgFlag = 1;
                remoteDownLoadImage(1,hostName, fileName);         
				remDldImgFlag = 0;
                printf(PROMPT);

            }

            break;

        case    RFM_DOWNLOAD_CPE:

            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for DOWNLOAD CPE. Error!", bParmCnt);
                return WRONG_CMD;
            }

            uiDnldCpe(*pPid);

            CmdType = CTRL_CMD; 
            break;

            break;

        case    RFM_ACTIVATE_CPE:
            {

                U8  actOption;

                if (bParmCnt != (_PORTNUM_+2))
                {
                    printf ("\nwrong parameter count %d for ACTIVATE CPE. Error!", bParmCnt);
                    return WRONG_CMD;
                }

                if (CmdInfo[_PORTNUM_+1].Length>1)
                {
                    printf("\nwrong activation option: 0 or 1!");
                    return	WRONG_CMD;
                }
                /* get the port reset option	*/
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],CmdInfo[_PORTNUM_+1].Length);
                bParam1=atoi(bCmd);
                actOption=(U8) bParam1;

                uiActivateImage(*pPid,actOption);
                CmdType = CTRL_CMD; 
            }
            break;

        case RFM_GET_CPE_VERSION:

            if (bParmCnt != (_PORTNUM_+1))
            {
                printf ("\nwrong parameter count %d for GET CPE VERSION Error!", bParmCnt);
                return WRONG_CMD;
            }

            uiGetRMVersion(*pPid);
            CmdType = CTRL_CMD; 
            break;


        case RFM_SET_DISPLAY:
            {

                U8  dLevel;

                if (bParmCnt != (_PORTNUM_))
                {
                    printf ("\nwrong parameter count %d for set display level. Error!", bParmCnt);
                    return WRONG_CMD;
                }

                if (CmdInfo[_BMENUM_].Length>1)
                {
                    printf("\nwrong display level option: 0 or 1!");
                    return	WRONG_CMD;
                }
                /* get the port reset option	*/
                memcpy (( U8 *)bCmd,( U8 *)&bValidPtr[CmdInfo[_BMENUM_].Index],CmdInfo[_BMENUM_].Length);
                bParam1=atoi(bCmd);
                dLevel=(U8) bParam1;

                uiSetDisplay(dLevel);
                CmdType = CTRL_CMD; 
            }

            break;
#endif


        case OPTIONAL_CMD:  
            if (bParmCnt != (_BMENUM_+4))
            {
                printf ("\nwrong parameter count %d for ApiCmd GET_PER_TONE_BIT_LOAD. Error!", bParmCnt);
                return WRONG_CMD;
            }
            {
                unsigned int    addr;
                int             length;

                sscanf(&bValidPtr[CmdInfo[_BMENUM_+2].Index], "%d", &addr);
                sscanf(&bValidPtr[CmdInfo[_BMENUM_+3].Index], "%d", &length);               
                oampOptionalCmd(pPid, *cmdTag, addr, length);           
            }
            break;  

/* save some space on the CPE by not compiling TL commands that would not work anyway. */

#ifdef VTU_O
	case GET_EOC_PROTOCOL_VER:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get EOC Protocol Version", bParmCnt);
                    printf( "\nUsage: geteoc::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetEocProtocolVer( *pPid );
		    CmdType = CTRL_CMD;
	    }
            break;

	case REMOTE_REBOOT:
            if (bParmCnt < (_PORTNUM_+1))
            {
                printf( "\nwrong parameter count %d for reboot CPE", bParmCnt);
                printf( "\nUsage: rebootcpe::<BME>:<port>;\n" );
                CmdType = WRONG_CMD;
            }
	    else {
		U8	firmwareChoice = 0;

		if (bParmCnt > _PORTNUM_+1)
		{
		    firmwareChoice = atoi( &bValidPtr[ CmdInfo[ _PORTNUM_ + 1 ].Index ] );
		}
		uiRemoteReboot( *pPid, firmwareChoice );
		CmdType = CTRL_CMD;
	    }
            break;

	case GET_REMOTE_VERSION:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote Version", bParmCnt);
                    printf( "\nUsage: geteoc::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteVersion( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;

	case GET_REMOTE_ERRORED_SECONDS:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote Errored Seconds", bParmCnt);
                    printf( "\nUsage: getrerrs::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteErroredSeconds( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;

	case GET_REMOTE_ENET_STATUS:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote Ethernet Status", bParmCnt);
                    printf( "\nUsage: getrenet::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteEthernetStatus( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;
	case GET_REMENET_RPT_FLAG:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote Autonomous Ethernet Status Reporting Flag", bParmCnt);
                    printf( "\nUsage: getrenetrptflag::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteEnetAutoRptFlag( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;
		
	case GET_REMOTE_MDIO_REGS:
          if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote MDIO Register", bParmCnt);
                    printf( "\nUsage: getrmdio::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteMDIORegs( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;
	case GET_REMOTE_FPGA_MDIO_REGS:
  {                               
      int mdioFpgaReg_no = 0;
      U8 str[40];
      if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote MDIO Register", bParmCnt);
                    printf( "\nUsage: getrfpgamdio::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
      
        printf ("\n Enter the Register Number in Hex (Reg.Range [0x0 to 0x%x]):  ",MAX_FPGA_REGS);
        gets(str);
        sscanf(str,"%x",&mdioFpgaReg_no);

        if((mdioFpgaReg_no < 0) || (mdioFpgaReg_no > MAX_FPGA_REGS))
            printf("Invalid FPGA Register Address:%x",mdioFpgaReg_no);
        else
        {
     		  uiGetRemoteFpgaMDIOReg( *pPid, (U16 )mdioFpgaReg_no);
          CmdType = CTRL_CMD;
        }
	    }
	    break;
  }        
    case GET_REMOTE_ENET_CFG:
          if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote Enet Config.", bParmCnt);
                    printf( "\nUsage: getrenetcfg::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteEnetCfg( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;
    case GET_REMOTE_GPIO_PINS:
          if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote GPIO Pins", bParmCnt);
                    printf( "\nUsage: getrgpio::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteGPIOPin( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;

	case GET_REMOTE_MODEM_ID:
		 if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote Modem ID", bParmCnt);
                    printf( "\nUsage: getrmodid::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteModemId( *pPid );
		    CmdType = CTRL_CMD;
	    }
		break;
	case GET_REMOTE_TXPWR:
		 if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for get Remote Tx Power", bParmCnt);
                    printf( "\nUsage: getrtxpwr::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiGetRemoteTxPower( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;

  case GET_REMOTE_LEARNED_ENET_ADDR:
    if (bParmCnt != (_PORTNUM_+1))
    {
      printf( "\nwrong parameter count %d for get Remote Learned Enet Addresses", bParmCnt);
      printf( "\nUsage: getrlrndenetaddr::<BME>:<port>;\n" );
      CmdType = WRONG_CMD;
    }
    else 
    {
		  uiGetRemoteLearnedEnetAddress( *pPid );
		  CmdType = CTRL_CMD;
    }
    break;


    case SET_REMENET_STATUS_RPT:
		 if (bParmCnt != (_PORTNUM_+2))
            {
                    printf( "\nwrong parameter count %d for set Autonomous Ethernet Status Report", bParmCnt);
                    printf( "\nUsage: setaenetrpt::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
            memcpy( (BYTE *)bCmd,
			   (BYTE *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],
				    CmdInfo[_PORTNUM_+1].Length);
			bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;
		    bParam1=atoi(bCmd);
		    uiSetAutoEnetStatusRpt( *pPid, bParam1 );
		    CmdType = CTRL_CMD;
	    }
	    break;
	case SET_REMOTE_ENET_LB:
            if (bParmCnt != (_PORTNUM_+2))
            {
                    printf( "\nwrong parameter count %d for Set Remote Ethernet Loopback", bParmCnt);
                    printf( "\nUsage: setrphylb::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
            	    memcpy( (BYTE *)bCmd,
			   (BYTE *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],
				    CmdInfo[_PORTNUM_+1].Length);
		    bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;
		    bParam1=atoi(bCmd);
		    uiSetRemoteEthernetLb( *pPid, bParam1 );
		    CmdType = CTRL_CMD;
	    }
	    break;
 	case SET_REMOTE_MDIO_REG:

		if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for set Remote MDIO Reg", bParmCnt);
                    printf( "\nUsage: setrmdio::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {

			printf ("\n Enter the Register Number:  ");
			scanf ("%d", &mdioReg_no);
 
			printf ("\n Enter the Register Value (in Hex):  ");
			scanf ("%x", &mdioReg_value);

 		    uiSetRemoteMDIOReg( *pPid, mdioReg_no, mdioReg_value);
		    CmdType = CTRL_CMD;
	    }
		break;
  case SET_REMOTE_FPGA_MDIO_REG:
  {
    int mdioFpgaReg_no = 0;
    int mdioFpgaReg_value = 0;
    U8 str[40];
                                
		if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for set Remote MDIO Reg", bParmCnt);
                    printf( "\nUsage: setrfpgamdio::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {

      printf ("\n Enter the Register Number(Reg.Range [0 to 0x%x]):  ", MAX_FPGA_REGS);
      
 
   gets(str);
      sscanf(str,"%x",&mdioFpgaReg_no);
      if((mdioFpgaReg_no < 0) || (mdioFpgaReg_no > MAX_FPGA_REGS))
           printf("Invalid FPGA Register Address:%x",mdioFpgaReg_no);
      else
      {
        printf ("\n Enter the Register Value (in Hex):  ");
 
     gets(str);
        sscanf(str,"%x",&mdioFpgaReg_value);

   		  uiSetRemoteFpgaMDIOReg( *pPid, (U16) mdioFpgaReg_no, 
                          (U16) mdioFpgaReg_value);
	  	  CmdType = CTRL_CMD;
      }
	    }
		break;

 }
	case SET_ENET_FLOW_CONTROL:
            if (bParmCnt != (_PORTNUM_+2))
            {
                    printf( "\nwrong parameter count %d for Set Remote Ethernet Flow Control", bParmCnt);
                    printf( "\nUsage: setreflow::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
            	    memcpy( (BYTE *)bCmd,
			   (BYTE *)&bValidPtr[CmdInfo[_PORTNUM_+1].Index],
				    CmdInfo[_PORTNUM_+1].Length);
		    bCmd[CmdInfo[_PORTNUM_+1].Length] = 0;
		    bParam1=atoi(bCmd);
		    uiSetRemoteEthernetFlow( *pPid, bParam1 );
		    CmdType = CTRL_CMD;
	    }
	    break;
	case SET_REMOTE_ENET_CFG:
		 if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for set Remote Ethernet Configuration", bParmCnt);
                    printf( "\nUsage: setrenetcfg::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiSetRemotePhyParams( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;
	case CLEAR_REMOTE_CNTRS:
		  if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for clear Remote Counters", bParmCnt);
                    printf( "\nUsage: clrrcntr::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiSetClearRemoteCounters( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;
#endif

        case GET_DEVICE_VERSIONS:
            if (bParmCnt != (_BMENUM_+1))
            {
                printf ("\nwrong parameter count %d for BME TL command get device versions\n", bParmCnt);
                return WRONG_CMD;
            }
	    else if (pPid->bmeNum > MAX_NUM_OF_BMES)
	    {
                printf ("\ninvlaid BME number %d for get device versions\n", pPid->bmeNum );
                CmdType = WRONG_CMD;
	    }
	    else {
		status=iposDeviceVersion( pPid->bmeNum, *cmdTag, 0, storeDeviceVersions );
		if (status != IPOS_SUCCESS)
		{
		    printf( "\nProblem getting BME/hardware versions, error is %d\n", status );
		}
		CmdType = CTRL_CMD;
	    }

            break;

        case SHOW_DEVICE_VERSIONS:
            if (bParmCnt != (_BMENUM_+1))
            {
                printf ("\nwrong parameter count %d for BME TL command get device versions\n", bParmCnt);
                return WRONG_CMD;
            }
	    else {
		uiShowDeviceVersions( pPid->bmeNum );
		CmdType = CTRL_CMD;
	    }

            break;

	case SHOW_ERRORED_SECONDS:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for show Remote Errored Seconds", bParmCnt);
                    printf( "\nUsage: showerrs::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiShowErroredSeconds( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;

	case SHOW_ETHERNET_STATUS:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for show ethernet status", bParmCnt);
                    printf( "\nUsage: showenet::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiShowEthernetStatus( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;

	case SEND_VIRTUAL_MESSAGE_1:
            if (bParmCnt != (_PORTNUM_+1))
            {
                    printf( "\nwrong parameter count %d for send virtual protocol 1", bParmCnt);
                    printf( "\nUsage: sendvp1::<BME>:<port>;\n" );
                    CmdType = WRONG_CMD;
            }
	    else {
		    uiSendVirtualMessage1( *pPid );
		    CmdType = CTRL_CMD;
	    }
	    break;

#endif // BUP

        default:
            break;
    }

    return CmdType;
}

void displayTLHelp (void)
{
#ifndef BUP_DIAGS
    printf("\nList of BME TL Commands");
    printf("\n");   
    printf("\nbitswapreq  bstart      breset        clrcntr         detectsig");
    printf("\ndevver      emiconfig     evloge          evlogc          evlogp");
    printf("\nevlogs      eoctrltx      eorxdata        eotxdata");
    printf("\neosetdata   eodatarep     eoreldat        eomsgrcv");
    printf("\nfifode      fifods        getpprof        gselft   getcntr");
    printf("\nlpbk        msgtrace      msgfilter       pprov           pstat       ");
    printf("\npinst       pstart        perreppreset    pstop	    	pdes");
    printf("\npermon      setpprof      sysstatus       sendsig");
    printf("\nsysprov     thresrep      updrep          pstatex");
    printf("\nmtrstat     msgfilval     getendtype");
    printf("\nsetendtype  getPerToneBitLoad");
    printf("\ngetpmcntr   pmconfig      pmtrigger");
    printf("\n\nType \"?cmd\" to get the syntax of the specific command");
    printf("\nType \"??cmd\" to get the detailed syntax of the specific command");

    return;
#endif
}

void displayTLCmdSyntax (eCommands Cmd,  U8 bDetailSyntax)
{
#ifndef BUP_DIAGS

    switch (Cmd)
    {
        /* A Cmds */
        /* B Cmds */
        case BME_START:
            printf("\nBME_START");
            printf("\nbstart:cmdtag:bmenum[1..%d];",MAX_NUM_OF_BMES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
            }
            break;

        case BME_RESET:
            printf("\nBME_RESET");
            printf("\nbreset:cmdtag:bmenum[1..%d];",MAX_NUM_OF_BMES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
            }
            break;

            /* C Cmds */
        case CLEAR_ALL_COUNTERS:
            printf("\nCLEAR_ALL_COUNTERS");
            printf("\nclrcntr:cmdtag:bmenum[1..%d];",MAX_NUM_OF_BMES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
            }
            break;

            /* D Cmds */
        case DEVICE_VERSIONS:
            printf("\nDEVICE_VERSIONS");
            printf("\ndevver:cmdtag:bmenum[1..%d];",MAX_NUM_OF_BMES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
            }
            break;

            /* E Cmds */
        case EMI_CONFIG:
            printf("\nEMI_CONFIG");
            printf("\nemiconfig:cmdtag:bmenum[1..%d]:memtype[sram/sdram]:memsize:caslat:rcdel:rowpre:rowact:rowcyc;",MAX_NUM_OF_BMES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nmemtype - sram / sdram");
                printf("\nmemsize - if SRAM, 1MB(1) / 2MB(2)");
                printf("\n          if SDRAM, 16MB(16) / 22MB(22) / 8MB(8)");
                printf("\ncaslat - if SDRAM, CAS Latency 3CLOCKS(3) / 2CLOCKS(2)");
                printf("\nrcdel - if SDRAM, RAS to CAS delay 3CLOCKS(3) / 2CLOCKS(2)");
                printf("\nrowpre - if SDRAM, min row precharge time 3CLOCKS(3) / 2CLOCKS(2)");
                printf("\nrowact - if SDRAM, min row active time 6CLOCKS(6) / 7CLOCKS(7)");
                printf("\nrowcyc - if SDRAM, min row cycle time 11CLOCKS(11) / 10CLOCKS(10)");
            }
            break;

        case EVENT_LOG_STATUS:
            printf("\nEVENT_LOG_STATUS");
            printf("\nevlogs:cmdtag;");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
            }
            break;

        case EVENT_LOG_ENABLE:
            printf("\nEVENT_LOG_ENABLE");
            printf("\nevloge:cmdtag:enable[0..1];");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nenable - enable(1) / disable(0)");
            }
            break;

        case EVENT_LOG_CLEAR:
            printf("\nEVENT_LOG_CLEAR");
            printf("\nevlogc:cmdtag;");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
            }
            break;

        case EVENT_LOG_PRINT:
            printf("\nEVENT_LOG_PRINT");
            printf("\nevlogp:cmdtag;");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
            }
            break;

        case PERIODIC_REPORTS_ENABLE:
            printf("\nPERIODIC_REPORTS_ENABLE");
            printf("\nperrep:cmdtag:bmenum[1..%d]:portnum[1..%d]:enable[0..1]:alarmfreq[0..255]:sysstatusfreq[0..255];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                printf("\nenable - enable(1) / disable(0)");
                printf("\nalarmfreq - frequency of alarm counter report in ms - max 512 (100ms)");
                printf("\nsysstatusfreq - frequency of system status report in ms - max 512 (100ms)");
            }
            break;

        case UPDATED_REPORTS_ENABLE:
            printf("\nUPDATED_REPORTS_ENABLE");
            printf("\neupdreport:cmdtag:bmenum[1..%d]:portnum[1..%d]:enable[0..1];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                printf("\nenable - enable(1) / disable(0)");
            }
            break;

        case EOC_GET_DATA:
            printf("\nEOC_GET_DATA");
            printf("\nerxdata:cmdtag:bmenum[1..%d]:portnum[1..%d]:opcode;",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);  
                printf("\nopcode - EOC opcode");
            }
            break;

        case EOC_SEND_DATA_STREAM:
            printf("\nEOC_SEND_DATA_STREAM");
            printf("\netxdata:cmdtag:bmenum[1..%d]:portnum[1..%d]:streamdata[hex  U8s - size 250];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);  
                printf("\nstreamdata - max len 250. data in hex  U8s");
            }
            break;

        case EOC_MSG_RECEIVE:
            printf("\nEOC_MSG_RECEIVE");
            printf("\nemsgrcv:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);  
            }
            break;

        case EOC_CONTROL_SEND:
            printf("\nEOC_CONTROL_SEND");
            printf("\neoctrltx:cmdtag:bmenum[1..%d]:portnum[1..%d]:opcode;",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);  
                printf("\nopcode - EOC opcode");
            }
            break;

        case EOC_SET_DATA:
            printf("\nEOC_SET_DATA");
            printf("\neosetdata:cmdtag:bmenum[1..%d]:portnum[1..%d]:opcode:regdata[hex  U8s - size 128];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);  
                printf("\nopcode - EOC opcode");
                printf("\nregdata - EOC register data. Max len 128. Data in hex  U8s");
            }
            break;

        case BIT_SWAP_REQ:
            printf("\nBIT_SWAP_REQ");
            printf("\nbitswapreq:cmdtag:bmenum[1..%d]:portnum[1..%d]:opcode:message[hex  U8s - size 12];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);  
                printf("\nopcode - BitSwap opcode");
                printf("\nregdata - Bit Swap Req message. Max len 12. Data in hex  U8s");
            }
            break;

        case EOC_DATA_REPLY:
            printf("\nEOC_DATA_REPLY");
            printf("\nedatarep:cmdtag:bmenum[1..%d]:portnum[1..%d]:opcode:length[dec  U8]:data[hex  U8s];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);  
                printf("\nopcode - EOC opcode");
                printf("\nlength - length of data in  U8s");
                printf("\ndata - EOC data. Max len 128. Data in hex  U8s"); 
            }
            break;

        case EOC_RELAY_DATA_STREAM:
            printf("\nEOC_RELAY_DATA_STREAM");
            printf("\neredata:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS); 
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

            /* F Cmds */
        case FIFO_DISPLAY_STATUS:
            printf("\nFIFO_DISPLAY_STATUS");
            printf("\nfifods:cmdtag;");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
            }
            break;

        case FIFO_DISPLAY_ENABLE:
            printf("\nFIFO_DISPLAY_ENABLE");
            printf("\nfifode:cmdtag:enable[0..1];");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nenable - enable(1) / disable(0)");
            }
            break;

            /* G Cmds */
        case GET_COUNTERS:
            printf("\nGET_COUNTERS");
            printf("\ngetcntr:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;
            
        case GET_PM_COUNTERS:
            printf("\nGET_PM_COUNTERS");
            printf("\ngetpmcntr:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

        case PM_CONFIG_PARAMS:
            printf("\nPM_CONFIG_PARAMS");
            printf("\npmconfig:cmdtag:bmenum[1..%d];",MAX_NUM_OF_BMES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
            }
            break;

        case PM_TRIGGER_FAILURES:
            printf("\nPM_TRIGGER_FAILURES");
            printf("\npmtrigger:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

        case GET_SELFTEST_RESULTS:
            printf("\nGET_SELFTEST_RESULTS");
            printf("\ngselft:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

        case GET_HOST_ENDIAN_TYPE:
            printf("\nGET_HOST_ENDIAN_TYPE");
            printf("\ngetendtype:cmdtag;");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
            }
            break;

        case GET_PORT_PROFILE:
            printf("\nGET_PORT_PROFILE");
            printf("\ngetpprof:cmdtag:profilenum[0..%d];", MAX_PORT_PROFILES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nprofilenum - 0..%d. 0 - default port profile", MAX_PORT_PROFILES);
            }
            break;

            /* H Cmds */
            /* I Cmds */
            /* J Cmds */
            /* K Cmds */
            /* L Cmds */
        case SET_LOOPBACK:
            printf("\nSET_LOOPBACK");
            printf("\nlpbk:cmdtag:bmenum[1..%d]:portnum[1..%d]:type[1:2:..5];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                printf("\ntype - 1...5");
                printf("\n       1 HpiReleaseLoop");
                printf("\n       2 HpiNetworkNetwork");
                printf("\n       3 HpiNetworkLine");
                printf("\n       4 HpiLineNetwork");
                printf("\n       5 HpiLineLine");   
            }
            break;

            /* M Cmds */
        case MSG_TRACING_STATUS:
            printf("\nMSG_TRACING_STATUS");
            printf("\nmsgts:cmdtag;");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
            }
            break;

        case MSG_TRACING_ENABLE:
            printf("\nMSG_TRACING_ENABLE");
            printf("\nmsgts:cmdtag:enable[0..1];");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nenable - enable(1) / disable(0)");
            }
            break;

        case MSG_FILTER_VALUE:
            printf("\nMSG_FILTER_VALUE");
            printf("\nmsgfilval:cmdtag;");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
            }
            break;

        case MSG_FILTER:
            printf("\nMSG_FILTER");
            printf("\nmsgfilter:cmdtag:value[hex ulong];");
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nvalue - 0x0 - 0xffffffff");
            }
            break;

            /* N Cmds */
            /* O Cmds */
            /* P Cmds */
            /* printf ("\nPORT_BRINGUP -> portbringup"); */
            /* printf ("\nPORT_TEARDOWN -> portteardown"); */

        case PORT_PROVISION:
            printf("\nPORT_PROVISION");
            printf("\npprov:cmdtag:bmenum[1..%d]:portnum[1..%d]:profilenum[0..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS, MAX_PORT_PROFILES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                printf("\nprofilenum 0 - Default Port Profile.");
            }
            break;

        case PORT_STATUS_BRIEF: 
            printf("\nPORT_STATUS_BRIEF-Get port status");
            printf("\npstat:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

        case PORT_STATUS_EXTENDED:
            printf("\nPORT_STATUS_EXTENDED:-Get extended port status");
            printf("\npstatex:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;


        case PORT_INSTANTIATE:
            printf("\nPORT_INSTANTIATE");
            printf("\npinst:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

        case PORT_RESET:
            printf("\nPORT_RESET");
            printf("\npreset:cmdtag:bmenum[1..%d]:portnum[1..%d]:startmode[0..1];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                printf("\nstartmode - Port initiate (0) / Far-end initiate (1)");  
            }
            break;

        case PORT_START:
            printf("\nPORT_START");
            printf("\npstart:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

        case PORT_STOP:
            printf("\nPORT_STOP, keep current port provisioning");
            printf("\npstop:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;

        case PORT_DESTROY:
            printf("\nPORT_DESTROY, remove port provisioning");
            printf("\npdes:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
            }
            break;


        case PERFORMANCE_MONITORING:
            printf("\nPERFORMANCE_MONITORING");
            printf("\npermon:cmdtag:bmenum[1..%d]:portnum[1..%d]:reptype[0..3]:paramtype[0..17];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                printf("\nreptype - 0..3. Ne15min(0) / Fe15min(1) / Ne24hour(2) / Fe24hour(3)");
                printf("\nparamtype - 0..17.");
                printf("\n            CvSlow15min(0)   CvFast15min(1)   CvSlow24hour(2)    CvFast24hour(3)");
                printf("\n            FecSlow15min(4)  FecFast15min(5)  FecSlow24hour(6)   FecFast24hour(7)");
                printf("\n            HecvSlow15min(8) HecvFast15min(9) HecvSlow24hour(10) HecvFast24hour(11");
                printf("\n            ErrSec15min(12)  ErrSec24hour(13) SevErrSec15min(14) SevErrSec24hour(15)");
                printf("\n            Uasec15min(16)   Uasec24hour(17)");
            }
            break;

            /* Q Cmds */
            /* R Cmds */
            /* S Cmds */
        case SET_PORT_PROFILE_PARAMETER:
            printf("\nSET_PORT_PROFILE_PARAMETER");
            printf("\nsetpprof:cmdtag:profilenum[1..%d]:parmtype:data;",MAX_PORT_PROFILES);
            if (bDetailSyntax)
            {
                printf("\ncmdtag - optional- max size %d", MAX_TAG_LENGTH);
                printf("\nprofilenum - 1..%d", MAX_PORT_PROFILES);
                printf("\nparmtype 0..FF");
                printf ("\n		INTERLEAVED_CHANNEL 	=0x0,\
                        FAST_CHANNEL            =0x1,   LINE_TYPE       =0x2,\
                        DSL_MODE        =0x3,   RATE_ADAPTATION_MODE    =0x4,\
                        INTERLEAVED_PERCENTAGE  =0x5,   UPSTREAM_MAX_RATE_FAST  =0x6,\
                        UPSTREAM_MIN_RATE_FAST  =0x7,   UPSTREAM_MAX_RATE_SLOW  =0x8,\
                        UPSTREAM_MIN_RATE_SLOW  =0x9,   UPSTREAM_MAX_INTER_DELAY=0xa,\
                        DOWNSTREAM_MAX_RATE_FAST=0xb,   DOWNSTREAM_MIN_RATE_FAST=0xc,\
                        DOWNSTREAM_MAX_RATE_SLOW=0xd,   DOWNSTREAM_MIN_RATE_SLOW=0xe,\
                        DOWNSTREAM_MAX_INTER_DELAY=0xf, NUM_PARITY_FAST     =0x10,\
                        NUM_PARITY_SLOW     =0x11,  US_TARGET_NOISE_MARGIN    =0x12,\
                        DS_TARGET_NOISE_MARGIN =0x13,  MIN_NOISE_MARGIN    =0x14,\
                        BAND_PLAN       =0x15,  NUM_RFI_BAND        =0x16,\
                        BAND_1_START        =0x17,  BAND_1_STOP     =0x18,\
                        BAND_2_START        =0x19,  BAND_2_STOP     =0x1a,\
                        BAND_3_START        =0x1b,  BAND_3_STOP     =0x1c,\
                        BAND_4_START        =0x1d,  BAND_4_STOP     =0x1e,\
                        BAND_5_START        =0x1f,  BAND_5_STOP     =0x20 \
                        UPSTREAM_MIN_PROTECTION= 0x24,  DOWNSTREAM_MIN_PROTECTION=0x25  ");



                        }
                        break;

case SYSTEM_STATUS:
                       printf("\nSYSTEM_STATUS");
                       printf("\nsysstatus:cmdtag:bmenum[1..%d];",MAX_NUM_OF_BMES);
                       if (bDetailSyntax){
                       printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                       printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                       }
                       break;

case SEND_SIGNALS:
                       printf("\nSEND_SIGNALS");
                       printf("\nsendsig:cmdtag:bmenum[1..%d]:portnum[1..%d]:option[1..13];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
                       if (bDetailSyntax){   
                       printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                       printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                       printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                       printf("\noption - 1..13");
                       printf("\n         HpiStopTone(1)   HpiQuiet(2)      HpiPilot(3)    HpiCTone(4)");
                       printf("\n         HpiCAct2(5)      HpiCReveille(6)  HpiCReverb(7)  HpiCSegue(8)");
                       printf("\n         HpiRActReq(9)    HpiRAct1(10)     HpiRAct2(11)   HpiRReverb(12)");
                       printf("\n         HpiRSegue(13)");
                       }
                       break;

case DETECT_SIGNALS:
                       printf("\nDETECT_SIGNALS");
                       printf("\ndetectsig:cmdtag:bmenum[1..%d]:portnum[1..%d]:option[1..13];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);

                       break;

case SYSTEM_PROVISION:
                       printf("\nSYSTEM_PROVISION");
                       printf("\nsysprov:cmdtag:bmenum[1..%d]:VendorID_T1E1:VendorID_ITU:Rev#:Serial#:AtmOption:AtmCellSize:OptionMask:BandPlan:NumPort:PBOEnable;",MAX_NUM_OF_BMES);
                       if (bDetailSyntax){
                       printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                       printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                       }
                       break;

case SET_HOST_ENDIAN_TYPE:
                       printf("\nSET_HOST_ENDIAN_TYPE");
                       printf("\nsetendtype:cmdtag:endiantype[1..2];");
                       if (bDetailSyntax){
                       printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                       printf("\nendiantype - 1 LittleEndianType");
                       printf("\n			   2 BigEndianType");
                       }
                       break;

                       /* T Cmds */case THRESHOLD_REPORTS:
                       printf("\nTHRESHOLD_REPORTS");
                       printf("\nthresrep:cmdtag:bmenum[1..%d]:portnum[1..%d]:reptype[0..3];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
                       if (bDetailSyntax){
                       printf("\ncmdtag - optional - max size %d", MAX_TAG_LENGTH);
                       printf("\nbmenum - 1..%d", MAX_NUM_OF_BMES);
                       printf("\nportnum - 1..%d", MAX_NUM_OF_PORTS);
                       printf("\nreptype - 0..3. Ne15min(0) / Fe15min(1) / Ne24hour(2) / Fe24hour(3)");
                       }
                       break;


#ifdef	USE_RFM
case    RFM_LOAD_IMAGE:
                       printf("\nLoad Image from TFTP server");
                       printf("\nldimage:cmdtag:filename:host_ip_address;");
                       if (bDetailSyntax){
                       printf("\nLoad Image from TFTP server");
                       printf("\nldimage:cmdtag:filename:host_ip_address;");
                       }
                       break;

case    RFM_DOWNLOAD_CPE:           
                       printf("\nDownload CPE");
                       printf("\ndnldcpe:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
                       if (bDetailSyntax){
                       printf("\nTHRESHOLD_REPORTS");
                       printf("\nthresrep:cmdtag:bmenum[1..%d]:portnum[1..%d];",MAX_NUM_OF_BMES, MAX_NUM_OF_PORTS);
                       }
                       break;




#endif

                       /* U Cmds */
                       /* V Cmds */
                       /* W Cmds */
                       /* X Cmds */
                       /* Y Cmds */
                       /* Z Cmds */default:
                       break;



                       }

                       return;
#endif
                       }


                       void sendTlCmdResponse (eCommands Cmd, eApiRv CmdStatus,int BmeNum,int PortNum){

#if 0
                       /* Update command status */
                       Bme[BmeNum].Port[PortNum].CmdStatus=CmdStatus;

//  if ((Cmd != 0xc3) && (Cmd != 0x80) && (Cmd != 0xc2) && (Cmd != 0x0e))
                       if ((Cmd != 0xc3) && (Cmd != 0x80) && (Cmd != 0xc2)){
                       switch(CmdStatus){case FAIL:
                       printf("\nb%dp%d cmd %x cmdTag %x status: FAIL", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case TxCmdFAIL:
                       printf("\nb%dp%d cmd %x cmdTag %x status: TxCmdFAIL", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case PARMS_UNDEFINED:
                       printf("\nb%dp%d cmd %x cmdTag %x status: PARMS_UNDEFINED", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case TxCmdTIMEOUT:
                       //printf("\nb%dp%d cmd %x cmdTag %x status: TxCmdTIMEOUT", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case COMPLETE:
                       printf("\nb%dp%d cmd %x cmdTag %x status: COMPLETE", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case CMD_TIMER_EXPIRE:
                       printf("\nb%dp%d cmd %x cmdTag %x status: CMD_TIMER_EXPIRE", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case AUTONOMOUS:
                       printf("\nb%dp%d cmd %x cmdTag %x status: AUTONOMOUS", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case IN_PROGRESS:
                       printf("\nb%dp%d cmd %x cmdTag %x status: IN_PROGRESS", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_BUSY:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_BUSY", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_DEACTIVATED:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_DEACTIVATED", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_ERROR:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_ERROR", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_NOT_IMPLEMENTED:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_NOT_IMPLEMENTED", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_TIMEOUT:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_TIMEOUT", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_INVALID_DEST:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_INVALID_DEST", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_INVALID_OPCODE:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_INVALID_OPCODE", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_INVALID_LENGTH:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_INVALID_LENGTH", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_INVALID_DATA:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_INVALID_DATA", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_INVALID_STATE:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_INVALID_STATE", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_DB_ERROR:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_DB_ERROR", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

case NACK_ACTIVATE_FAIL:
                       printf("\nb%dp%d cmd %x cmdTag %x status: NACK_ACTIVATE_FAIL", BmeNum, PortNum, Cmd, bCmdTag[PortNum]);
                       break;

default:
                       break;
                       }
#ifdef VTU_O
                       printf ("\nco> ");
#else
                       printf ("\ncpe> ");
#endif


                       }
#endif
                       return;
                       }

/* END_OF_FILE */
