/**
* @file PFM_Cfg.c
* @brief Platform Function Module:配置文件管理
* @details
* 读取平台配置信息
* @author GT-BU
* @date 2021.02.20
* @version V1.0
* @copyright TCT
* @par 修改日志
* <table>
* <tr><th>Date        <th>Version  <th>Author     <th>Description
* <tr><td>2021.02.01  <td>V1.0     <td>GT-BU      <td>创建初始版本
* </table>
*/
#include "PFM_Cfg.h"
#include "CM_Memory.h"
#include "CM_IniFile.h"
#include "CM_Socket.h"  /* inet_addr */
#include "CM_MD5.h"  /* inet_addr */
#include "PFM_Log.h"
#include "PFM_CPUUsage.h"
#include "MSCP_APP_Interface.h"
#include "DFM_DRV.h"
#include "PFM_RemoteUpdate.h"
#include "CM_Time.h"
#include "CFM_Net.h"
#ifdef WIN32
#include "conio.h" /* _getch() */
#endif



/** 平台配置ini */
#define MAIN_BASE_INI "main_base.ini"
#define MAIN_ID_INI   "main_id.ini"
#define MAIN_MD5_INI  "main_md5.ini"

/** 配置文件路径 */
CM_CHAR FS_FILE_PATH[100];

/** 平台软件版本号 */
const CM_UINT8 MSCP_SW_VERION[4] = { 93u, 18u, 0u, 2u };
/** 驱动软件版本号 */
CM_UINT8 MSCP_DRV_VERION[4] = {0};
/** 与维护一体机接口文档版本号(接口文档发生改变时升级版本号) */
CM_UINT16 TSCP_DOC_VERION[2] = {34u,11u};
/** 操作系统版本号 */
CM_UINT8 TSCP_QNX_VERION[10] = {0u};



/** 平台配置数据 */
STRU_PFM_CFG_T g_PFM_Cfg;

/** 维护模式远程部署功能配置数据 */
STRU_RMUP_CFG_T g_RMUP_Cfg;

/** 需应用注册的版本号 */
STRU_APP_VERSON g_App_Verson;
/*应用基本参数配置结构体*/
static STRU_APP_CFG_T g_AppCfgInterface;
static void s_str2md5(IN const CM_CHAR* str, OUT CM_UINT8 md5[16]);
static void PFM_CFG_Check_BoardID(void);
void PFM_CFG_MAINID_Init(void)
{
    g_PFM_Cfg.CPU_ID = (CM_UINT8)CM_GetProfileInt(MAIN_ID_INI,"ID","CPU_ID");
    CM_NM_ASSERT(0u != g_PFM_Cfg.CPU_ID, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_1);
    g_PFM_Cfg.BOARD_ID = (CM_UINT8)CM_GetProfileInt(MAIN_ID_INI, "ID", "BOARD_ID");
    CM_NM_ASSERT(0u != g_PFM_Cfg.BOARD_ID, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_2);
    PFM_CFG_Check_BoardID();
    g_PFM_Cfg.OUTNET_ID = (CM_UINT16)CM_GetProfileHex(MAIN_ID_INI, "ID", "OUTNET_ID");
    CM_NM_ASSERT(0u != g_PFM_Cfg.OUTNET_ID,CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_3);
    g_PFM_Cfg.INNET_ID = (CM_UINT16)CM_GetProfileHex(MAIN_ID_INI, "ID", "INNET_ID");
    CM_NM_ASSERT(0u != g_PFM_Cfg.INNET_ID,CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_2, TSCP_DARK_ASSERT_4);
    g_PFM_Cfg.INNET_ID_RM = (CM_UINT16)CM_GetProfileHex(MAIN_ID_INI, "ID", "INNET_ID_RM");
    MSCP_LOG_MSG("Remote Update INNET_ID_RM = 0x%.2x",g_PFM_Cfg.INNET_ID_RM);
    (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_INIT1, 5, \
    					sizeof(CM_UINT8),g_PFM_Cfg.CPU_ID,
    					sizeof(CM_UINT8),g_PFM_Cfg.BOARD_ID,
						sizeof(CM_UINT16),g_PFM_Cfg.OUTNET_ID,
    					sizeof(CM_UINT16),g_PFM_Cfg.INNET_ID,
						sizeof(CM_UINT16),g_PFM_Cfg.INNET_ID_RM);
}
/**
* @brief 平台配置文件初始化
*/
void PFM_CFG_Init(void)
{
    /*- 变量初始化 */
    CM_INT32 cpuID = 0;  /* CPU ID*/
    CM_INT32 i = 0;      /* 循环变量 */
    ENUM_CM_RETURN rt = 0;     /* 函数返回值 */
	CM_UINT64 tickstart = 0; /* 上电时间计时 */
	CM_CHAR buf[100];    /* 临时缓冲区 */
    /*- 保存软件版本信息 */
    MSCP_LOG_MSG("MSCP start version:%d.%d.%d.%d  %s  %s\n", 
        MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3], __DATE__, __TIME__);
    (void)printf("MSCP start version:%d.%d.%d.%d \n",
            MSCP_SW_VERION[0], MSCP_SW_VERION[1], MSCP_SW_VERION[2], MSCP_SW_VERION[3]);
    /*- 读取ID信息 */

    (void)strcpy(FS_FILE_PATH,g_AppCfgInterface.FS_NAME);
    (void)strcpy(g_PFM_Cfg.APP_NAME,g_AppCfgInterface.APP_NAME);
    MSCP_LOG_MSG("FS_NAME:%s\n",FS_FILE_PATH);
    MSCP_LOG_MSG("APP_NAME:%s\n",g_PFM_Cfg.APP_NAME);

    rt = CM_GetProfileString(MAIN_MD5_INI, "MD5_CONFIG", g_PFM_Cfg.APP_NAME, buf);
    CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_5);

    rt = CM_MD5_Calc((CM_UINT8*)&g_AppCfgInterface,sizeof(STRU_APP_CFG_T),g_PFM_Cfg.CFG_MD5);
    CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_6);

    s_str2md5(buf, g_PFM_Cfg.APP_MD5);
    MSCP_LOG_MSG("BOARD_ID  = %d\nCPU_ID    = %d\nINNET_ID  = %04X\nOUTNET_ID = %04X\nINNET_ID_RM\n",
        g_PFM_Cfg.BOARD_ID, g_PFM_Cfg.CPU_ID, g_PFM_Cfg.INNET_ID, g_PFM_Cfg.OUTNET_ID, g_PFM_Cfg.INNET_ID_RM);

    /*- 读取平台功能配置 */
    g_PFM_Cfg.CYC_TIME = g_AppCfgInterface.CYC_TIME;
    g_PFM_Cfg.OutnetSafePack_Len = (TSCP_CYC_DATAMAX_LEN * g_PFM_Cfg.CYC_TIME)/100u;

    g_PFM_Cfg.app_num = g_AppCfgInterface.app_num;
    g_PFM_Cfg.CC_VER = 0u;
    g_PFM_Cfg.M_2oo2_Enable = g_AppCfgInterface.M_2oo2_Enable;
    g_PFM_Cfg.M_2x2_Enable = g_AppCfgInterface.M_2x2_Enable;
    g_PFM_Cfg.M_InnetSafe_Enable = g_AppCfgInterface.M_InnetSafe_Enable;
    g_PFM_Cfg.M_InnetRaw_Enable = g_AppCfgInterface.M_InnetRaw_Enable;
    g_PFM_Cfg.M_OutnetSafe_Enable = g_AppCfgInterface.M_OutnetSafe_Enable;
	g_PFM_Cfg.M_OutnetRaw_Enable = g_AppCfgInterface.M_OutnetRaw_Enable;
	g_PFM_Cfg.M_CpuUsageGet_Enable = g_AppCfgInterface.M_CpuUsageGet_Enable;
	g_PFM_Cfg.M_RemoteUpdate_Enable = g_AppCfgInterface.M_RemoteUpdate_Enable;
	(void)strcpy(g_PFM_Cfg.Start_Path,g_AppCfgInterface.Start_Path);
	g_PFM_Cfg.reboot_replycount = g_AppCfgInterface.reboot_replycount;
	g_PFM_Cfg.M_AutoReboot_Count = g_AppCfgInterface.M_AutoReboot_Count;
	g_PFM_Cfg.M_AutoClear_Days = g_AppCfgInterface.M_AutoClear_Days;
	MSCP_LOG_MSG("CYC_TIME:%d\n",g_PFM_Cfg.CYC_TIME);
	MSCP_LOG_MSG("app_num:%d\n",g_PFM_Cfg.app_num);
	MSCP_LOG_MSG("CC_VER:%d\n",g_PFM_Cfg.CC_VER);
	MSCP_LOG_MSG("M_2oo2_Enable:0x%x\n",g_PFM_Cfg.M_2oo2_Enable);
	MSCP_LOG_MSG("M_2x2_Enable:0x%x\n",g_PFM_Cfg.M_2x2_Enable);
	MSCP_LOG_MSG("M_InnetSafe_Enable:0x%x\n",g_PFM_Cfg.M_InnetSafe_Enable);
	MSCP_LOG_MSG("M_InnetRaw_Enable:0x%x\n",g_PFM_Cfg.M_InnetRaw_Enable);
	MSCP_LOG_MSG("M_OutnetSafe_Enable:0x%x\n",g_PFM_Cfg.M_OutnetSafe_Enable);
	MSCP_LOG_MSG("M_OutnetRaw_Enable:0x%x\n",g_PFM_Cfg.M_OutnetRaw_Enable);
	MSCP_LOG_MSG("M_CpuUsageGet_Enable:0x%x\n",g_PFM_Cfg.M_CpuUsageGet_Enable);
	MSCP_LOG_MSG("M_RemoteUpdate_Enable:0x%x\n",g_PFM_Cfg.M_RemoteUpdate_Enable);
	MSCP_LOG_MSG("Start_Path:%s\n",g_PFM_Cfg.Start_Path);
	MSCP_LOG_MSG("reboot_replycount:%d\n",g_PFM_Cfg.reboot_replycount);
	MSCP_LOG_MSG("M_AutoReboot_Count:%d\n",g_PFM_Cfg.M_AutoReboot_Count);
	MSCP_LOG_MSG("M_AutoClear_Days:%d\n",g_PFM_Cfg.M_AutoClear_Days);
	PFM_CFG_SendDarkCfg();
	if (0u != g_PFM_Cfg.M_AutoClear_Days)
	{
		tickstart = CM_GetSecTick(); /* 上电时间计时/秒 */
		MSCP_LOG_MSG("tickstart = %lld\n",tickstart);
		g_PFM_Cfg.M_AutoClear_Second = tickstart + g_PFM_Cfg.M_AutoClear_Days*24u*60u*60u; /* 擦除历史宕机文件阈值单位秒 */
		MSCP_LOG_MSG("g_PFM_Cfg.M_Clear_Second = %llu\n",g_PFM_Cfg.M_AutoClear_Second);
	}
	else
	{
		
	}
    /*- @alias 读取2x2oo2平台各CPU的通信配置 */
    for (cpuID = 1; cpuID <= 4; cpuID++)
    {
    	(void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_2oo2,g_AppCfgInterface.CPU[cpuID-1].IP_2oo2);
        g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data         = 51001;
		g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data_App     = 51005;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_2x2_State    = 51006;

        g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Time         = 51002;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Maintenance  = 51004;

        (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_2x2,g_AppCfgInterface.CPU[cpuID-1].IP_2x2);
        g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Data          = 52001;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Time          = 52002;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Syn           = 52003;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_State         = 52004;

        (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Maintain,	g_AppCfgInterface.CPU[cpuID-1].IP_Maintain);
        (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Com,			g_AppCfgInterface.CPU[cpuID-1].IP_Com);
        (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Out,			g_AppCfgInterface.CPU[cpuID-1].IP_Out);
        (void)strcpy(g_PFM_Cfg.CPU_CFG[cpuID].IP_Com_Extend,	g_AppCfgInterface.CPU[cpuID-1].IP_Com_Extend);

        /*读取内网透传参数*/
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num = g_AppCfgInterface.Port_Innet_Raw_Num;
        CM_NM_ASSERT(g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num <= 9, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_7);
        /*读取内网透传扩展参数*/
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num = g_AppCfgInterface.Port_Innet_Raw_Extend_Num;
        CM_NM_ASSERT(g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num <= 9, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_8);
        MSCP_LOG_MSG("Port_Innet_Raw_Num:%d,%d\n",g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num,g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num);
        for(i = 1u;i <= (g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num +
        		g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num);
        		i++)
        {
			(void)CM_Memcpy(&g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i],sizeof(STRU_PFM_INNET_RAW_T),
					&g_AppCfgInterface.Innet_Raw_Parameter[i-1],sizeof(STRU_PFM_INNET_RAW_T));
			MSCP_LOG_MSG("[%d]Port_Type_Enable:%d\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].Port_Type_Enable);
			MSCP_LOG_MSG("[%d]Port_Innet_Raw:%d\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].Port_Innet_Raw);
			MSCP_LOG_MSG("[%d]Server_DevId:%d\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].Server_DevId);
			MSCP_LOG_MSG("[%d]IP_InnetRaw_maddr:%s\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].IP_InnetRaw_maddr);
			MSCP_LOG_MSG("[%d]TIME_STAMP_ENABLE:0x%x\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].TIME_STAMP_ENABLE);
			MSCP_LOG_MSG("[%d]INNET_2oo2_RAW:0x%x\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].INNET_2oo2_RAW);
			MSCP_LOG_MSG("[%d]INNET_2x2_RAW:0x%x\n",i,g_PFM_Cfg.CPU_CFG[cpuID].Innet_Raw_Parameter[i].INNET_2x2_RAW);
        }
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Safe = g_AppCfgInterface.Port_Innet_Safe;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Safe = g_AppCfgInterface.Port_Outnet_Safe;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Raw = g_AppCfgInterface.Port_Outnet_Raw;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Heart = 53003;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Base = g_AppCfgInterface.CPU[cpuID-1].Logger_PortBase;
        g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Ciphertext = g_AppCfgInterface.CPU[cpuID-1].Logger_PortCiphertext;
		g_PFM_Cfg.CPU_CFG[cpuID].Port_Remote_Update = g_AppCfgInterface.Port_Remote_Update;
		MSCP_LOG_MSG("CPU[%d]IP_2oo2:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_2oo2);
		MSCP_LOG_MSG("CPU[%d]IP_2x2:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_2x2);
		MSCP_LOG_MSG("CPU[%d]IP_Maintain:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Maintain);
		MSCP_LOG_MSG("CPU[%d]IP_Com:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Com);
		MSCP_LOG_MSG("CPU[%d]IP_Out:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Out);
		MSCP_LOG_MSG("CPU[%d]IP_Com_Extend:%s\n",cpuID,g_PFM_Cfg.CPU_CFG[cpuID].IP_Com_Extend);

	    (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, (TSCP_DARK_PFMCFG_INIT2 + cpuID - 1), 18, \
	    					sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data,
	    					sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Data_App,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_2x2_State,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Time,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2oo2_Maintenance,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Data,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Time,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_Syn,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_2x2_State,
							sizeof(CM_INT32),g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Num,
							sizeof(CM_INT32),g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Raw_Extend_Num,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Innet_Safe,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Safe,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Raw,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Outnet_Heart,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Base,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Log_Ciphertext,
							sizeof(CM_UINT16),g_PFM_Cfg.CPU_CFG[cpuID].Port_Remote_Update);
    }

    /*- 确定本机通信配置 */
    cpuID = (CM_INT32)CM_UNSIGNED_INT_EXP((((CM_UINT32)g_PFM_Cfg.BOARD_ID - 1u) * 2u) + (CM_UINT32)g_PFM_Cfg.CPU_ID);
    rt = CM_Memcpy(&g_PFM_Cfg.Local_Cfg, sizeof(STRU_PFM_CPU_CFG_T), &g_PFM_Cfg.CPU_CFG[cpuID], sizeof(STRU_PFM_CPU_CFG_T));
    CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_9);

    /*- 确定2oo2邻机通信配置 */
    cpuID = (CM_INT32)CM_UNSIGNED_INT_EXP((((CM_UINT32)g_PFM_Cfg.BOARD_ID - 1u) * 2u) + (3u - (CM_UINT32)g_PFM_Cfg.CPU_ID));
    rt = CM_Memcpy(&g_PFM_Cfg.Peer_Cfg, sizeof(STRU_PFM_CPU_CFG_T), &g_PFM_Cfg.CPU_CFG[cpuID], sizeof(STRU_PFM_CPU_CFG_T));
    CM_NM_ASSERT(ENUM_CM_TRUE == rt,CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_10);

    /*- 确定2x2对机（对系）通信配置 */
    cpuID = (CM_INT32)CM_UNSIGNED_INT_EXP(((2u - (CM_UINT32)g_PFM_Cfg.BOARD_ID) * 2u) + (CM_UINT32)g_PFM_Cfg.CPU_ID);
    rt = CM_Memcpy(&g_PFM_Cfg.Partner_Cfg, sizeof(STRU_PFM_CPU_CFG_T), &g_PFM_Cfg.CPU_CFG[cpuID], sizeof(STRU_PFM_CPU_CFG_T));
    CM_NM_ASSERT(ENUM_CM_TRUE == rt, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_11);

    /*- @alias 读取通控(CC)的IP配置 */
    if (1u == g_PFM_Cfg.CPU_ID)
    {
    	(void)strcpy(g_PFM_Cfg.CC_R_IP,g_AppCfgInterface.OutNetRed.CC_G_IP);
    	(void)strcpy(g_PFM_Cfg.CC_B_IP,g_AppCfgInterface.OutNetBlue.CC_G_IP);
    	(void)strcpy(g_PFM_Cfg.EXTEND_R_IP,g_AppCfgInterface.OutNetRed.EXTEND_G_IP);
    	(void)strcpy(g_PFM_Cfg.EXTEND_B_IP,g_AppCfgInterface.OutNetBlue.EXTEND_G_IP);
    }
    else
    {
    	(void)strcpy(g_PFM_Cfg.CC_R_IP,g_AppCfgInterface.OutNetRed.CC_P_IP);
    	(void)strcpy(g_PFM_Cfg.CC_B_IP,g_AppCfgInterface.OutNetBlue.CC_P_IP);
    	(void)strcpy(g_PFM_Cfg.EXTEND_R_IP,g_AppCfgInterface.OutNetRed.EXTEND_P_IP);
    	(void)strcpy(g_PFM_Cfg.EXTEND_B_IP,g_AppCfgInterface.OutNetBlue.EXTEND_P_IP);
    }    
    /*- 读取通控的端口配置 */
    g_PFM_Cfg.CC_R_OutnetSafe_Port = g_AppCfgInterface.OutNetRed.OutnetSafe_Port;
	g_PFM_Cfg.CC_R_OutnetRaw_Port = g_AppCfgInterface.OutNetRed.OutnetRaw_Port;
    g_PFM_Cfg.CC_R_InnetRaw_Port = g_AppCfgInterface.OutNetRed.InnetRaw_Port;
    g_PFM_Cfg.CC_R_Heart_Port = 53003;

    g_PFM_Cfg.CC_B_OutnetSafe_Port = g_AppCfgInterface.OutNetBlue.OutnetSafe_Port;
	g_PFM_Cfg.CC_B_OutnetRaw_Port = g_AppCfgInterface.OutNetBlue.OutnetRaw_Port;
    g_PFM_Cfg.CC_B_InnetRaw_Port = g_AppCfgInterface.OutNetBlue.InnetRaw_Port;
    g_PFM_Cfg.CC_B_Heart_Port = 53003;
    MSCP_LOG_MSG("CC_R_IP:%s\n",g_PFM_Cfg.CC_R_IP);
    MSCP_LOG_MSG("CC_B_IP:%s\n",g_PFM_Cfg.CC_B_IP);
    MSCP_LOG_MSG("EXTEND_R_IP:%s\n",g_PFM_Cfg.EXTEND_R_IP);
    MSCP_LOG_MSG("EXTEND_B_IP:%s\n",g_PFM_Cfg.EXTEND_B_IP);
    MSCP_LOG_MSG("CC_R_OutnetSafe_Port:%d\n",g_PFM_Cfg.CC_R_OutnetSafe_Port);
    MSCP_LOG_MSG("CC_R_OutnetRaw_Port:%d\n",g_PFM_Cfg.CC_R_OutnetRaw_Port);
    MSCP_LOG_MSG("CC_R_InnetRaw_Port:%d\n",g_PFM_Cfg.CC_R_InnetRaw_Port);
    MSCP_LOG_MSG("CC_B_OutnetSafe_Port:%d\n",g_PFM_Cfg.CC_B_OutnetSafe_Port);
    MSCP_LOG_MSG("CC_B_OutnetRaw_Port:%d\n",g_PFM_Cfg.CC_B_OutnetRaw_Port);
    MSCP_LOG_MSG("CC_B_InnetRaw_Port:%d\n",g_PFM_Cfg.CC_B_InnetRaw_Port);

    (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_INIT3, 8, \
    					sizeof(CM_UINT16),g_PFM_Cfg.CC_R_OutnetSafe_Port,
    					sizeof(CM_UINT16),g_PFM_Cfg.CC_R_OutnetRaw_Port,
						sizeof(CM_UINT16),g_PFM_Cfg.CC_R_InnetRaw_Port,
    					sizeof(CM_UINT16),g_PFM_Cfg.CC_R_Heart_Port,
						sizeof(CM_UINT16),g_PFM_Cfg.CC_B_OutnetSafe_Port,
						sizeof(CM_UINT16),g_PFM_Cfg.CC_B_OutnetRaw_Port,
						sizeof(CM_UINT16),g_PFM_Cfg.CC_B_InnetRaw_Port,
						sizeof(CM_UINT16),g_PFM_Cfg.CC_B_Heart_Port);

    /*- @alias 读取日志记录的IP配置 */
	if ((CM_UINT8)1u == g_PFM_Cfg.CPU_ID)
	{
		(void)strcpy(g_PFM_Cfg.Logger_IP,g_AppCfgInterface.Logger_G_IP);
	}
	else
	{
		(void)strcpy(g_PFM_Cfg.Logger_IP,g_AppCfgInterface.Logger_P_IP);
	}
	MSCP_LOG_MSG("Logger_IP:%s\n",g_PFM_Cfg.Logger_IP);
    /*读取内网通信设备的通信配置*/
    /*- 读取内通信设备数量 */
    g_PFM_Cfg.INNET_COM_NUM = g_AppCfgInterface.INNET_COM_NUM;
    MSCP_LOG_MSG("INNET_COM_NUM:%d\n",g_PFM_Cfg.INNET_COM_NUM);
    CM_NM_ASSERT(g_PFM_Cfg.INNET_COM_NUM <= 255, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_1, TSCP_DARK_ASSERT_12);

    (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_INIT4, 3, \
    					sizeof(CM_UINT16),g_PFM_Cfg.Logger_PortBase,
    					sizeof(CM_UINT16),g_PFM_Cfg.Logger_PortCiphertext,
						sizeof(CM_UINT16),g_PFM_Cfg.INNET_COM_NUM);

    /*- @alias 读取所有内网透传设备通信配置 */
    for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++)
    {
    	(void)CM_Memcpy(&g_PFM_Cfg.INNET_COM_CFG[i],sizeof(STRU_PFM_INNET_CFG_T),&g_AppCfgInterface.INNET_COM_CFG[i-1],sizeof(STRU_PFM_INNET_CFG_T));
    	MSCP_LOG_MSG("[%d]InnetID:0x%x\n",i,g_PFM_Cfg.INNET_COM_CFG[i].InnetID);
    	MSCP_LOG_MSG("[%d]IP_G:%d.%d.%d.%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].IP_G&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_G>>8)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_G>>16)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_G>>24)&0xFF);
    	MSCP_LOG_MSG("[%d]Port_Raw_G:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_G);
    	MSCP_LOG_MSG("[%d]Port_Safe_G:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_G);
    	MSCP_LOG_MSG("[%d]IP_P:%d.%d.%d.%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].IP_P&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_P>>8)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_P>>16)&0xFF,(g_PFM_Cfg.INNET_COM_CFG[i].IP_P>>24)&0xFF);
    	MSCP_LOG_MSG("[%d]Port_Raw_P:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_P);
    	MSCP_LOG_MSG("[%d]Port_Safe_P:%d\n",i,g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_P);
    }
    /*设置维护终端ID*/
    PFM_SetMaintenanceId(g_AppCfgInterface.ID_Maintenance);

    /*CPU使用率获取初始化*/
    PFM_CpuUsage_Init();
	/*大小端转换*/
	TSCP_DOC_VERION[0] = CM_ShortFromChar(&TSCP_DOC_VERION[0]);
	TSCP_DOC_VERION[1] = CM_ShortFromChar(&TSCP_DOC_VERION[1]);

	(void)DFM_GetQNX_Verion(TSCP_QNX_VERION);
	MSCP_LOG_MSG("TSCP_QNX_VERION : %d.%d.%d.%d\n",TSCP_QNX_VERION[0],TSCP_QNX_VERION[1],TSCP_QNX_VERION[2],TSCP_QNX_VERION[3]);
	(void)printf("TSCP_QNX_VERION : %d.%d.%d.%d\n",TSCP_QNX_VERION[0],TSCP_QNX_VERION[1],TSCP_QNX_VERION[2],TSCP_QNX_VERION[3]);
}
/**
* @brief 字符串转MD5码
* @param str 字符串
* @param md5 字符串对应的md5码
*/
static void s_str2md5(IN const CM_CHAR* str, OUT CM_UINT8 md5[16])
{
    /*- 变量初始化 */
    CM_UINT32 len = strlen(str);
    CM_UINT32 i = 0u;
    CM_UINT32 val = 0u;
    CM_UINT32 offset = 0u;
    /*- 入参检查 */
    CM_NM_ASSERT((CM_UINT32)((31u == len) || (32u == len)) && ((NULL != str) && (NULL != md5)), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_1);
    /*- MD5码长度是否为31字节（最高位是0）*/
    if (31u == len)
    {
        /*- 读取第1字节 */
    	(void)sscanf(str, "%1x", &val);
        offset = 1u;
    }
    /*- MD5码长度是否为32字节（最高位不是0）*/
    else if (32u == len)
    {
        /*- 读取前2字节 */
    	(void)sscanf(str, "%2x", &val);
        offset = 2u;
    }
    else
    {
        /*- 无效输入 */
        CM_NM_ASSERT(0u, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_3, TSCP_DARK_ASSERT_2);
    }

    /*- 给MD5码第1位赋值 */
    md5[0u] = (CM_UINT8)val;
    /*- @alias 循环读取后15位MD5码 */
    for (i = 0u; i < 15u; i++)
    {
    	(void)sscanf(str + (offset + (i * 2u)), "%2x", &val);
        md5[1u + i] = (CM_UINT8)val;
    }
}

/**
* @brief 获取板卡ID
* @return 板卡ID
* @details 
* 板卡ID根据板卡所在槽位确定
*/
CM_UINT8 PFM_CFG_GetBoardID(void)
{
    /*- 返回板卡ID */
    return g_PFM_Cfg.BOARD_ID;
}

/**
* @brief 获取CPUID
* @return CPUID
* @details
* CPUID根据配置文件确定
*/
CM_UINT8 PFM_CFG_GetCpuID(void)
{
    /*- 返回CPUID */
    return g_PFM_Cfg.CPU_ID;
}

/**
* @brief 获取外网ID
* @return 外网ID
* @details 
* 设备ID在配置文件中配置
*/
CM_UINT16 PFM_CFG_GetOutnetID(void)
{
    /*- 返回设备ID */
    return g_PFM_Cfg.OUTNET_ID;
}

/**
* @brief 获取外网ID
* @return 外网ID
* @details
* 设备ID在配置文件中配置
*/
CM_UINT16 PFM_CFG_GetInnetID(void)
{
    /*- 返回设备ID */
    return g_PFM_Cfg.INNET_ID;
}


/**
* @brief 根据内网ID获取设备通信信息
* @param InnetID 内网ID
* @return 查找结果
* - 非NULL 指向设备通信信息的指针
* - NULL 查找失败
*/
STRU_PFM_INNET_CFG_T *PFM_INI_InnetID2Addr(IN CM_UINT16 InnetID)
{
    /*- 变量初始化 */
    STRU_PFM_INNET_CFG_T *pCom = NULL;
    CM_INT32 i = 0;
    /*- 开始遍历内网通信配置:是否遍历完成:下一条配置 */
    for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++)
    {
        /*- 是否找到了目标内网ID */
        if (InnetID == g_PFM_Cfg.INNET_COM_CFG[i].InnetID)
        {
            /*- 输出通信配置信息 */
            pCom = &g_PFM_Cfg.INNET_COM_CFG[i];
            /*- 返回 */
            break;
        }
        else
        {
            /*- 无处理 */
        }
    }
    /*- 返回查找结果 */
    return pCom;
}

/**
* @brief 根据内网IP端口查找设备通信配置
* @param InnetIP 内网IP
* @param InnetPort 内网端口
* @return 查找结果
* - 非NULL 指向设备通信信息的指针
* - NULL 查找失败
*/
STRU_PFM_INNET_CFG_T *PFM_INI_InnetIP2Addr(IN CM_UINT32 InnetIP,IN CM_UINT16 InnetPort)
{
    /*- 变量初始化 */
    STRU_PFM_INNET_CFG_T *pCom = NULL;
    CM_INT32 i = 0;
    /*- 本机是否是CPU1 */
    if ((CM_UINT8)1u == g_PFM_Cfg.CPU_ID)
    {
        /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */
        for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++)
        {
            /*- 是否找到了一致的绿网地址 */
            if (( InnetIP == g_PFM_Cfg.INNET_COM_CFG[i].IP_G) 
                && ((CM_UINT16_MAX == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_G) 
                    ||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_G)||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_G)))
            {
                /*- 输出通信配置 */
                pCom = &g_PFM_Cfg.INNET_COM_CFG[i];
                /*- 返回 */
                break;
            }
            else
            {
                /*- 无处理 */
            }
        }
    }
    else
    {
        /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */
        for (i = 1; i <= (CM_INT32)g_PFM_Cfg.INNET_COM_NUM; i++)
        {
            /*- 是否找到了一致的紫网地址 */
            if ((InnetIP == g_PFM_Cfg.INNET_COM_CFG[i].IP_P) 
                && ((CM_UINT16_MAX == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_P)
                    ||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Raw_P)||(InnetPort == g_PFM_Cfg.INNET_COM_CFG[i].Port_Safe_P)))
            {
                /*- 输出通信配置 */
                pCom = &g_PFM_Cfg.INNET_COM_CFG[i];
                /*- 返回 */
                break;
            }
            else
            {
                /*- 无处理 */
            }
        }
    }
    /*- 返回通信配置 */
    return pCom;
}

/**
* @brief 根据内网ID获取设备通信信息(维护模式下使用)
* @param InnetID 内网ID
* @return 查找结果
* - 非NULL 指向设备通信信息的指针
* - NULL 查找失败
*/
STRU_PFM_INNET_CFG_T *PFM_INI_RmInnetID2Addr(IN CM_UINT16 InnetID)
{
    /*- 变量初始化 */
    STRU_PFM_INNET_CFG_T *pCom = NULL;
    CM_INT32 i = 0;
    /*- 开始遍历内网通信配置:是否遍历完成:下一条配置 */
    for (i = 1; i <= (CM_INT32)g_RMUP_Cfg.INNET_COM_NUM; i++)
    {
        /*- 是否找到了目标内网ID */
        if (InnetID == g_RMUP_Cfg.INNET_COM_CFG[i].InnetID)
        {
            /*- 输出通信配置信息 */
            pCom = &g_RMUP_Cfg.INNET_COM_CFG[i];
            /*- 返回 */
            break;
        }
        else
        {
            /*- 无处理 */
        }
    }
    /*- 返回查找结果 */
    return pCom;
}

/**
* @brief 根据内网IP端口查找设备通信配置(维护模式下使用)
* @param InnetIP 内网IP
* @param InnetPort 内网端口
* @return 查找结果
* - 非NULL 指向设备通信信息的指针
* - NULL 查找失败
*/
STRU_PFM_INNET_CFG_T *PFM_INI_RmInnetIP2Addr(IN CM_UINT32 InnetIP,IN CM_UINT16 InnetPort)
{
    /*- 变量初始化 */
    STRU_PFM_INNET_CFG_T *pCom = NULL;
    CM_INT32 i = 0;
    /*- 本机是否是CPU1 */
    if ((CM_UINT8)1u == g_RMUP_Cfg.CPU_ID)
    {
        /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */
        for (i = 1; i <= (CM_INT32)g_RMUP_Cfg.INNET_COM_NUM; i++)
        {
            /*- 是否找到了一致的绿网地址 */
            if (( InnetIP == g_RMUP_Cfg.INNET_COM_CFG[i].IP_G) 
                && ((CM_UINT16_MAX == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_G) 
                    ||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_G)||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Safe_G)))
            {
                /*- 输出通信配置 */
                pCom = &g_RMUP_Cfg.INNET_COM_CFG[i];
                /*- 返回 */
                break;
            }
            else
            {
                /*- 无处理 */
            }
        }
    }
    else
    {
        /*- 开始遍历通信配置:通信配置是否遍历完成:继续遍历通信配置 */
        for (i = 1; i <= (CM_INT32)g_RMUP_Cfg.INNET_COM_NUM; i++)
        {
            /*- 是否找到了一致的紫网地址 */
            if ((InnetIP == g_RMUP_Cfg.INNET_COM_CFG[i].IP_P) 
                && ((CM_UINT16_MAX == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_P)
                    ||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Raw_P)||(InnetPort == g_RMUP_Cfg.INNET_COM_CFG[i].Port_Safe_P)))
            {
                /*- 输出通信配置 */
                pCom = &g_RMUP_Cfg.INNET_COM_CFG[i];
                /*- 返回 */
                break;
            }
            else
            {
                /*- 无处理 */
            }
        }
    }
    /*- 返回通信配置 */
    return pCom;
}

/**
* @brief 板卡id自检
*/
void PFM_CFG_IfconfigIp(void)
{
#ifdef QNX
	/*- 变量初始化 */
	CM_UINT8 DrvBoard_ID = DFM_getBoardID();     /* 板卡ID */
	CM_CHAR str[1024] = {0};
	(void)memset(str, 0, sizeof(str));
	MSCP_LOG_MSG("drv_boardid:0x%x\r\n",DrvBoard_ID);
	switch(DrvBoard_ID)
	{
	/*1-1*/
	case 0x53U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.144.101");
		/*- 跳出 */
		break;
	case 0x33U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.146.101");
		/*- 跳出 */
		break;
	case 0x63U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.145.101");
		/*- 跳出 */
		break;
	case 0x03U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.147.101");
		/*- 跳出 */
		break;
	/*1-2*/
	case 0x55U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.16.102");
		/*- 跳出 */
		break;
	case 0x35U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.18.102");
		/*- 跳出 */
		break;
	case 0x65U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.17.102");
		/*- 跳出 */
		break;
	case 0x05U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.19.102");
		/*- 跳出 */
		break;
	/*2-1*/
	case 0xA6U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.144.103");
		/*- 跳出 */
		break;
	case 0xC6U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.146.103");
		/*- 跳出 */
		break;
	case 0x96U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.145.103");
		/*- 跳出 */
		break;
	case 0xF6U:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.147.103");
		/*- 跳出 */
		break;
	/*2-2*/
	case 0xAAU:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.16.104");
		/*- 跳出 */
		break;
	case 0xCAU:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.18.104");
		/*- 跳出 */
		break;
	case 0x9AU:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.17.104");
		/*- 跳出 */
		break;
	case 0xFAU:
		sprintf(str, "ifconfig %s %s", "wm0", "192.168.19.104");
		/*- 跳出 */
		break;
	default:
		MSCP_LOG_MSG("drv_boardidErr:0x%x,ini:0x%x,0x%x\r\n",DrvBoard_ID,g_PFM_Cfg.BOARD_ID,g_PFM_Cfg.CPU_ID);
		/*- 跳出 */
		break;
	}
	(void)printf("%s\n",str);
	(void)system(str);
#endif /*QNX*/
}

/**
* @brief 初始化应用版本号管理结构体
*/
void PFM_CFG_RegisterVerson_Init(void)
{
	/*- 变量初始化 */
	CM_UINT8 i = 0u;
	CM_UINT8 j = 0u;
	g_App_Verson.versonNumber = 0u;

	/*- @alias 初始化应用版本号管理结构体 */
	for(i = 0u; i < 3u; i++)
	{
		g_App_Verson.registerVerson[i].flag = 0u;
		g_App_Verson.registerVerson[i].versonName = i + 1u;
		for(j = 0u; j < 4u; j++)
		{
			g_App_Verson.registerVerson[i].verson[j] = 0u;
		}
	}

}

/**
* @brief 应用配置ip、端口、使能等可配置变量
* @param app_data 应用配置结构体 取值范围:非空
* @details 此配置用来代替main_base.ini
*/
void PFM_Set_APP_ConfigData(STRU_APP_CFG_T *app_data)
{
	/*- 变量初始化 */
	ENUM_CM_RETURN ret = ENUM_CM_FALSE; /* 函数返回值 */
	/*- 如果入参为空 */
	if(NULL == app_data)
	{
		/*- 无处理 */
	}
	else
	{
		/*- 应用配置ip、端口、使能等可配置变量 */
		ret = CM_Memcpy(&g_AppCfgInterface,sizeof(STRU_APP_CFG_T),app_data,sizeof(STRU_APP_CFG_T));
	}

	/*- 判断是否配置成功 */
	CM_NM_ASSERT(ENUM_CM_TRUE == ret, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_5, TSCP_DARK_ASSERT_1);
}

/**
* @brief 板卡id自检
*/
static void PFM_CFG_Check_BoardID(void)
{
#ifdef QNX
	CM_UINT8 DrvBoard_ID = DFM_getBoardID();     /**< 板卡ID */
	MSCP_LOG_MSG("drv_boardid:0x%x\r\n",DrvBoard_ID);
	switch(DrvBoard_ID)
	{
	/*1-1*/
	case 0x53U:
	case 0x33U:
	case 0x63U:
	case 0x03U:
		CM_NM_ASSERT(((CM_UINT8)1U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)1U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1);
		/*- 跳出 */
		break;
	/*1-2*/
	case 0x55U:
	case 0x35U:
	case 0x65U:
	case 0x05U:
		CM_NM_ASSERT(((CM_UINT8)1U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)2U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1);
		/*- 跳出 */
		break;
	/*2-1*/
	case 0xA6U:
	case 0xC6U:
	case 0x96U:
	case 0xF6U:
		CM_NM_ASSERT(((CM_UINT8)2U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)1U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1);
		/*- 跳出 */
		break;
	/*2-2*/
	case 0xAAU:
	case 0xCAU:
	case 0x9AU:
	case 0xFAU:
		CM_NM_ASSERT(((CM_UINT8)2U == g_PFM_Cfg.BOARD_ID) && ((CM_UINT8)2U == g_PFM_Cfg.CPU_ID), CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1);
		/*- 跳出 */
		break;
	default:
		MSCP_LOG_MSG("drv_boardidErr:0x%x,ini:0x%x,0x%x\r\n",DrvBoard_ID,g_PFM_Cfg.BOARD_ID,g_PFM_Cfg.CPU_ID);
		CM_NM_ASSERT(0, CFG_MODE, DARK_FAULT_CODE_FUN_ORDER_4, TSCP_DARK_ASSERT_1);
		/*- 跳出 */
		break;
	}
#endif /*QNX*/
}

void PFM_CFG_SendDarkCfg(void)
{
    (void)CFM_DarkLog_Multiple(DARK_LOG_HEX, TSCP_DARK_PFMCFG_SENDDARKCFG, 14u, \
    					sizeof(CM_UINT32),g_PFM_Cfg.CYC_TIME,
    					sizeof(CM_UINT32),g_PFM_Cfg.OutnetSafePack_Len,
						sizeof(CM_INT32),g_PFM_Cfg.app_num,
    					sizeof(CM_UINT32),g_PFM_Cfg.M_2oo2_Enable,
						sizeof(CM_UINT32),g_PFM_Cfg.M_2x2_Enable,
						sizeof(CM_UINT32),g_PFM_Cfg.M_InnetSafe_Enable,
						sizeof(CM_UINT32),g_PFM_Cfg.M_InnetRaw_Enable,
						sizeof(CM_UINT32),g_PFM_Cfg.M_OutnetSafe_Enable,
						sizeof(CM_UINT32),g_PFM_Cfg.M_OutnetRaw_Enable,
						sizeof(CM_UINT8),g_PFM_Cfg.M_CpuUsageGet_Enable,
						sizeof(CM_UINT32),g_PFM_Cfg.M_RemoteUpdate_Enable,
						sizeof(CM_INT32),g_PFM_Cfg.reboot_replycount,
						sizeof(CM_UINT8),g_PFM_Cfg.M_AutoReboot_Count,
						sizeof(CM_UINT16),g_PFM_Cfg.M_AutoClear_Days);
}

