Jelajahi Sumber

充电控制器软件初版

LAPTOP-KB7QFH2U\ChenJie-PC 2 tahun lalu
induk
melakukan
bee5ef1004

+ 29 - 26
HardwareLib/HardwareLib.h

@@ -99,8 +99,8 @@ typedef enum
 #define _ATD_INDEX_DI3_CHAN 21      // DI3信号,对应接插件X18
 #define _ATD_INDEX_DI2_CHAN 22      // DI2信号,对应接插件X17
 #define _ATD_INDEX_UBATTERY_CHAN 23 //蓄电池电压,内部连接
-                                    //模拟量输入重新定义(APP)
-#define _ATD_INDEX_AIRPRESSURE 17   //气压传感器,对应接插件XK62
+/*应用层序号重新定义*/
+
 #define _ATD_INDEX_PLUGINTEMP1 2    //接插件温度1,对应接插件XK27
 #define _ATD_INDEX_PLUGINTEMP2 3    //接插件温度2,对应接插件XK35
 #define _ATD_INDEX_PLUGINTEMP3 4    //接插件温度3,对应接插件XK30
@@ -132,20 +132,23 @@ uint16 ATDDrv_GetChanResult(uint8 idxChanUB); //
 #define _DIN_INDEX_BAK14_CHAN 13   //开关14信号,对应接插件X19
 #define _DIN_INDEX_BAK15_CHAN 14   //开关15信号,对应接插件X22
 #define _DIN_INDEX_BAK16_CHAN 15   //开关16信号,对应接插件X23
-                                   //数字量输入重新定义(APP)
-#define _DIN_INDEX_UNLOCKSENSOR1 0 //对应接插件XK10,松开传感器1,需配置低有效
-#define _DIN_INDEX_UNLOCKSENSOR2 7 //对应接插件XK11,松开传感器2,需配置低有效
-#define _DIN_INDEX_UNLOCKSENSOR3 3 //对应接插件XK13,松开传感器3,需配置低有效
-#define _DIN_INDEX_UNLOCKSENSOR4 4 //对应接插件XK14,松开传感器4,需配置低有效
-
-#define _DIN_INDEX_LOCKSENSOR1 8 //对应接插件XK15,夹紧传感器1,需配置低有效
-#define _DIN_INDEX_LOCKSENSOR2 1 //对应接插件XK17,夹紧传感器2,需配置低有效
-#define _DIN_INDEX_LOCKSENSOR3 2 //对应接插件XK18,夹紧传感器3,需配置低有效
-#define _DIN_INDEX_LOCKSENSOR4 6 //对应接插件XK5,夹紧传感器4,需配置低有效
-
-#define _DIN_INDEX_READYSENSOR1 11 //对应接插件XK6,落座传感器1,高有效
-#define _DIN_INDEX_READYSENSOR2 10 //对应接插件XK7,落座传感器2,高有效
-#define _DIN_INDEX_PLUGHVLOCK 12   //对应接插件XK3,接插件互锁1,高有效,整车放电接插件
+/*应用层序号重新定义*/
+#define _DIN_INDEX_X10 0    	//开关1信号,对应接插件X10,输入交流接触器
+#define _DIN_INDEX_X17 1    	//开关2信号,对应接插件X17,并充正负接触器
+#define _DIN_INDEX_X18 2    	//开关3信号,对应接插件X18,A路至底座输出接触器
+#define _DIN_INDEX_X13 3    	//开关4信号,对应接插件X13,A路至充电枪接触器
+#define _DIN_INDEX_X14 4     	//开关5信号,对应接插件X14,B路至底座接触器
+#define _DIN_INDEX_X9 5     	//开关6信号,对应接插件X9,B路至充电枪接触器
+#define _DIN_INDEX_X5 6     	//开关7信号,对应接插件X5,A路熔断器
+#define _DIN_INDEX_X11 7     	//开关8信号,对应接插件X11,B路熔断器
+#define _DIN_INDEX_X15 8    	//开关9信号,对应接插件X15
+#define _DIN_INDEX_X4 9    		//开关10信号,对应接插件X4
+#define _DIN_INDEX_X7 10   		//开关11信号,对应接插件X7,A路辅助电源输出检测
+#define _DIN_INDEX_X6 11  		//开关12信号,对应接插件X6,B路辅助电源输出检测
+#define _DIN_INDEX_X3 12  		//开关13信号,对应接插件X3
+#define _DIN_INDEX_X19 13  		//开关14信号,对应接插件X19
+#define _DIN_INDEX_X22 14   	//开关15信号,对应接插件X22 互锁1
+#define _DIN_INDEX_X23 15   	//开关16信号,对应接插件X23 互锁2
 void DINDrv_SetChanThres(uint8 idxChanUB, uint8 stOpenLvlUB, uint16 uThresUW);
 uint8 DINDrv_GetChanState(uint8 idxChanUB); //得到上述通道开关状态
 //********************************************************************************************
@@ -221,16 +224,16 @@ DSM_stDiagE_TYPE PPWMDrv_GetChanDiagInfo(uint8 idxChanUB, DSM_idxDiagTypeE_TYPE
 #define _PSWT_INDEX_LBAK7_CHAN 14     //低边驱动7,对应接插件X47
 #define _PSWT_INDEX_LBAK8_CHAN 15     //低边驱动8,对应接插件X48
 #define _PSWT_INDEX_MAINRELAY_CHAN 16 //功率电主继电器,对应接插件X33
-                                      //驱动重新定义(APP)
-#define _PSWT_INDEX_AIRCONTROL 0      //电磁阀控制,对应接插件XK36
-#define _PSWT_INDEX_EBCLEDCONTROL 1   //换电LED控制,对应接插件XK32
-#define _PSWT_INDEX_BLEPWRCONTROL 2   //蓝牙电源控制,对应接插件XK28
-#define _M1_C 8                       // M1-控制,对应接插件X34
-#define _M2_C 9                       // M2-控制,对应接插件X44
-#define _M3_C 10                      // M3-控制,对应接插件X41
-#define _M4_C 11                      // M4-控制,对应接插件X43
-
-#define _M_D_C 15 // M4-反转控制,对应接插件X48
+/*应用层序号重新定义*/
+#define _PSWT_INDEX_X36 0      //高边驱动1,对应接插件X36,输入交流接触器控制
+#define _PSWT_INDEX_X32 1      //高边驱动2,对应接插件X32,A路BMS电源供电切换-B路
+#define _PSWT_INDEX_X28 2      //高边驱动3,对应接插件X28,A路24V常供电电源控制
+#define _PSWT_INDEX_X24 3      //高边驱动4,对应接插件X24,B路24V常供电电源控制
+#define _PSWT_INDEX_X20 4      //高边驱动5,对应接插件X20,A/B路控制输出切换
+#define _PSWT_INDEX_X16 5      //高边驱动6,对应接插件X16,A/B路 S+/S-切换
+#define _PSWT_INDEX_X12 6      //高边驱动7,对应接插件X12,A/B路电子锁控制切换
+#define _PSWT_INDEX_X8 7      	//高边驱动8,对应接插件X8,A/B路辅助电源切换
+
 //该函数须放在10ms任务中调用
 void PSwtDrv_Interface(uint8 idxChanUB, uint8 bOpenUB); //输出上述通道的低边驱动状态, bOpen=1时为打开, 否则为关闭
 DSM_stDiagE_TYPE PSwtDrv_GetChanDiagInfo(uint8 idxChanUB, DSM_idxDiagTypeE_TYPE idxDiagTypeE);

+ 96 - 273
System/Vehicle/AppFunc.c

@@ -14,10 +14,101 @@
 #include "math.h"
 #include "AppFunc.h"
 #include "Std_Types.h"
-#define Lock 0
-#define Unlock 1
-#define LockCtrl() PSwtDrv_Interface(_PSWT_INDEX_HBAK1_CHAN, Lock)
-#define UnlockCtrl() PSwtDrv_Interface(_PSWT_INDEX_HBAK1_CHAN, Unlock)
+
+void GetDIOState(void)
+{
+	//配置高有效,底层悬空为0,触发为1,应用层输出悬空为0,触发为1
+	DINDrv_SetChanThres(_DIN_INDEX_X10, 0, 40950U);
+	DINDrv_SetChanThres(_DIN_INDEX_X17, 0, 40950U);
+	DINDrv_SetChanThres(_DIN_INDEX_X18, 0, 40950U);
+	DINDrv_SetChanThres(_DIN_INDEX_X13, 0, 40950U);
+	DINDrv_SetChanThres(_DIN_INDEX_X9, 0, 40950U);
+	DINDrv_SetChanThres(_DIN_INDEX_X5, 0, 40950U);
+	DINDrv_SetChanThres(_DIN_INDEX_X11, 0, 40950U);
+	DINDrv_SetChanThres(_DIN_INDEX_X14, 0, 40950U);
+
+	chrgModuelPwrCtlFB 		=DINDrv_GetChanState(_DIN_INDEX_X10);
+	paraChrgCtlFB 			=DINDrv_GetChanState(_DIN_INDEX_X17);
+	outToBaseCtlFB_A 		=DINDrv_GetChanState(_DIN_INDEX_X18);
+	outToChrgCtlFB_A		=DINDrv_GetChanState(_DIN_INDEX_X13);
+	outToChrgCtlFB_B		=DINDrv_GetChanState(_DIN_INDEX_X9);
+	outToBaseCtlFB_B		=DINDrv_GetChanState(_DIN_INDEX_X14);
+	fuseActionFB_A			=DINDrv_GetChanState(_DIN_INDEX_X5);
+	fuseActionFB_B			=DINDrv_GetChanState(_DIN_INDEX_X11);
+
+	A_volDetect 			=DINDrv_GetChanState(_DIN_INDEX_X7);
+	B_volDetect				=DINDrv_GetChanState(_DIN_INDEX_X6);
+	connectorHvlock1 		=DINDrv_GetChanState(_DIN_INDEX_X22);
+	connectorHvlock2		=DINDrv_GetChanState(_DIN_INDEX_X23);
+}
+void GetAIOValue(void)
+{
+	uint16 PluginTemp1_Vol = 0;
+	uint32 PluginTemp1_R = 0;
+	uint16 PluginTemp2_Vol = 0;
+	uint32 PluginTemp2_R = 0;
+	uint16 PluginTemp3_Vol = 0;
+	uint32 PluginTemp3_R = 0;
+	uint16 PluginTemp4_Vol = 0;
+	uint32 PluginTemp4_R = 0;
+	//温度采集获取
+	PluginTemp1_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP1);
+	PluginTemp2_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP2);
+	PluginTemp3_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP3);
+	PluginTemp4_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP4);
+	PluginTemp1_R = (uint32)((PluginTemp1_Vol / (5.0 * 4095 - PluginTemp1_Vol)) * 1000.0);
+	PluginTemp2_R = (uint32)((PluginTemp2_Vol / (5.0 * 4095 - PluginTemp2_Vol)) * 1000.0);
+	PluginTemp3_R = (uint32)((PluginTemp3_Vol / (5.0 * 4095 - PluginTemp3_Vol)) * 1000.0);
+	PluginTemp4_R = (uint32)((PluginTemp4_Vol / (5.0 * 4095 - PluginTemp4_Vol)) * 1000.0);
+	chrgGunTemp1_A = (uint8)Look1_u32u8(PluginTemp1_R, R_table, T_table, 240);
+	chrgGunTemp2_A = (uint8)Look1_u32u8(PluginTemp2_R, R_table, T_table, 240);
+	chrgGunTemp1_B = (uint8)Look1_u32u8(PluginTemp3_R, R_table, T_table, 240);
+	chrgGunTemp2_B = (uint8)Look1_u32u8(PluginTemp4_R, R_table, T_table, 240);
+}
+void ctrlFunc(void)
+{
+	if(chrgModulePwrCtrl==1)
+	{
+		PSwtDrv_Interface(_PSWT_INDEX_X36, 1);
+	}
+	else
+	{
+		PSwtDrv_Interface(_PSWT_INDEX_X36, 0);
+	}
+	if(chrgStartState==0&&chrgStopState==1)
+	{
+		if(baseSwitchCtrl==1)
+		{
+			PSwtDrv_Interface(_PSWT_INDEX_X32, 1);
+			PSwtDrv_Interface(_PSWT_INDEX_X20, 1);
+			PSwtDrv_Interface(_PSWT_INDEX_X16, 1);
+			PSwtDrv_Interface(_PSWT_INDEX_X12, 1);
+			PSwtDrv_Interface(_PSWT_INDEX_X8, 1);
+		}
+		else
+		{
+			PSwtDrv_Interface(_PSWT_INDEX_X32, 0);
+			PSwtDrv_Interface(_PSWT_INDEX_X20, 0);
+			PSwtDrv_Interface(_PSWT_INDEX_X16, 0);
+			PSwtDrv_Interface(_PSWT_INDEX_X12, 0);
+			PSwtDrv_Interface(_PSWT_INDEX_X8, 0);
+		}
+	}
+
+	 chrgBoxTemp1 = temp_gf1;
+	 chrgBoxTemp2 = temp_gf2;
+	 chrgBoxGasOver1 = gashighLevel_gf1;
+	 chrgBoxGasOver2 = gashighLevel_gf2;
+	 chrgBoxFumesOver1 = fumesHigh_gf1;
+	 chrgBoxFumesOver2 = fumesHigh_gf2;
+
+	 ctrlFXFB1 = getbit(workMode_gf1,5);
+	 ctrlFXFB2 = getbit(workMode_gf2,5);
+	 chrgBox1Warning = warningLevel_gf1;
+	 chrgBox2Warning = warningLevel_gf2;
+
+}
+/*
 void LockAndUnlockCtrl()
 {
 	static uint16 LockDelay = 0;
@@ -154,110 +245,9 @@ void LockAndUnlockCtrl()
 		LockCtrl();
 	}
 }
-/**
- * @brief : 互锁检测函数
- * @param {*}
- * @return {*}
- */
-void GetHVLockState(void)
-{
-	// PWM输出,互锁1检测,频率100HZ,占空比30%
-	uint16 VehCo_fTestUI = 1000;
-	uint16 VehCo_rTestUW = 3000;
-	uint32 PwmFreAcq = 0;
-	uint16 PwmDutyAcq = 0;
-	PPWMDrv_Interface(_PPWM_INDEX_HVLOCK2, VehCo_fTestUI, VehCo_rTestUW);
-	PulseAcqDrv_GetChanFreq(_PULSEACQ_INDEX_HVLOCK2, &PwmFreAcq, &PwmDutyAcq);
-	if (abs(PwmFreAcq - VehCo_fTestUI) < 100 && abs(PwmDutyAcq - VehCo_rTestUW) < 500)
-	{
-		m_flg_HVlock1 = 1;
-	}
-	else
-	{
-		m_flg_HVlock1 = 0;
-	}
-	//互锁2检测,高有效,悬空为0则未接入,高电平为1则接入,
-	m_flg_HVlock2 = DINDrv_GetChanState(_DIN_INDEX_PLUGHVLOCK);
-}
-/**
- * @brief : 数字量传感器信号检测函数
- * @param {*}
- * @return {*}
- */
-void GetDIOState(void)
-{
-	uint8 temp[4];
-	//松开传感器检测,配置低有效,底层悬空为1,触发为0,应用层输出悬空为0,触发为1
-	memset(temp, 0x00, 4);
-	ebcd_st_unlockSensor = 0;
-	DINDrv_SetChanThres(_DIN_INDEX_UNLOCKSENSOR1, 1, 4095U);
-	DINDrv_SetChanThres(_DIN_INDEX_UNLOCKSENSOR2, 1, 4095U);
-	DINDrv_SetChanThres(_DIN_INDEX_UNLOCKSENSOR3, 1, 4095U);
-	DINDrv_SetChanThres(_DIN_INDEX_UNLOCKSENSOR4, 1, 4095U);
-	temp[0] = !DINDrv_GetChanState(_DIN_INDEX_UNLOCKSENSOR1);
-	temp[1] = !DINDrv_GetChanState(_DIN_INDEX_UNLOCKSENSOR2);
-	temp[2] = !DINDrv_GetChanState(_DIN_INDEX_UNLOCKSENSOR3);
-	temp[3] = !DINDrv_GetChanState(_DIN_INDEX_UNLOCKSENSOR4);
-	ebcd_st_unlockSensor = (getbit(temp[3], 0) << 3) | (getbit(temp[2], 0) << 2) | (getbit(temp[1], 0) << 1) | (getbit(temp[0], 0) << 0);
+*/
 
-	//夹紧传感器检测,配置低有效,底层悬空为1,触发为0,应用层输出悬空为0,触发为1
-	memset(temp, 0x00, 4);
-	ebcd_st_lockSensor = 0;
-	DINDrv_SetChanThres(_DIN_INDEX_LOCKSENSOR1, 1, 4095U);
-	DINDrv_SetChanThres(_DIN_INDEX_LOCKSENSOR2, 1, 4095U);
-	DINDrv_SetChanThres(_DIN_INDEX_LOCKSENSOR3, 1, 4095U);
-	DINDrv_SetChanThres(_DIN_INDEX_LOCKSENSOR4, 1, 4095U);
-	temp[0] = !DINDrv_GetChanState(_DIN_INDEX_LOCKSENSOR1);
-	temp[1] = !DINDrv_GetChanState(_DIN_INDEX_LOCKSENSOR2);
-	temp[2] = !DINDrv_GetChanState(_DIN_INDEX_LOCKSENSOR3);
-	temp[3] = !DINDrv_GetChanState(_DIN_INDEX_LOCKSENSOR4);
-	ebcd_st_lockSensor = (getbit(temp[3], 0) << 3) | (getbit(temp[2], 0) << 2) | (getbit(temp[1], 0) << 1) | (getbit(temp[0], 0) << 0);
-
-	//落座传感器检测,高有效,悬空为0则未接入,高电平为1则接入
-	memset(temp, 0x00, 4);
-	temp[0] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR1);
-	temp[1] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR2);
-	ebcd_st_pedstSensor = (getbit(temp[1], 0) << 1) | (getbit(temp[0], 0) << 0);
-}
 
-/**
- * @brief : 获取模拟量输入值,并进行转换
- * @param {*}
- * @return {*}
- */
-void GetAIOValue(void)
-{
-	uint16 AirPressureTemp_Vol = 0;
-	uint16 PluginTemp1_Vol = 0;
-	uint32 PluginTemp1_R = 0;
-	uint16 PluginTemp2_Vol = 0;
-	uint32 PluginTemp2_R = 0;
-	uint16 PluginTemp3_Vol = 0;
-	uint32 PluginTemp3_R = 0;
-	uint16 PluginTemp4_Vol = 0;
-	uint32 PluginTemp4_R = 0;
-
-	AirPressureTemp_Vol = ATDDrv_GetChanResult(_ATD_INDEX_AIRPRESSURE);
-	AirPressureTemp_Vol = (uint16)(AirPressureTemp_Vol * 1000 / 4095.0);
-	Test_LockPressure = AirPressureTemp_Vol; //锁紧力测试变量
-	/*气压数据转换*/
-	AirPressureTemp_Vol = MAX(AirPressureTemp_Vol, 500);
-	AirPressureTemp_Vol = MIN(AirPressureTemp_Vol, 4500);
-	ebcd_P_airSensor = (uint8)((AirPressureTemp_Vol - 500) / 40);
-	/*温度采集获取*/
-	PluginTemp1_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP1);
-	PluginTemp2_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP2);
-	PluginTemp3_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP3);
-	PluginTemp4_Vol = ATDDrv_GetChanResult(_ATD_INDEX_PLUGINTEMP4);
-	PluginTemp1_R = (uint32)((PluginTemp1_Vol / (5.0 * 4095 - PluginTemp1_Vol)) * 1000.0);
-	PluginTemp2_R = (uint32)((PluginTemp2_Vol / (5.0 * 4095 - PluginTemp2_Vol)) * 1000.0);
-	PluginTemp3_R = (uint32)((PluginTemp3_Vol / (5.0 * 4095 - PluginTemp3_Vol)) * 1000.0);
-	PluginTemp4_R = (uint32)((PluginTemp4_Vol / (5.0 * 4095 - PluginTemp4_Vol)) * 1000.0);
-	ebcd_T_plugin[0] = (uint8)Look1_u32u8(PluginTemp1_R, R_table, T_table, 240);
-	ebcd_T_plugin[1] = (uint8)Look1_u32u8(PluginTemp2_R, R_table, T_table, 240);
-	ebcd_T_plugin[2] = (uint8)Look1_u32u8(PluginTemp3_R, R_table, T_table, 240);
-	ebcd_T_plugin[3] = (uint8)Look1_u32u8(PluginTemp4_R, R_table, T_table, 240);
-}
 /**
  * @brief : lookUp Table Fun
  * @param {uint32} u0 x
@@ -325,174 +315,7 @@ uint16 Look1_u32u8(uint32 u0, uint32 *bp0, uint8 *table, uint16 MaxLen)
 	}
 	return y;
 }
-/**
- * @brief : 故障诊断函数,运行时间100ms
- * @param {*}
- * @return {*}
- */
-void FaultDiagnosisFunc(void)
-{
-	UINT8 ErrorNumTemp = 0, ErrRank = 0;
-	static BOOL FuncFirstRun = TRUE;
-	static BOOL sfmd_flg_Temp1Over2;
-	static BOOL sfmd_flg_Temp2Over2;
-	static BOOL sfmd_flg_Temp3Over2;
-	static BOOL sfmd_flg_Temp4Over2;
-	static BOOL sfmd_flg_Temp1Over3;
-	static BOOL sfmd_flg_Temp2Over3;
-	static BOOL sfmd_flg_Temp3Over3;
-	static BOOL sfmd_flg_Temp4Over3;
-	BOOL sfmd_flg_Temp1Openflt = FALSE;
-	BOOL sfmd_flg_Temp2Openflt = FALSE;
-	BOOL sfmd_flg_Temp3Openflt = FALSE;
-	BOOL sfmd_flg_Temp4Openflt = FALSE;
-	if (FuncFirstRun)
-	{
-		FuncFirstRun = FALSE;
-		sfmd_flg_Temp1Over2 = FALSE;
-		sfmd_flg_Temp2Over2 = FALSE;
-		sfmd_flg_Temp3Over2 = FALSE;
-		sfmd_flg_Temp4Over2 = FALSE;
-		sfmd_flg_Temp1Over3 = getbit(sfmv_Num_FltEEsave, 0);
-		sfmd_flg_Temp2Over3 = getbit(sfmv_Num_FltEEsave, 1);
-		sfmd_flg_Temp3Over3 = getbit(sfmv_Num_FltEEsave, 2);
-		sfmd_flg_Temp4Over3 = getbit(sfmv_Num_FltEEsave, 3);
-	}
-	/*锁紧与解锁诊断*/
-	if (ebcd_st_SwitchCtrlFlg == Unlock) //解锁诊断
-	{
-		if (ebcd_st_unlockSensor == 0x0F)
-		{
-			ebcd_st_unlockSucJug = 1;
-		}
-		else if (ebcd_st_unlockSensor == 0x00)
-		{
-			ebcd_st_unlockSucJug = 0;
-		}
-		else
-		{
-			ebcd_st_unlockSucJug = 2;
-		}
-	}
-	else //锁紧诊断
-	{
-		if (ebcd_st_lockSensor == 0x0F)
-		{
-			ebcd_st_lockSucJug = 1;
-		}
-		else if (ebcd_st_lockSensor == 0x00)
-		{
-			ebcd_st_lockSucJug = 0;
-		}
-		else
-		{
-			ebcd_st_lockSucJug = 2;
-		}
-	}
-	/*底座到位判断*/
-	if (ebcd_st_pedstSucJug == 0x03)
-	{
-		ebcd_st_pedstSucJug = 1;
-	}
-	else if (ebcd_st_pedstSucJug == 0x00)
-	{
-		ebcd_st_pedstSucJug = 0;
-	}
-	else
-	{
-		ebcd_st_pedstSucJug = 2;
-	}
-	/*温度传感器开路诊断*/
-	sfmd_flg_Temp1Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[0] == 0), (UINT16 *)&DiagErrFaulNum.DiagErrFaulN25, 5U);
-	sfmd_flg_Temp2Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[1] == 0), (UINT16 *)&DiagErrFaulNum.DiagErrFaulN26, 5U);
-	sfmd_flg_Temp3Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[2] == 0), (UINT16 *)&DiagErrFaulNum.DiagErrFaulN27, 5U);
-	sfmd_flg_Temp4Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[3] == 0), (UINT16 *)&DiagErrFaulNum.DiagErrFaulN28, 5U);
-	/*温度传感器三级过温诊断*/
-	sfmd_flg_Temp1Over3 = DiagThrSystem1(1, !sfmd_flg_Temp1Openflt, ebcd_T_plugin[0], sfmd_Th_Temp1Over3Faul, sfmd_Th_Temp1Over3Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN17, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN17, sfmd_flg_Temp1Over3);
-	sfmd_flg_Temp2Over3 = DiagThrSystem1(1, !sfmd_flg_Temp2Openflt, ebcd_T_plugin[1], sfmd_Th_Temp2Over3Faul, sfmd_Th_Temp2Over3Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN18, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN18, sfmd_flg_Temp2Over3);
-	sfmd_flg_Temp3Over3 = DiagThrSystem1(1, !sfmd_flg_Temp3Openflt, ebcd_T_plugin[2], sfmd_Th_Temp3Over3Faul, sfmd_Th_Temp3Over3Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN19, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN19, sfmd_flg_Temp3Over3);
-	sfmd_flg_Temp4Over3 = DiagThrSystem1(1, !sfmd_flg_Temp4Openflt, ebcd_T_plugin[3], sfmd_Th_Temp4Over3Faul, sfmd_Th_Temp4Over3Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN20, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN20, sfmd_flg_Temp4Over3);
-	/*温度传感器二级过温诊断*/
-	sfmd_flg_Temp1Over2 = DiagThrSystem1(1, !sfmd_flg_Temp1Over3 && !sfmd_flg_Temp1Openflt, ebcd_T_plugin[0], sfmd_Th_Temp1Over2Faul, sfmd_Th_Temp1Over2Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN9, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN9, sfmd_flg_Temp1Over2);
-	sfmd_flg_Temp2Over2 = DiagThrSystem1(1, !sfmd_flg_Temp2Over3 && !sfmd_flg_Temp2Openflt, ebcd_T_plugin[1], sfmd_Th_Temp2Over2Faul, sfmd_Th_Temp2Over2Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN10, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN10, sfmd_flg_Temp2Over2);
-	sfmd_flg_Temp3Over2 = DiagThrSystem1(1, !sfmd_flg_Temp3Over3 && !sfmd_flg_Temp3Openflt, ebcd_T_plugin[2], sfmd_Th_Temp3Over2Faul, sfmd_Th_Temp3Over2Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN11, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN11, sfmd_flg_Temp3Over2);
-	sfmd_flg_Temp4Over2 = DiagThrSystem1(1, !sfmd_flg_Temp4Over3 && !sfmd_flg_Temp4Openflt, ebcd_T_plugin[3], sfmd_Th_Temp4Over2Faul, sfmd_Th_Temp4Over2Reco, 30, 30, (UINT16 *)&DiagErrFaulNum.DiagErrFaulN12, (UINT16 *)&DiagErrRecoNum.DiagErrRecoN12, sfmd_flg_Temp4Over2);
 
-	sfmv_Num_FltEEsave = ((sfmd_flg_Temp4Over3 & 0x01) << 3) | ((sfmd_flg_Temp3Over3 & 0x01) << 2) | ((sfmd_flg_Temp2Over3 & 0x01) << 1) | (sfmd_flg_Temp1Over3);
-	/*故障代码写入*/
-	if (sfmd_flg_Temp1Openflt)
-	{
-		ErrorNumTemp = 25;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp2Openflt)
-	{
-		ErrorNumTemp = 26;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp3Openflt)
-	{
-		ErrorNumTemp = 27;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp4Openflt)
-	{
-		ErrorNumTemp = 28;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp1Over3)
-	{
-		ErrorNumTemp = 17;
-		ErrRank = 3;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp2Over3)
-	{
-		ErrorNumTemp = 18;
-		ErrRank = 3;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp3Over3)
-	{
-		ErrorNumTemp = 19;
-		ErrRank = 3;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp4Over3)
-	{
-		ErrorNumTemp = 20;
-		ErrRank = 3;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp1Over2)
-	{
-		ErrorNumTemp = 9;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp2Over2)
-	{
-		ErrorNumTemp = 10;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp3Over2)
-	{
-		ErrorNumTemp = 11;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-	if (sfmd_flg_Temp4Over2)
-	{
-		ErrorNumTemp = 12;
-		ErrRank = 2;
-		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
-	}
-}
 /**
  * @brief : 故障判断函数
  * @param {BOOL} Enable 使能状态

+ 2 - 4
System/Vehicle/AppFunc.h

@@ -17,12 +17,10 @@
 #ifndef SYSTEM_VEHICLE_APPFUNCION_H_
 #define SYSTEM_VEHICLE_APPFUNCION_H_
 #include "CanVar.h"
-void GetHVLockState(void);
-void GetDIOState(void);
+void ctrlFunc(void);
 void GetAIOValue(void);
-void LockAndUnlockCtrl();
+void GetDIOState(void);
 uint16 Look1_u32u8(uint32 u0, uint32 *bp0, uint8 *table, uint16 MaxLen);
-void FaultDiagnosisFunc(void);
 BOOL JudgeTimeSystem(BOOL Enable, BOOL Input, UINT16 *N, UINT16 Thr);
 BOOL DiagThrSystem1(BOOL Enable, BOOL precondition, UINT16 Input, UINT16 fltThr, UINT16 recThr, UINT16 fltNumThr, UINT16 recNumThr, UINT16 *fltNum, UINT16 *recNum, UINT8 *fitFlg);
 UINT16 GetErrorNum(UINT16 *ErrorArray, UINT8 Errorlen);

+ 4 - 20
System/Vehicle/AppVar.c

@@ -10,24 +10,8 @@
 //标定变量
 #include "AppVar.h"
 /*constVar*/
-const UINT8 sfmd_Th_Temp1Over2Faul = 120;
-const UINT8 sfmd_Th_Temp1Over2Reco = 110;
-const UINT8 sfmd_Th_Temp2Over2Faul = 120;
-const UINT8 sfmd_Th_Temp2Over2Reco = 110;
-const UINT8 sfmd_Th_Temp3Over2Faul = 120;
-const UINT8 sfmd_Th_Temp3Over2Reco = 110;
-const UINT8 sfmd_Th_Temp4Over2Faul = 120;
-const UINT8 sfmd_Th_Temp4Over2Reco = 110;
-const UINT8 sfmd_Th_Temp1Over3Faul = 135;
-const UINT8 sfmd_Th_Temp1Over3Reco = 110;
-const UINT8 sfmd_Th_Temp2Over3Faul = 135;
-const UINT8 sfmd_Th_Temp2Over3Reco = 110;
-const UINT8 sfmd_Th_Temp3Over3Faul = 135;
-const UINT8 sfmd_Th_Temp3Over3Reco = 110;
-const UINT8 sfmd_Th_Temp4Over3Faul = 135;
-const UINT8 sfmd_Th_Temp4Over3Reco = 110;
 
-UINT8 ebcd_st_SwitchCtrlFlg = 0; //换电控制器控制状态
-UINT16 ErrArray[10] = {0};
-DiagErrFaulNum_t DiagErrFaulNum;
-DiagErrRecoNum_t DiagErrRecoNum;
+UINT8 A_volDetect = 0;
+UINT8 B_volDetect = 0;
+UINT8 A_volCtrl = 0;
+UINT8 B_volCtrl = 0;

+ 4 - 63
System/Vehicle/AppVar.h

@@ -9,68 +9,9 @@
  */
 #include "Std_Types.h"
 #include "HardwareLib.h"
-typedef struct
-{
-    UINT16 DiagErrFaulN9;
-    UINT16 DiagErrFaulN10;
-    UINT16 DiagErrFaulN11;
-    UINT16 DiagErrFaulN12;
-    UINT16 DiagErrFaulN13;
-    UINT16 DiagErrFaulN14;
-    UINT16 DiagErrFaulN15;
-    UINT16 DiagErrFaulN16;
-    UINT16 DiagErrFaulN17;
-    UINT16 DiagErrFaulN18;
-    UINT16 DiagErrFaulN19;
-    UINT16 DiagErrFaulN20;
-    UINT16 DiagErrFaulN21;
-    UINT16 DiagErrFaulN22;
-    UINT16 DiagErrFaulN23;
-    UINT16 DiagErrFaulN24;
-    UINT16 DiagErrFaulN25;
-    UINT16 DiagErrFaulN26;
-    UINT16 DiagErrFaulN27;
-    UINT16 DiagErrFaulN28;
-} DiagErrFaulNum_t;
-
-typedef struct
-{
-    UINT16 DiagErrRecoN9;
-    UINT16 DiagErrRecoN10;
-    UINT16 DiagErrRecoN11;
-    UINT16 DiagErrRecoN12;
-    UINT16 DiagErrRecoN13;
-    UINT16 DiagErrRecoN14;
-    UINT16 DiagErrRecoN15;
-    UINT16 DiagErrRecoN16;
-    UINT16 DiagErrRecoN17;
-    UINT16 DiagErrRecoN18;
-    UINT16 DiagErrRecoN19;
-    UINT16 DiagErrRecoN20;
-    UINT16 DiagErrRecoN21;
-    UINT16 DiagErrRecoN22;
-    UINT16 DiagErrRecoN23;
-    UINT16 DiagErrRecoN24;
-} DiagErrRecoNum_t;
 /*ConstVar*/
-extern const UINT8 sfmd_Th_Temp1Over2Faul;
-extern const UINT8 sfmd_Th_Temp1Over2Reco;
-extern const UINT8 sfmd_Th_Temp2Over2Faul;
-extern const UINT8 sfmd_Th_Temp2Over2Reco;
-extern const UINT8 sfmd_Th_Temp3Over2Faul;
-extern const UINT8 sfmd_Th_Temp3Over2Reco;
-extern const UINT8 sfmd_Th_Temp4Over2Faul;
-extern const UINT8 sfmd_Th_Temp4Over2Reco;
-extern const UINT8 sfmd_Th_Temp1Over3Faul;
-extern const UINT8 sfmd_Th_Temp1Over3Reco;
-extern const UINT8 sfmd_Th_Temp2Over3Faul;
-extern const UINT8 sfmd_Th_Temp2Over3Reco;
-extern const UINT8 sfmd_Th_Temp3Over3Faul;
-extern const UINT8 sfmd_Th_Temp3Over3Reco;
-extern const UINT8 sfmd_Th_Temp4Over3Faul;
-extern const UINT8 sfmd_Th_Temp4Over3Reco;
 
-extern UINT8 ebcd_st_SwitchCtrlFlg;
-extern UINT16 ErrArray[10];
-extern DiagErrFaulNum_t DiagErrFaulNum;
-extern DiagErrRecoNum_t DiagErrRecoNum;
+extern UINT8 A_volDetect ;
+extern UINT8 B_volDetect ;
+extern UINT8 A_volCtrl ;
+extern UINT8 B_volCtrl ;

+ 0 - 807
System/Vehicle/Communication/BcuCanProtocolFunc.c

@@ -1,807 +0,0 @@
-/*
- * @Author       : ChenJie
- * @Date         : 2021-12-22 17:09:09
- * @Version      : V3.0
- * @LastEditors  : ChenJie
- * @LastEditTime : 2022-05-10 18:53:29
- * @Description  : CAN协议解析与组包
- * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\BcuCanProtocolFunc.c
- */
-#include "BcuCanProtocolFunc.h"
-void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
-{
-	switch (ID)
-	{
-	case 0x1801D0F3:
-		BMS_ReqVIN = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0x3);
-		BMS_ReqHVOff = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
-		BcuRxFlag[0] = 0x01;
-		break;
-	case 0x1801D8F3:
-		BMS_SoftwareVersion = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_HardwareVersion = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_ProtocolEditionH = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x3);
-		BMS_ProtocolEditionL = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0xF);
-		BcuRxFlag[1] = 0x01;
-		break;
-	case 0x1880D0F3:
-		BMS_CharDevNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xF);
-		BMS_FtPosRly = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 4) & 0x1);
-		BMS_FtNegRly = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 5) & 0x1);
-		BMS_FtPosCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 6) & 0x1);
-		BMS_FtNegCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 7) & 0x1);
-		BMS_FtPosCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0x1);
-		BMS_FtNegCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 1) & 0x1);
-		BMS_FtHeatRly1 = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 2) & 0x1);
-		BMS_FtHeatRly2 = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 3) & 0x1);
-		BMS_StPosRly = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 4) & 0x3);
-		BMS_StNegRly = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 6) & 0x3);
-		BMS_StPreCharRly = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0x3);
-		BMS_StPosCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 2) & 0x3);
-		BMS_StNegCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 4) & 0x3);
-		BMS_StPosCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 6) & 0x3);
-		BMS_StNegCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0x3);
-		BMS_FtAuxRelayWeld = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 2) & 0x1);
-		BMS_BraOpenCirc = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 3) & 0x1);
-		BMS_FtBackCharCurrOutLim = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 4) & 0x3);
-		BMS_FtPosRlyOpen = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 6) & 0x1);
-		BMS_FtNegRlyOpen = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 7) & 0x1);
-		BMS_FtPosCharRly1Open = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x1);
-		BMS_FtPosCharRly2Open = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 1) & 0x1);
-		BMS_FtNegCharRly1Open = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0x1);
-		BMS_FtNegCharRly2Open = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 3) & 0x1);
-		BMS_FtTMSContClose = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 4) & 0x1);
-		BMS_FtTMSContOpen = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 5) & 0x1);
-		BMS_FtTMS = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 6) & 0x1);
-		BMS_Ft24VSpy = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 7) & 0x1);
-		BMS_FtPACKSelfProt = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0x1);
-		BMS_FtCharSockTempOver = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 1) & 0x3);
-		BMS_FtTempOutCtrl = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 3) & 0x1);
-		BMS_StPosHeatRly = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 4) & 0x3);
-		BMS_StNegHeatRly = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 6) & 0x3);
-		BMS_CharSysNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xF);
-		BMS_FtCode = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		BcuRxFlag[2] = 0x01;
-		break;
-	case 0x1881D0F3:
-		BMS_ST1CheckSum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		BMS_ST1Counter = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xF);
-		BMS_Mode = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 4) & 0x3);
-		BMS_AuxRlySt = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 6) & 0x1);
-		BMS_BattBalaSt = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 7) & 0x1);
-		BMS_CharGunSt = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0x1);
-		BMS_CharMode = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 1) & 0x3);
-		BMS_CharSt = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 3) & 0x3);
-		BMS_FtLvl = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 5) & 0x3);
-		BMS_FtCellTempDiff = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0x3);
-		BMS_FtCellTempHigh = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 2) & 0x3);
-		BMS_FtPACKOverVolt = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 4) & 0x3);
-		BMS_FtPACKUndeVolt = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 6) & 0x3);
-		BMS_FtSOCLow = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x3);
-		BMS_FtCellOverVolt = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0x3);
-		BMS_FtCellUndeVolt = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 4) & 0x3);
-		BMS_FtIns = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 6) & 0x3);
-		BMS_FtCellOverVoltDiff = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0x3);
-		BMS_FtCharCurrOver = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 2) & 0x3);
-		BMS_FtDisCharCurrOver = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 4) & 0x3);
-		BMS_FtCellTempLow = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 6) & 0x3);
-		BMS_FtBranVoltDifOver = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0x3);
-		BMS_FtBMSHardWare = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 2) & 0x3);
-		BMS_FtSOCHigh = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x1);
-		BMS_FtSOCJump = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 5) & 0x1);
-		BMS_FtInCom = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 6) & 0x1);
-		BMS_FtSysMism = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 7) & 0x1);
-		BMS_FtHvIntLock = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x1);
-		BMS_FtSmoke = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 1) & 0x1);
-		BMS_FtFire = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 2) & 0x1);
-		BMS_FtNum = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 3) & 0x1F);
-		BcuRxFlag[3] = 0x01;
-		break;
-	case 0x1882D0F3:
-		BMS_PackSOC = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		BMS_PackSOH = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-		BMS_PackCurr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_MaxCharCurr = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_MaxDisCharCurr = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
-		BcuRxFlag[4] = 0x01;
-		break;
-	case 0x1883D0F3:
-		BMS_PosIns = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_NegIns = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_BattVolt = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_LinkVolt = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
-		BcuRxFlag[5] = 0x01;
-		break;
-	case 0x1884D0F3:
-		BMS_MaxCellTemp = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		BMS_MinCellTemp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-		BMS_AverCellTemp = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-		BMS_MaxCellTempCSC = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-		BMS_MaxCellTempNum = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
-		BMS_MinCellTempCSC = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
-		BMS_MinCellTempNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-		BcuRxFlag[6] = 0x01;
-		break;
-	case 0x1885D0F3:
-		BMS_MaxCellVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_MaxCellVoltCSC = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-		BMS_MaxCellVoltNum = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-		BMS_AverCellVolt = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BcuRxFlag[7] = 0x01;
-		break;
-	case 0x1886D0F3:
-		BMS_MinCellVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_MinCellVoltCSC = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-		BMS_MinCellVoltNum = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-		BMS_ContChrgCurr = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_ContDisCharCurr = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
-		BcuRxFlag[8] = 0x01;
-		break;
-	case 0x1887D0F3:
-		BMS_CharReqVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_CharReqCurr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_SysInsRes = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_InsDeteSt = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0x1);
-		BMS_FtCharInsLow = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 1) & 0x1);
-		BMS_FtCurrSenr = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 2) & 0x1);
-		BMS_FtHeatingFilm = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 3) & 0x1);
-		BMS_FtMainLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x1);
-		BMS_FtAuxLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 5) & 0x1);
-		BMS_FtACANLost = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 6) & 0x1);
-		BMS_FtDCDC = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 7) & 0x1);
-		BMS_FtSOCDif = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x1);
-		BMS_FtCellOverDisChar = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 1) & 0x1);
-		BMS_FtCharOver = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 2) & 0x3);
-		BMS_FtContDisCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 4) & 0x3);
-		BMS_FtContCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 6) & 0x3);
-		BcuRxFlag[9] = 0x01;
-		break;
-	case 0x1888D0F3:
-		BMS_MaxDisCharPwr = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_MaxCharPwr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_ContDisCharPwr = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_ContCharPwr = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
-		BcuRxFlag[10] = 0x01;
-		break;
-	case 0x1889D0F3:
-		BMS_InstEngyCons = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_TotalEngyCons = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_SOE = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_RmanCharTime = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
-		BcuRxFlag[11] = 0x01;
-		break;
-	case 0x188AD0F3:
-		BMS_Gun1DCNegTemp = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		BMS_Gun1DCPosTemp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-		BMS_Gun2DCNegTemp = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-		BMS_Gun2DCPosTemp = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-		BMS_CurrHeatSt = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x3);
-		BMS_CurrCoolSt = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0x3);
-		BMS_FtCharCnct = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 4) & 0x1);
-		BMS_FtOverDisCharCurrDuringChar = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 5) & 0x1);
-		BMS_FtCharNTC = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 6) & 0x1);
-		BMS_FtELock = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 7) & 0x1);
-		BMS_CharNum = (UINT16)(((*(UINT8 *)(rawData + 5)) | (*(UINT8 *)(rawData + 6) << 8)) & 0xFFFF);
-		BcuRxFlag[12] = 0x01;
-		break;
-	case 0x18C1D0F3:
-		BMS_CellVoltFramNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		BMS_CSC_Code = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-		if (BMS_CellVoltFramNum == 0 || BMS_CellVoltFramNum > 128)
-		{
-			break;
-		}
-		for (UINT8 i = 0; i < 3; i++)
-		{
-			BMS_CellVolt[(BMS_CellVoltFramNum - 1) * 3 + i] = (UINT16)(((*(UINT8 *)(rawData + i * 2 + 2)) | (*(UINT8 *)(rawData + i * 2 + 3) << 8)) & 0xFFFF);
-		}
-		BcuRxFlag[13] = 0x01;
-		break;
-	case 0x18C2D0F3:
-		BMS_CellTempFramNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		BMS_CSC_Code = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-		if (BMS_CellTempFramNum == 0 || BMS_CellTempFramNum > 12)
-		{
-			break;
-		}
-		for (UINT8 i = 0; i < 6; i++)
-		{
-			if (((BMS_CellTempFramNum - 1) * 6 + i) < sizeof(BMS_CellTemp))
-			{
-				BMS_CellTemp[(BMS_CellTempFramNum - 1) * 6 + i] = (UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF);
-			}
-		}
-		BcuRxFlag[14] = 0x01;
-		break;
-	case 0x18E1D0F3:
-		BMS_Checksum = 0;
-		for (UINT8 i = 1; i < 8; i++)
-		{
-			BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
-		}
-		if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
-		{
-			BMS_PackComp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0x7);
-			BMS_BattCodeLeng = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 3) & 0x1F);
-			BMS_SN[0] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-			BMS_SN[1] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-			BMS_SN[2] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
-			BMS_SN[3] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
-			BMS_SN[4] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-			BMS_SN[5] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		}
-		BcuRxFlag[15] = 0x01;
-		break;
-	case 0x18E2D0F3:
-		BMS_Checksum = 0;
-		for (UINT8 i = 1; i < 8; i++)
-		{
-			BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
-		}
-		if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
-		{
-			BMS_SN[6] = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-			BMS_SN[7] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-			BMS_SN[8] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-			BMS_SN[9] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
-			BMS_SN[10] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
-			BMS_SN[11] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-			BMS_SN[12] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		}
-		BcuRxFlag[16] = 0x01;
-		break;
-	case 0x18E3D0F3:
-		BMS_Checksum = 0;
-		for (UINT8 i = 1; i < 8; i++)
-		{
-			BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
-		}
-		if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
-		{
-			BMS_SN[13] = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-			BMS_SN[14] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-			BMS_SN[15] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-			BMS_SN[16] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
-			BMS_SN[17] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
-			BMS_SN[18] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-			BMS_SN[19] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		}
-		BcuRxFlag[17] = 0x01;
-		break;
-	case 0x18E4D0F3:
-		BMS_Checksum = 0;
-		for (UINT8 i = 1; i < 8; i++)
-		{
-			BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
-		}
-		if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
-		{
-			BMS_SN[20] = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-			BMS_SN[21] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-			BMS_SN[22] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-			BMS_SN[23] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
-			BMS_SN[24] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
-			BMS_SN[25] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-			BMS_SN[26] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		}
-		BcuRxFlag[18] = 0x01;
-		break;
-	case 0x18E5D0F3:
-		BMS_BattRateCap = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
-		BMS_BattRateVolt = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
-		BMS_BattRateEngy = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
-		BMS_BattType = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xF);
-		BMS_CoolType = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x3);
-		BcuRxFlag[19] = 0x01;
-		break;
-	case 0x18E6D0F3:
-		BMS_CSC_Total = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		BMS_CellTotal = (UINT16)(((*(UINT8 *)(rawData + 1)) | (*(UINT8 *)(rawData + 2) << 8)) & 0xFFFF);
-		BMS_TempTotal = (UINT16)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8)) & 0xFFFF);
-		BMS_CellVoltLevel = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
-		BMS_CellMinVolt = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-		BMS_CellMaxVolt = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		BcuRxFlag[20] = 0x01;
-		break;
-	case 0x18F1D0F3:
-		BMS_TotalCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) |(*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalDisCharEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) |(*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
-		BMS_SingleCharEngy = (UINT16)(((*(UINT8 *)(rawData + 6)) |(*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
-		BcuRxFlag[21] = 0x01;
-		break;
-	case 0x18F2D0F3:
-		BMS_TotalBackCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalStaCharEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) |(*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
-		BcuRxFlag[22] = 0x01;
-		break;
-	case 0x18F3D0F3:
-		BMS_TotalGunCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalGunCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
-		BcuRxFlag[23] = 0x01;
-		break;
-	case 0x18F4D0F3:
-		BMS_TotalCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalDisCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
-		BMS_SingleCharCapy = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
-		BcuRxFlag[24] = 0x01;
-		break;
-	case 0x18F5D0F3:
-		BMS_TotalBackCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
-		BMS_TotalStaCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
-		BMS_HVBranNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-		BMS_SingleHVBranchCellNum = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		BcuRxFlag[25] = 0x01;
-		break;
-	case 0x18FF45F4:
-		BMS_ReqMode = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0x3);
-		BMS_HVCmd = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
-		BMS_ChgSts = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 4) & 0x3);
-		BMS_HVRelaySts = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 6) & 0x3);
-		BMS_HVVolt = (UINT16)(((*(UINT8 *)(rawData + 1)) | (*(UINT8 *)(rawData + 2) << 8)) & 0xFFFF);
-		BMS_SetTemp = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
-		BMS_Life = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
-		BMS_CRC = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		BcuRxFlag[26] = 0x01;
-		break;
-	case 0x18FFC13A:
-		TMS_WorkStatus = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0x3);
-		TMS_HVRelayST = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
-		TMS_OutletTemp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
-		TMS_InletTemp = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
-		TMS_ReqPow = (UINT16)(((*(UINT8 *)(rawData + 5)) | (*(UINT8 *)(rawData + 6) << 8)) & 0xFFFF);
-		TMS_ErrCode = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x3F);
-		TMS_FaultLevel = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 6) & 0x3);
-		BcuRxFlag[27] = 0x01;
-		break;
-	default:
-		break;
-	}
-}
-void BcuRxDiagnose(void)
-{
-	static UINT32 TimeCounter = 0;	// ms
-	TimeCounter = TimeCounter + 10; //
-	for (UINT8 i = 0; i < sizeof(BcuInTable) / 4; i++)
-	{
-		if (BcuRxFlag[i] == 1) // received msg, and clear the error conter
-		{
-			BcuRxErrorCounter[i] = 0;
-			BcuRxFlag[i] = 0;
-			continue;
-		}
-		if (BcuRxErrorCounter[i] < 3)
-		{
-			BcuRxShortError[i] = 0;
-			BcuRxLongError[i] = 0;
-		}
-		else if (BcuRxErrorCounter[i] >= 3 && BcuRxErrorCounter[i] < 13)
-		{
-			BcuRxShortError[i] = 1;
-			BcuRxLongError[i] = 0;
-		}
-		else if (BcuRxErrorCounter[i] >= 13)
-		{
-			BcuRxShortError[i] = 0;
-			BcuRxLongError[i] = 1;
-			BcuRxMsgSetInvalidValue(BcuInTable[i]);
-			BcuRxErrorCounter[i] = 0;
-		}
-		else if (BcuRxErrorCounter[i] == 0xFF)
-		{
-			BcuRxErrorCounter[i] = 0xFE;
-		}
-	}
-	if (TimeCounter % 100 == 0) // period <=100ms
-	{
-		BcuRxErrorCounter[0]++; // can msg 0x1801D0F3
-		// if(BcuRxErrorCounter[0]>=13)
-		BcuRxErrorCounter[2]++; // can msg 0x1880D0F3
-		// if(BcuRxErrorCounter[2]>=13)
-		BcuRxErrorCounter[3]++; // can msg 0x1881D0F3
-		// if(BcuRxErrorCounter[3]>=13)
-		BcuRxErrorCounter[4]++; // can msg 0x1882D0F3
-		// if(BcuRxErrorCounter[4]>=13)
-		BcuRxErrorCounter[5]++; // can msg 0x1883D0F3
-		// if(BcuRxErrorCounter[5]>=13)
-		BcuRxErrorCounter[6]++; // can msg 0x1884D0F3
-		// if(BcuRxErrorCounter[6]>=13)
-		BcuRxErrorCounter[7]++; // can msg 0x1885D0F3
-		// if(BcuRxErrorCounter[7]>=13)
-		BcuRxErrorCounter[8]++; // can msg 0x1886D0F3
-		// if(BcuRxErrorCounter[8]>=13)
-		BcuRxErrorCounter[9]++; // can msg 0x1887D0F3
-		// if(BcuRxErrorCounter[9]>=13)
-		BcuRxErrorCounter[10]++; // can msg 0x1888D0F3
-		// if(BcuRxErrorCounter[10]>=13)
-		BcuRxErrorCounter[13]++; // can msg 0x18C1D0F3
-		// if(BcuRxErrorCounter[13]>=13)
-		BcuRxErrorCounter[14]++; // can msg 0x18C2D0F3
-		// if(BcuRxErrorCounter[14]>=13)
-		BcuRxErrorCounter[19]++; // can msg 0x18E5D0F3
-		// if(BcuRxErrorCounter[19]>=13)
-		BcuRxErrorCounter[20]++; // can msg 0x18E6D0F3
-								 // if(BcuRxErrorCounter[20]>=13)
-	}
-	if (TimeCounter % 1000 == 0) // period ==1000ms
-	{
-		BcuRxErrorCounter[11]++; // can msg 0x1889D0F3
-		// if(BcuRxErrorCounter[11]>=13)
-		// printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[11]);
-		BcuRxErrorCounter[12]++; // can msg 0x188AD0F3
-		// if(BcuRxErrorCounter[12]>=13)
-		// printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[12]);
-		BcuRxErrorCounter[15]++; // can msg 0x18E1D0F3
-		// if(BcuRxErrorCounter[15]>=13)
-		// printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[15]);
-		BcuRxErrorCounter[16]++; // can msg 0x18E2D0F3
-		// if(BcuRxErrorCounter[16]>=13)
-		// printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[16]);
-		BcuRxErrorCounter[17]++; // can msg 0x18E3D0F3
-		// if(BcuRxErrorCounter[17]>=13)
-		// printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[17]);
-		BcuRxErrorCounter[18]++; // can msg 0x18E4D0F3
-		// if(BcuRxErrorCounter[18]>=13)
-		// printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[18]);
-		BcuRxErrorCounter[26]++; // can msg 0x18FF45F4
-		// if(BcuRxErrorCounter[26]>=13)
-		// printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[26]);
-		BcuRxErrorCounter[27]++; // can msg 0x18FFC13A
-								 // if(BcuRxErrorCounter[27]>=13)
-								 // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[27]);
-	}
-	if (TimeCounter % 30000 == 0) // period ==30000ms
-	{
-		BcuRxErrorCounter[1]++; // can msg 0x1801D8F3
-								// if(BcuRxErrorCounter[1]>=13)
-								// printf("can msg 0x%x lost,cycle time30000ms\n",COMInTable[1]);
-	}
-}
-void BcuRxMsgSetInvalidValue(UINT32 ID)
-{
-	switch (ID)
-	{
-	case 0x1801D0F3:
-		BMS_ReqVIN = 0xFF;
-		BMS_ReqHVOff = 0xFF;
-		break;
-	case 0x1801D8F3:
-		BMS_SoftwareVersion = 0xFFFF;
-		BMS_HardwareVersion = 0xFFFF;
-		BMS_ProtocolEditionH = 0xFF;
-		BMS_ProtocolEditionL = 0xFF;
-		break;
-	case 0x1880D0F3:
-		BMS_CharDevNum = 0xFF;
-		BMS_FtPosRly = 0xFF;
-		BMS_FtNegRly = 0xFF;
-		BMS_FtPosCharRly1 = 0xFF;
-		BMS_FtNegCharRly1 = 0xFF;
-		BMS_FtPosCharRly2 = 0xFF;
-		BMS_FtNegCharRly2 = 0xFF;
-		BMS_FtHeatRly1 = 0xFF;
-		BMS_FtHeatRly2 = 0xFF;
-		BMS_StPosRly = 0xFF;
-		BMS_StNegRly = 0xFF;
-		BMS_StPreCharRly = 0xFF;
-		BMS_StPosCharRly1 = 0xFF;
-		BMS_StNegCharRly1 = 0xFF;
-		BMS_StPosCharRly2 = 0xFF;
-		BMS_StNegCharRly2 = 0xFF;
-		BMS_FtAuxRelayWeld = 0xFF;
-		BMS_BraOpenCirc = 0xFF;
-		BMS_FtBackCharCurrOutLim = 0xFF;
-		BMS_FtPosRlyOpen = 0xFF;
-		BMS_FtNegRlyOpen = 0xFF;
-		BMS_FtPosCharRly1Open = 0xFF;
-		BMS_FtPosCharRly2Open = 0xFF;
-		BMS_FtNegCharRly1Open = 0xFF;
-		BMS_FtNegCharRly2Open = 0xFF;
-		BMS_FtTMSContClose = 0xFF;
-		BMS_FtTMSContOpen = 0xFF;
-		BMS_FtTMS = 0xFF;
-		BMS_Ft24VSpy = 0xFF;
-		BMS_FtPACKSelfProt = 0xFF;
-		BMS_FtCharSockTempOver = 0xFF;
-		BMS_FtTempOutCtrl = 0xFF;
-		BMS_StPosHeatRly = 0xFF;
-		BMS_StNegHeatRly = 0xFF;
-		BMS_CharSysNum = 0xFF;
-		BMS_FtCode = 0xFF;
-		break;
-	case 0x1881D0F3:
-		BMS_ST1CheckSum = 0xFF;
-		BMS_ST1Counter = 0xFF;
-		BMS_Mode = 0xFF;
-		BMS_AuxRlySt = 0xFF;
-		BMS_BattBalaSt = 0xFF;
-		BMS_CharGunSt = 0xFF;
-		BMS_CharMode = 0xFF;
-		BMS_CharSt = 0xFF;
-		BMS_FtLvl = 0xFF;
-		BMS_FtCellTempDiff = 0xFF;
-		BMS_FtCellTempHigh = 0xFF;
-		BMS_FtPACKOverVolt = 0xFF;
-		BMS_FtPACKUndeVolt = 0xFF;
-		BMS_FtSOCLow = 0xFF;
-		BMS_FtCellOverVolt = 0xFF;
-		BMS_FtCellUndeVolt = 0xFF;
-		BMS_FtIns = 0xFF;
-		BMS_FtCellOverVoltDiff = 0xFF;
-		BMS_FtCharCurrOver = 0xFF;
-		BMS_FtDisCharCurrOver = 0xFF;
-		BMS_FtCellTempLow = 0xFF;
-		BMS_FtBranVoltDifOver = 0xFF;
-		BMS_FtBMSHardWare = 0xFF;
-		BMS_FtSOCHigh = 0xFF;
-		BMS_FtSOCJump = 0xFF;
-		BMS_FtInCom = 0xFF;
-		BMS_FtSysMism = 0xFF;
-		BMS_FtHvIntLock = 0xFF;
-		BMS_FtSmoke = 0xFF;
-		BMS_FtFire = 0xFF;
-		BMS_FtNum = 0xFF;
-		break;
-	case 0x1882D0F3:
-		BMS_PackSOC = 0xFF;
-		BMS_PackSOH = 0xFF;
-		BMS_PackCurr = 0xFFFF;
-		BMS_MaxCharCurr = 0xFFFF;
-		BMS_MaxDisCharCurr = 0xFFFF;
-		break;
-	case 0x1883D0F3:
-		BMS_PosIns = 0xFFFF;
-		BMS_NegIns = 0xFFFF;
-		BMS_BattVolt = 0xFFFF;
-		BMS_LinkVolt = 0xFFFF;
-		break;
-	case 0x1884D0F3:
-		BMS_MaxCellTemp = 0xFF;
-		BMS_MinCellTemp = 0xFF;
-		BMS_AverCellTemp = 0xFF;
-		BMS_MaxCellTempCSC = 0xFF;
-		BMS_MaxCellTempNum = 0xFF;
-		BMS_MinCellTempCSC = 0xFF;
-		BMS_MinCellTempNum = 0xFF;
-		break;
-	case 0x1885D0F3:
-		BMS_MaxCellVolt = 0xFFFF;
-		BMS_MaxCellVoltCSC = 0xFF;
-		BMS_MaxCellVoltNum = 0xFF;
-		BMS_AverCellVolt = 0xFFFF;
-		break;
-	case 0x1886D0F3:
-		BMS_MinCellVolt = 0xFFFF;
-		BMS_MinCellVoltCSC = 0xFF;
-		BMS_MinCellVoltNum = 0xFF;
-		BMS_ContChrgCurr = 0xFFFF;
-		BMS_ContDisCharCurr = 0xFFFF;
-		break;
-	case 0x1887D0F3:
-		BMS_CharReqVolt = 0xFFFF;
-		BMS_CharReqCurr = 0xFFFF;
-		BMS_SysInsRes = 0xFFFF;
-		BMS_InsDeteSt = 0xFF;
-		BMS_FtCharInsLow = 0xFF;
-		BMS_FtCurrSenr = 0xFF;
-		BMS_FtHeatingFilm = 0xFF;
-		BMS_FtMainLoopPreChar = 0xFF;
-		BMS_FtAuxLoopPreChar = 0xFF;
-		BMS_FtACANLost = 0xFF;
-		BMS_FtDCDC = 0xFF;
-		BMS_FtSOCDif = 0xFF;
-		BMS_FtCellOverDisChar = 0xFF;
-		BMS_FtCharOver = 0xFF;
-		BMS_FtContDisCharCurrOverLoad = 0xFF;
-		BMS_FtContCharCurrOverLoad = 0xFF;
-		break;
-	case 0x1888D0F3:
-		BMS_MaxDisCharPwr = 0xFFFF;
-		BMS_MaxCharPwr = 0xFFFF;
-		BMS_ContDisCharPwr = 0xFFFF;
-		BMS_ContCharPwr = 0xFFFF;
-		break;
-	case 0x1889D0F3:
-		BMS_InstEngyCons = 0xFFFF;
-		BMS_TotalEngyCons = 0xFFFF;
-		BMS_SOE = 0xFFFF;
-		BMS_RmanCharTime = 0xFFFF;
-		break;
-	case 0x188AD0F3:
-		BMS_Gun1DCNegTemp = 0xFF;
-		BMS_Gun1DCPosTemp = 0xFF;
-		BMS_Gun2DCNegTemp = 0xFF;
-		BMS_Gun2DCPosTemp = 0xFF;
-		BMS_CurrHeatSt = 0xFF;
-		BMS_CurrCoolSt = 0xFF;
-		BMS_FtCharCnct = 0xFF;
-		BMS_FtOverDisCharCurrDuringChar = 0xFF;
-		BMS_FtCharNTC = 0xFF;
-		BMS_FtELock = 0xFF;
-		BMS_CharNum = 0xFFFF;
-		break;
-	case 0x18C1D0F3:
-		BMS_CellVoltFramNum = 0xFF;
-		for (UINT16 i = 0; i < sizeof(BMS_CellVolt) / 2; i++)
-		{
-			BMS_CellVolt[i] = 0xFFFF;
-		}
-		break;
-	case 0x18C2D0F3:
-		BMS_CellTempFramNum = 0xFF;
-		BMS_CSC_Code = 0xFF;
-		for (UINT8 i = 0; i < sizeof(BMS_CellTemp); i++)
-		{
-			BMS_CellTemp[i] = 0xFF;
-		}
-		break;
-	case 0x18E1D0F3:
-		BMS_Checksum = 0xFF;
-		BMS_PackComp = 0xFF;
-		BMS_BattCodeLeng = 0xFF;
-		BMS_SN[0] = 0xFF;
-		BMS_SN[1] = 0xFF;
-		BMS_SN[2] = 0xFF;
-		BMS_SN[3] = 0xFF;
-		BMS_SN[4] = 0xFF;
-		BMS_SN[5] = 0xFF;
-		break;
-	case 0x18E2D0F3:
-		BMS_Checksum = 0xFF;
-		BMS_SN[6] = 0xFF;
-		BMS_SN[7] = 0xFF;
-		BMS_SN[8] = 0xFF;
-		BMS_SN[9] = 0xFF;
-		BMS_SN[10] = 0xFF;
-		BMS_SN[11] = 0xFF;
-		BMS_SN[12] = 0xFF;
-		break;
-	case 0x18E3D0F3:
-		BMS_Checksum = 0xFF;
-		BMS_SN[13] = 0xFF;
-		BMS_SN[14] = 0xFF;
-		BMS_SN[15] = 0xFF;
-		BMS_SN[16] = 0xFF;
-		BMS_SN[17] = 0xFF;
-		BMS_SN[18] = 0xFF;
-		BMS_SN[19] = 0xFF;
-		break;
-	case 0x18E4D0F3:
-		BMS_Checksum = 0xFF;
-		BMS_SN[20] = 0xFF;
-		BMS_SN[21] = 0xFF;
-		BMS_SN[22] = 0xFF;
-		BMS_SN[23] = 0xFF;
-		BMS_SN[24] = 0xFF;
-		BMS_SN[25] = 0xFF;
-		BMS_SN[26] = 0xFF;
-		break;
-	case 0x18E5D0F3:
-		BMS_BattRateCap = 0xFFFF;
-		BMS_BattRateVolt = 0xFFFF;
-		BMS_BattRateEngy = 0xFFFF;
-		BMS_BattType = 0xFF;
-		BMS_CoolType = 0xFF;
-		break;
-	case 0x18E6D0F3:
-		BMS_CSC_Total = 0xFF;
-		BMS_CellTotal = 0xFFFF;
-		BMS_TempTotal = 0xFFFF;
-		BMS_CellVoltLevel = 0xFF;
-		BMS_CellMinVolt = 0xFF;
-		BMS_CellMaxVolt = 0xFF;
-		break;
-	case 0x18F1D0F3:
-		BMS_TotalCharEngy = 0xFFFFFFFF;
-		BMS_TotalDisCharEngy = 0xFFFFFFFF;
-		BMS_SingleCharEngy = 0xFFFF;
-		break;
-	case 0x18F2D0F3:
-		BMS_TotalBackCharEngy = 0xFFFFFFFF;
-		BMS_TotalStaCharEngy = 0xFFFFFFFF;
-		break;
-	case 0x18F3D0F3:
-		BMS_TotalGunCharEngy = 0xFFFFFFFF;
-		BMS_TotalGunCharCapy = 0xFFFFFFFF;
-		break;
-	case 0x18F4D0F3:
-		BMS_TotalCharCapy = 0xFFFFFFFF;
-		BMS_TotalDisCharCapy = 0xFFFFFFFF;
-		BMS_SingleCharCapy = 0xFFFF;
-		break;
-	case 0x18F5D0F3:
-		BMS_TotalBackCharCapy = 0xFFFFFFFF;
-		BMS_TotalStaCharCapy = 0xFFFFFFFF;
-		BMS_HVBranNum = 0xFF;
-		BMS_SingleHVBranchCellNum = 0xFF;
-		break;
-	case 0x18FF45F4:
-		BMS_ReqMode = 0xFF;
-		BMS_HVCmd = 0xFF;
-		BMS_ChgSts = 0xFF;
-		BMS_HVRelaySts = 0xFF;
-		BMS_HVVolt = 0xFFFF;
-		BMS_SetTemp = 0xFF;
-		BMS_Life = 0xFF;
-		BMS_CRC = 0xFF;
-		break;
-	case 0x18FFC13A:
-		TMS_WorkStatus = 0xFF;
-		TMS_HVRelayST = 0xFF;
-		TMS_OutletTemp = 0xFF;
-		TMS_InletTemp = 0xFF;
-		TMS_ReqPow = 0xFFFF;
-		TMS_ErrCode = 0xFF;
-		TMS_FaultLevel = 0xFF;
-		break;
-	default:
-		break;
-	}
-}
-void BcuEncodeFunction(UINT32 ID, UINT8 *rawData)
-{
-	switch (ID)
-	{
-	case 0x18FFF8A7:
-	{
-		EBC_Counter = EBC_Counter + 1;
-		if (EBC_Counter > 15)
-		{
-			EBC_Counter = 0;
-		}
-		EBC_CharCnctSt = m_flg_HVlock1;
-		EBC_DisCharCnctSt = m_flg_HVlock2;
-		EBC_CnctSt = (m_flg_HVlock1 && m_flg_HVlock2);
-		if (ebcd_st_lockSucJug == 1)
-		{
-			EBC_LockSt = 2;
-		}
-		else if (ebcd_st_unlockSucJug == 1)
-		{
-			EBC_LockSt = 1;
-		}
-		else
-		{
-			EBC_LockSt = 0;
-		}
-		EBC_State = ebcd_st_ebcWork;
-		EBC_AirPressure = ebcd_P_airSensor;
-		UINT16 ErrTemp = 0;
-		ErrTemp = GetErrorNum(ErrArray, sizeof(ErrArray) / 2);
-		EBC_FtLvl = ErrTemp / 10000;
-		EBC_FtCode = ErrTemp % 10000;
-
-		/*Test*/
-		EBC_LockSt = 0x02;
-		EBC_CnctSt = 0x01;
-		EBC_DisCharCnctSt = 0x01;
-		EBC_CharCnctSt = 0x01;
-		*(rawData + 0) = EBC_Counter;
-		*(rawData + 1) = (EBC_CharCnctSt << 6) | (EBC_DisCharCnctSt << 4) | (EBC_CnctSt << 2) | (EBC_LockSt);
-		*(rawData + 2) = 0x00;
-		*(rawData + 3) = EBC_FtLvl;
-		*(rawData + 4) = EBC_FtCode;
-		*(rawData + 5) = 0x00;
-		*(rawData + 6) = EBC_AirPressure;
-		*(rawData + 7) = ((EBC_State << 5) & 0x03) | ((EBC_StopChgCmd << 4) & 0x01) | ((EBC_ReqHVOff << 3) & 0x01) | ((EBC_InhiHVOn << 2) & 0x01) | ((EBC_ActHeatReq << 1) & 0x01) | ((EBC_CharSt)&0x01);
-		break;
-	}
-	case 0x18FEF8A7:
-	{
-		EBC_DisCharPos1Temp = ebcd_T_plugin[0];
-		EBC_DischarNeg1Temp = ebcd_T_plugin[1];
-		EBC_DisCharPos2Temp = ebcd_T_plugin[2];
-		EBC_DisCharNeg2Temp = ebcd_T_plugin[3];
-		*(rawData + 0) = EBC_DisCharPos1Temp;
-		*(rawData + 1) = EBC_DischarNeg1Temp;
-		*(rawData + 2) = EBC_DisCharPos2Temp;
-		*(rawData + 3) = EBC_DisCharNeg2Temp;
-		*(rawData + 4) = EBC_ChgPos1Temp;
-		*(rawData + 5) = EBC_ChgNeg1Temp;
-		*(rawData + 6) = EBC_ChgPos2Temp;
-		*(rawData + 7) = EBC_ChgNeg2Temp;
-		break;
-	}
-	default:
-		break;
-	}
-}

+ 0 - 14
System/Vehicle/Communication/BcuCanProtocolFunc.h

@@ -1,14 +0,0 @@
-/*
- * @Author       : ChenJie
- * @Date         : 2021-12-22 17:09:09
- * @Version      : V3.0
- * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-27 16:10:50
- * @Description  : file content
- * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\BcuCanProtocolFunc.h
- */
-#include "CanVar.h"
-void BcuDecodeFunction(UINT32 ID, UINT8 *rawData);
-void BcuRxDiagnose(void);
-void BcuRxMsgSetInvalidValue(UINT32 ID);
-void BcuEncodeFunction(UINT32 ID, UINT8 *rawData);

+ 0 - 1020
System/Vehicle/Communication/BleCanProtocolFunc.c

@@ -1,1020 +0,0 @@
-/*
- * @Author       : ChenJie
- * @Date         : 2021-12-20 14:47:39
- * @Version      : V3.0
- * @LastEditors  : ChenJie
- * @LastEditTime : 2022-05-09 17:13:09
- * @Description  : file content
- * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\BleCanProtocolFunc.c
- */
-/*
- * CanProtocol.c
- * can协议转换
- *  Created on: 2021年12月20日
- *      Author: QiXiang_CHENJIE
- */
-#include "BleCanProtocolFunc.h"
-#include "HardwareLib.h"
-/**
- * @brief : EBC对ble的命令应答,AT指令,EBC(0x1CEE000X)->BLE(0x1CEF0000X)
- * @param {uint8} CmdIdx
- * @return {*}
- */
-void Can2ProtocolCode(uint8 CmdIdx, uint8 DataIdx, uint8 Byte0Num, uint32 *InnerCanID, uint8 *Data)
-{
-    uint8 BlePwrControl;       //蓝牙电源开关控制  FF-关闭,0A-打开
-    uint8 BlePwrControl_Flag;  //蓝牙电源开关控制使能  00-不控制,01-控制
-    uint8 BleRoleControl;      //蓝牙主从控制  01-主机,02-从机
-    uint8 BleRoleControl_Flag; //蓝牙主从控制使能  00-不控制,01-控制
-    uint8 BleName[8];
-    //上述变量下线检测时调用修改
-
-    // CmdIdx EBC对BLE命令列表
-    switch (CmdIdx)
-    {
-    case 0x00: // ebc->ble数据传输通道
-    {
-        Can2DataCode(DataIdx, Byte0Num, Data);
-        *InnerCanID = 0x1CEE0000;
-        break;
-    }
-    case 0x01: //查询BLE软件版本
-    {
-        Data[0] = 0x01;
-        Data[1] = 0x00;
-        Data[2] = 0x00;
-        Data[3] = 0x00;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        *InnerCanID = 0x1CEE0001;
-        break;
-    }
-    case 0x02: //查询BLE连接状态
-    {
-        Data[0] = 0x01;
-        Data[1] = 0x00;
-        Data[2] = 0x00;
-        Data[3] = 0x00;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        *InnerCanID = 0x1CEE0002;
-        break;
-    }
-    case 0x03: //让BLE断开连接
-    {
-        Data[0] = 0x02;
-        Data[1] = 0x00;
-        Data[2] = 0x00;
-        Data[3] = 0x00;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        *InnerCanID = 0x1CEE0003;
-        break;
-    }
-    case 0x04: //改无线设备名称 名称为ASCII码值
-    {
-        Data[0] = BleName[0];
-        Data[1] = BleName[1];
-        Data[2] = BleName[2];
-        Data[3] = BleName[3];
-        Data[4] = BleName[4];
-        Data[5] = BleName[5];
-        Data[6] = BleName[6];
-        Data[7] = BleName[7];
-        *InnerCanID = 0x1CEE0004;
-        break;
-    }
-    case 0x05: // BLE设备蓝牙开关查询及控制,默认为查询
-    {
-        if (BlePwrControl_Flag)
-        {
-            Data[0] = 0x02;
-            Data[1] = BlePwrControl;
-        }
-        else
-        {
-            Data[0] = 0x01;
-            Data[1] = 0x00;
-        }
-        Data[2] = 0x00;
-        Data[3] = 0x00;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        *InnerCanID = 0x1CEE0005;
-        break;
-    }
-    case 0x06: // BLE 主从机切换及查询,默认为查询
-    {
-        if (BleRoleControl_Flag)
-        {
-            Data[0] = 0x02;
-            Data[1] = BleRoleControl;
-        }
-        else
-        {
-            Data[0] = 0x01;
-            Data[1] = 0x00;
-        }
-        Data[2] = 0x00;
-        Data[3] = 0x00;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        *InnerCanID = 0x1CEE0006;
-        break;
-    }
-    default:
-        break;
-    }
-}
-/**
- * @brief : ebc对ble的数据应答,Ebc data ->Ble data
- * @param {*}
- * @return {*}
- */
-void Can2DataCode(uint8 DataIdx, uint8 Byte0Num, uint8 Data[])
-{
-    switch (DataIdx)
-    {
-    case 0x01: //主机数据类型1的应答
-    {
-        Data[0] = 0x11;
-        Data[1] = ebcd_st_ebcWork;
-        Data[2] = ebcd_st_ebcConnect;
-        Data[3] = ebcd_st_ebcLockWork;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        break;
-    }
-    case 0x02: //主机数据类型2的应答 共7条
-    {
-        switch (Byte0Num)
-        {
-        case 0x21:
-        {
-            vcud_st_keyOn = BattCD_stWakeupU.B.bLogic;
-            bcud_st_bcuTmsLiquid = 0; // TBD
-            ebcd_flg_pluginLockSig = m_flg_HVlock1 && m_flg_HVlock2;
-            Data[0] = Byte0Num;
-            Data[1] = ebcd_st_unlockSensor;
-            Data[2] = ebcd_st_lockSensor;
-            Data[3] = vcud_st_keyOn;
-            Data[4] = ebcd_P_airSensor;
-            Data[5] = bcud_st_bcuTmsLiquid;
-            Data[6] = ebcd_flg_pluginLockSig;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x22:
-        {
-            ebcd_st_pluginLockSig = (m_flg_HVlock2 << 2) | (m_flg_HVlock1 << 1) | (m_flg_HVlock1 << 1);
-            Data[0] = Byte0Num;
-            Data[1] = 0x00;
-            Data[2] = 0x00;
-            Data[3] = 0x00;
-            Data[4] = 0x00;
-            Data[5] = ebcd_st_pedstSensor;
-            Data[6] = ebcd_st_pluginLockSig;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x23:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = ebcd_st_unlockSucJug;
-            Data[2] = ebcd_st_lockSucJug;
-            Data[3] = 0x00;
-            Data[4] = 0x00;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x24:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = 0x00;
-            Data[2] = 0x00;
-            Data[3] = 0x00;
-            Data[4] = 0x00;
-            Data[5] = ebcd_st_pedstSucJug;
-            Data[6] = ebcd_flg_swapAdmit;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x25:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = ebcd_st_ebcWork;
-            Data[2] = ebcd_st_ebcConnect;
-            Data[3] = ebcd_st_ebcLockWork;
-            Data[4] = ebcd_Nr_errMax;
-            Data[5] = ebcd_Num_err1;
-            Data[6] = ebcd_Num_err2;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x26:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (ebcd_Nr_swapBatt >> 8) & 0xFF;
-            Data[2] = ebcd_Nr_swapBatt & 0xFF;
-            Data[3] = (ebcd_Nr_swapSucBatt >> 8) & 0xFF;
-            Data[4] = ebcd_Nr_swapSucBatt;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x27:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = ebcd_st_errTable1;
-            Data[2] = ebcd_st_errTable2;
-            Data[3] = ebcd_st_errTable3;
-            Data[4] = 0x00;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        default:
-            break;
-        }
-        break;
-    }
-    case 0x03: //主机数据类型3的应答 共5条
-    {
-        vcud_st_handbrake = VCU_St_ParkBrakeSw;
-        vcud_st_footbrake = (VCU_St_BrakePedal > 0);
-        vcud_st_gear = VCU_St_Gear;
-        vcud_st_vcuComun = (VcuRxLongError[0] != 1);
-        vcud_st_carStart = VCU_State_Veh;
-        vcud_st_Steer = 0x00;   // TBD
-        vcud_M_accDrv = 0 * 10; // TBD
-        if (VCU_St_VinRecv == 0x07)
-        {
-            memcpy(vcuv_Num_vin, VCU_Num_VIN, 17);
-        }
-        switch (Byte0Num)
-        {
-        case 0x31:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = vcud_st_handbrake;
-            Data[2] = vcud_st_footbrake;
-            Data[3] = vcud_st_gear;
-            Data[4] = vcud_st_vcuComun;
-            Data[5] = vcud_st_carStart;
-            Data[6] = vcud_st_Steer;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x32:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = vcuv_Num_vin[0];
-            Data[2] = vcuv_Num_vin[1];
-            Data[3] = vcuv_Num_vin[2];
-            Data[4] = vcuv_Num_vin[3];
-            Data[5] = vcuv_Num_vin[4];
-            Data[6] = vcuv_Num_vin[5];
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x33:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = vcuv_Num_vin[6];
-            Data[2] = vcuv_Num_vin[7];
-            Data[3] = vcuv_Num_vin[8];
-            Data[4] = vcuv_Num_vin[9];
-            Data[5] = vcuv_Num_vin[10];
-            Data[6] = vcuv_Num_vin[11];
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x34:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = vcuv_Num_vin[12];
-            Data[2] = vcuv_Num_vin[13];
-            Data[3] = vcuv_Num_vin[14];
-            Data[4] = vcuv_Num_vin[15];
-            Data[5] = vcuv_Num_vin[16];
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x35:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (vcud_M_accDrv >> 24) & 0xFF;
-            Data[2] = (vcud_M_accDrv >> 16) & 0xFF;
-            Data[3] = (vcud_M_accDrv >> 8) & 0xFF;
-            Data[4] = (vcud_M_accDrv)&0xFF;
-            Data[5] = vcud_P_airSensorForward;
-            Data[6] = vcud_P_airSensorBack;
-            Data[7] = 0x00;
-            break;
-        }
-        default:
-            break;
-        }
-        break;
-    }
-    case 0x04: //主机数据类型4的应答 共16条
-    {
-        bcud_st_bcuComun = (BcuRxLongError[4] != 0x01);
-        bcud_pct_bcuSoh = BMS_PackSOH;
-        bcud_V_battU = BMS_BattVolt;
-        if (BMS_Mode == 2)
-        {
-            bcud_st_hvWork = 2;
-        }
-        else if (BMS_Mode == 1)
-        {
-            bcud_st_hvWork = 0;
-        }
-        else
-        {
-            bcud_st_hvWork = 3;
-        }
-        bcud_st_bcuMainRelay = BMS_StPosRly;
-        bcud_pct_soc = (UINT16)(BMS_PackSOC * 4);
-        memcpy(bcuv_Num_battSn, BMS_SN, sizeof(BMS_SN));
-        bcud_Q_snglChrg = BMS_SingleCharCapy;
-        bcud_E_snglChrg = BMS_SingleCharEngy;
-        bcud_Q_accRecovry = BMS_TotalBackCharCapy;
-        bcud_E_accRecovry = BMS_TotalBackCharEngy;
-        bcud_Q_accSwapBatt = BMS_TotalStaCharCapy;
-        bcud_E_accSwapBatt = BMS_TotalStaCharEngy;
-        bcud_Q_accPlugInChrg = BMS_TotalGunCharCapy;
-        bcud_E_accPlugInChrg = BMS_TotalGunCharEngy;
-        bcud_Q_accDischrg = BMS_TotalDisCharCapy;
-        bcud_E_accDischrg = BMS_TotalDisCharEngy;
-        bcud_Q_accChrg = BMS_TotalCharCapy;
-        bcud_E_accChrg = BMS_TotalCharEngy;
-        switch (Byte0Num)
-        {
-        case 0x40:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_E_accPlugInChrg >> 24) & 0xFF;
-            Data[2] = (bcud_E_accPlugInChrg >> 16) & 0xFF;
-            Data[3] = (bcud_E_accPlugInChrg >> 8) & 0xFF;
-            Data[4] = (bcud_E_accPlugInChrg)&0xFF;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x41:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_Q_accChrg >> 24) & 0xFF;
-            Data[2] = (bcud_Q_accChrg >> 16) & 0xFF;
-            Data[3] = (bcud_Q_accChrg >> 8) & 0xFF;
-            Data[4] = (bcud_Q_accChrg)&0xFF;
-            Data[5] = bcud_st_bcuComun;
-            Data[6] = bcud_st_hvWork;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x42:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_Q_accDischrg >> 24) & 0xFF;
-            Data[2] = (bcud_Q_accDischrg >> 16) & 0xFF;
-            Data[3] = (bcud_Q_accDischrg >> 8) & 0xFF;
-            Data[4] = (bcud_Q_accDischrg)&0xFF;
-            Data[5] = bcud_st_bcuMainRelay;
-            Data[6] = bcud_pct_bcuSoh;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x43:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_E_accChrg >> 24) & 0xFF;
-            Data[2] = (bcud_E_accChrg >> 16) & 0xFF;
-            Data[3] = (bcud_E_accChrg >> 8) & 0xFF;
-            Data[4] = (bcud_E_accChrg)&0xFF;
-            Data[5] = (bcud_V_battU >> 8) & 0xFF;
-            Data[6] = (bcud_V_battU)&0xFF;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x44:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_E_accDischrg >> 24) & 0xFF;
-            Data[2] = (bcud_E_accDischrg >> 16) & 0xFF;
-            Data[3] = (bcud_E_accDischrg >> 8) & 0xFF;
-            Data[4] = (bcud_E_accDischrg)&0xFF;
-            Data[5] = (bcud_pct_soc >> 8) & 0xFF;
-            Data[6] = (bcud_pct_soc)&0xFF;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x45:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = bcuv_Num_battSn[0];
-            Data[2] = bcuv_Num_battSn[1];
-            Data[3] = bcuv_Num_battSn[2];
-            Data[4] = bcuv_Num_battSn[3];
-            Data[5] = bcuv_Num_battSn[4];
-            Data[6] = bcuv_Num_battSn[5];
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x46:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = bcuv_Num_battSn[6];
-            Data[2] = bcuv_Num_battSn[7];
-            Data[3] = bcuv_Num_battSn[8];
-            Data[4] = bcuv_Num_battSn[9];
-            Data[5] = bcuv_Num_battSn[10];
-            Data[6] = bcuv_Num_battSn[11];
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x47:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = bcuv_Num_battSn[12];
-            Data[2] = bcuv_Num_battSn[13];
-            Data[3] = bcuv_Num_battSn[14];
-            Data[4] = bcuv_Num_battSn[15];
-            Data[5] = bcuv_Num_battSn[16];
-            Data[6] = bcuv_Num_battSn[17];
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x48:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = bcuv_Num_battSn[18];
-            Data[2] = bcuv_Num_battSn[19];
-            Data[3] = bcuv_Num_battSn[20];
-            Data[4] = bcuv_Num_battSn[21];
-            Data[5] = bcuv_Num_battSn[22];
-            Data[6] = bcuv_Num_battSn[23];
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x49:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = bcuv_Num_battSn[24];
-            Data[2] = bcuv_Num_battSn[25];
-            Data[3] = bcuv_Num_battSn[26];
-            Data[4] = bcuv_Num_battSn[27];
-            Data[5] = bcuv_Num_battSn[28];
-            Data[6] = bcuv_Num_battSn[29];
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x4A:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = bcuv_Num_battSn[30];
-            Data[2] = bcuv_Num_battSn[31];
-            Data[3] = 0x00;
-            Data[4] = 0x00;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x4B:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_Q_snglChrg >> 8) & 0xFF;
-            Data[2] = (bcud_Q_snglChrg)&0xFF;
-            Data[3] = (bcud_Q_accRecovry >> 24) & 0xFF;
-            Data[4] = (bcud_Q_accRecovry >> 16) & 0xFF;
-            Data[5] = (bcud_Q_accRecovry >> 8) & 0xFF;
-            Data[6] = (bcud_Q_accRecovry)&0xFF;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x4C:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_Q_accSwapBatt >> 24) & 0xFF;
-            Data[2] = (bcud_Q_accSwapBatt >> 16) & 0xFF;
-            Data[3] = (bcud_Q_accSwapBatt >> 8) & 0xFF;
-            Data[4] = (bcud_Q_accSwapBatt)&0xFF;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x4D:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_E_snglChrg >> 8) & 0xFF;
-            Data[2] = (bcud_E_snglChrg)&0xFF;
-            Data[3] = (bcud_E_accRecovry >> 24) & 0xFF;
-            Data[4] = (bcud_E_accRecovry >> 16) & 0xFF;
-            Data[5] = (bcud_E_accRecovry >> 8) & 0xFF;
-            Data[6] = (bcud_E_accRecovry)&0xFF;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x4E:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_E_accSwapBatt >> 24) & 0xFF;
-            Data[2] = (bcud_E_accSwapBatt >> 16) & 0xFF;
-            Data[3] = (bcud_E_accSwapBatt >> 8) & 0xFF;
-            Data[4] = (bcud_E_accSwapBatt)&0xFF;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        case 0x4F:
-        {
-            Data[0] = Byte0Num;
-            Data[1] = (bcud_Q_accPlugInChrg >> 24) & 0xFF;
-            Data[2] = (bcud_Q_accPlugInChrg >> 16) & 0xFF;
-            Data[3] = (bcud_Q_accPlugInChrg >> 8) & 0xFF;
-            Data[4] = (bcud_Q_accPlugInChrg)&0xFF;
-            Data[5] = 0x00;
-            Data[6] = 0x00;
-            Data[7] = 0x00;
-            break;
-        }
-        default:
-            break;
-        }
-        break;
-    }
-    case 0x05:
-    {
-        Data[0] = 0x51;
-        Data[1] = 0x00;
-        Data[2] = 0x00;
-        Data[3] = 0x00;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        break;
-    }
-    default:
-        Data[0] = 0x00;
-        Data[1] = 0x00;
-        Data[2] = 0x00;
-        Data[3] = 0x00;
-        Data[4] = 0x00;
-        Data[5] = 0x00;
-        Data[6] = 0x00;
-        Data[7] = 0x00;
-        break;
-    }
-}
-
-/**
- * @brief : Ebc通过Can2接受到的协议解码
- * @param {uint8} CmdIdx
- * @return {*}
- */
-void Can2ProtocolDecode(uint32 Can2ID, uint8 Data[])
-{
-    switch (Can2ID)
-    {
-    case 0x1CEF0000:
-    {
-        Can2DataDecode(Data);
-        bled_flg_bleConn = 1;
-        bled_flg_bleDisconn = 0;
-        bled_st_dataTrans = 1;
-        break;
-    }
-    case 0x1CEF0001:
-    {
-        bled_Nr_softVer = (Data[0] << 24) | (Data[1] << 16) | (Data[2] << 8) | (Data[3]);
-        break;
-    }
-    case 0x1CEF0002:
-    {
-        if (Data[0] == 0x01 && Data[1] == 0x01)
-        {
-            bled_flg_bleConn = 1;
-            bled_flg_bleDisconn = 0;
-        }
-        else if (Data[0] == 0x01 && Data[1] == 0x02)
-        {
-            bled_flg_bleConn = 0;
-            bled_flg_bleDisconn = 1;
-        }
-        break;
-    }
-    case 0x1C00ECEA: // UDS检测ID
-    {
-        Uds_Service(Data);
-        break;
-    }
-    default:
-        break;
-    }
-}
-/**
- * @brief : Ebc通过can2接收到的数据解码,Ble->Ebc
- * @param {*}
- * @return {*}
- */
-void Can2DataDecode(uint8 Data[])
-{
-    uint8 CmdIndex = Data[0];
-    ebcd_st_toBleAns = CmdIndex;
-    ebcd_flg_Can2SendEnbale = TRUE; //所有的信息均立即回复
-    switch (CmdIndex)
-    {
-    case 0x01: //心跳数据,为了维持通讯
-    {
-        bled_flg_Heart = 1;
-        ebcd_flg_Can2SendEnbale = TRUE;
-        break;
-    }
-    case 0x02: //获取换电控制器信息
-    {
-        bled_flg_getEbcData = 1;
-        ebcd_flg_Can2SendEnbale = TRUE;
-        break;
-    }
-    case 0x03: //获得车辆信息
-    {
-        bled_flg_getVcuData = 1;
-        ebcd_flg_Can2SendEnbale = TRUE;
-        break;
-    }
-    case 0x04: //获取电池信息
-    {
-        bled_flg_getBmsData = 1;
-        ebcd_flg_Can2SendEnbale = TRUE;
-        break;
-    }
-    case 0x05: //握手
-    {
-        bled_flg_handShake = 1;
-        ebcd_flg_Can2SendEnbale = TRUE;
-        break;
-    }
-    case 0x06: //解锁
-    {
-        bled_flg_unlockCmd = Data[1];
-        bled_flg_lockCmd = 0;
-        break;
-    }
-    case 0x07: //锁紧
-    {
-        bled_flg_lockCmd = Data[1];
-        bled_flg_unlockCmd = 0;
-        break;
-    }
-    case 0x08: //完成换电
-    {
-        bled_flg_swapBattDone = 1;
-        break;
-    }
-    case 0x09: //强制解锁,强制上升
-    {
-        bled_flg_unlockCmdForce = Data[1];
-        bled_flg_topAscendCmdForce = Data[2];
-        break;
-    }
-    case 0x0A: //强制锁紧,强制下降
-    {
-        bled_flg_lockCmdForce = Data[1];
-        bled_flg_topDescendCmdForce = Data[2];
-        break;
-    }
-    case 0x0B: //回到行车状态
-    {
-        bled_flg_backToDrv = 1;
-        break;
-    }
-    case 0x0C: //顶板举升
-    {
-        bled_flg_topAscendCmd = Data[1];
-        break;
-    }
-    case 0x0D: //顶板下降
-    {
-        bled_flg_topDescendCmd = Data[1];
-        break;
-    }
-    case 0x0E: //换电开始自动解锁
-    {
-        bled_flg_autoUnlock = 1;
-        break;
-    }
-    case 0x0F: //换电完成自动锁紧
-    {
-        bled_flg_autoLock = 1;
-        break;
-    }
-    case 0x10: //除尘开始
-    {
-        bled_flg_openDustReCmd = 1;
-        break;
-    }
-    case 0x11: //除尘关闭
-    {
-        bled_flg_closeDustReCmd = 1;
-        break;
-    }
-    case 0x12: //切换到无线通信状态
-    {
-        break;
-    }
-    case 0x13: //进入换电状态
-    {
-        bled_flg_toSwapMod = 1;
-        break;
-    }
-    case 0x14: //急停指令
-    {
-        bled_flg_safeStopCmd = 1;
-        break;
-    } //新增需要改数组
-    default:
-        break;
-    }
-}
-static uint8 udsMode = 0; // uds 模式
-uint32 EbcAppSw = 0x00000101;
-void Uds_Service(uint8 *Data)
-{
-    UdsAnsType UdsAns;
-    memset((uint8 *)&UdsAns, 0x00, sizeof(UdsAns));
-    UdsAns.UdsSer = *(Data + 0);
-    UdsAns.UdsSubSer = *(Data + 1);
-    switch (UdsAns.UdsSer)
-    {
-    case 0x10: //模式选择
-    {
-        if (*(Data + 1) == 0x01)
-        {
-            udsMode = 1;
-            UdsPosAns(UdsAns);
-        }
-        else if (*(Data + 1) == 0x02)
-        {
-            if (udsMode == 1 || udsMode == 2)
-            {
-                udsMode = 2;
-                UdsPosAns(UdsAns);
-            }
-            else
-            {
-                udsMode = 0;
-                UdsNegAns(UdsAns);
-            }
-        }
-        else
-        {
-            udsMode = 0;
-            UdsNegAns(UdsAns);
-        }
-        break;
-    }
-    case 0x22: //查询
-    {
-        if (udsMode == 2)
-        {
-            switch (UdsAns.UdsSubSer)
-            {
-            case 0x01: //版本号查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = EbcAppSw >> 24;
-                UdsAns.Data2 = EbcAppSw >> 16;
-                UdsAns.Data3 = EbcAppSw >> 8;
-                UdsAns.Data4 = EbcAppSw;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x02: //解锁状态查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = ebcd_st_unlockSensor;
-                UdsAns.Data2 = 0x00;
-                UdsAns.Data3 = 0x00;
-                UdsAns.Data4 = 0x00;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x03: //锁紧状态查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = ebcd_st_lockSensor;
-                UdsAns.Data2 = 0x00;
-                UdsAns.Data3 = 0x00;
-                UdsAns.Data4 = 0x00;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x04: //落座状态查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = ebcd_st_pedstSensor;
-                UdsAns.Data2 = 0x00;
-                UdsAns.Data3 = 0x00;
-                UdsAns.Data4 = 0x00;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x05: //互锁状态查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = ((m_flg_HVlock1 & 0x01) << 1) | (m_flg_HVlock2 & 0x01);
-                UdsAns.Data2 = 0x00;
-                UdsAns.Data3 = 0x00;
-                UdsAns.Data4 = 0x00;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x06: //气压值查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = ebcd_P_airSensor;
-                UdsAns.Data2 = 0x00;
-                UdsAns.Data3 = 0x00;
-                UdsAns.Data4 = 0x00;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x07: //锁紧压力查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = Test_LockPressure >> 8;
-                UdsAns.Data2 = Test_LockPressure;
-                UdsAns.Data3 = 0x00;
-                UdsAns.Data4 = 0x00;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x08: //锁紧次数查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = ManuControlTimes >> 8;
-                UdsAns.Data2 = ManuControlTimes;
-                UdsAns.Data3 = 0x00;
-                UdsAns.Data4 = 0x00;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x09: //温度数据查询
-            {
-                UdsAns.Seq = 0;
-                UdsAns.Data1 = ebcd_T_plugin[0];
-                UdsAns.Data2 = ebcd_T_plugin[1];
-                UdsAns.Data3 = ebcd_T_plugin[2];
-                UdsAns.Data4 = ebcd_T_plugin[3];
-                UdsPosAns(UdsAns);
-                break;
-            }
-            default:
-                UdsNegAns(UdsAns);
-                break;
-            }
-        }
-        else
-        {
-            UdsNegAns(UdsAns);
-        }
-        break;
-    }
-    case 0x27: //控制
-    {
-        if (udsMode == 2)
-        {
-            switch (UdsAns.UdsSubSer)
-            {
-            case 0x01: //循环测试开启
-            {
-                ebcd_flg_ebcManCtrlEn = 1;
-                ebcd_flg_ebcManCtrlMode = 1;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x02:
-            {
-                ebcd_flg_ebcManCtrlEn = 1;
-                ebcd_flg_ebcManCtrlMode = 2;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x03:
-            {
-                ebcd_flg_ebcManCtrlEn = 1;
-                ebcd_flg_ebcManCtrlMode = 3;
-                UdsPosAns(UdsAns);
-                break;
-            }
-            case 0x04:
-            {
-            	ebcd_flg_ebcManCtrlEn = 0;
-            	UdsPosAns(UdsAns);
-            	break;
-            }
-            default:
-                UdsNegAns(UdsAns);
-                break;
-            }
-        }
-        else
-        {
-            UdsNegAns(UdsAns);
-        }
-        break;
-    }
-    case 0x2E: //写入
-    {
-        if (udsMode == 2)
-        {
-            switch (UdsAns.UdsSubSer)
-            {
-            case 0x01:
-            {
-                LockDelayTime = (*(Data + 4) << 8) | *(Data + 5);
-                UdsPosAns(UdsAns);
-                EEPROMDrv_bSaveInstantUB = 1;
-                break;
-            }
-            case 0x02:
-            {
-                UnlockDelayTime = (*(Data + 4) << 8) | *(Data + 5);
-                UdsPosAns(UdsAns);
-                EEPROMDrv_bSaveInstantUB = 1;
-                break;
-            }
-            default:
-                UdsNegAns(UdsAns);
-                break;
-            }
-        }
-        else
-        {
-            UdsNegAns(UdsAns);
-        }
-        break;
-    }
-    default:
-        break;
-    }
-}
-void UdsPosAns(UdsAnsType UdsAnsData)
-{
-    MCANDrv_infoMsgS_TYPE infoMsgS;
-    infoMsgS.infoConfS.infoMsgParU.B.CAN = 2;
-    infoMsgS.infoConfS.infoMsgParU.B.DIR = _MCAN_DIR_TX;
-    infoMsgS.infoConfS.infoMsgParU.B.DLC = 8;
-    infoMsgS.infoConfS.infoMsgParU.B.IDE = _MCAN_IDE_EXT;
-    infoMsgS.infoConfS.infoMsgIDUI = 0x1C00EAECUL;
-    infoMsgS.datMsgUBA[0] = 0x78;
-    infoMsgS.datMsgUBA[1] = UdsAnsData.UdsSer;
-    infoMsgS.datMsgUBA[2] = UdsAnsData.UdsSubSer;
-    infoMsgS.datMsgUBA[3] = UdsAnsData.Seq;
-    infoMsgS.datMsgUBA[4] = UdsAnsData.Data1;
-    infoMsgS.datMsgUBA[5] = UdsAnsData.Data2;
-    infoMsgS.datMsgUBA[6] = UdsAnsData.Data3;
-    infoMsgS.datMsgUBA[7] = UdsAnsData.Data4;
-    MCANDrv_SendMsg(infoMsgS);
-}
-void UdsNegAns(UdsAnsType UdsAnsData)
-{
-    MCANDrv_infoMsgS_TYPE infoMsgS;
-    infoMsgS.infoConfS.infoMsgParU.B.CAN = 2;
-    infoMsgS.infoConfS.infoMsgParU.B.DIR = _MCAN_DIR_TX;
-    infoMsgS.infoConfS.infoMsgParU.B.DLC = 8;
-    infoMsgS.infoConfS.infoMsgParU.B.IDE = _MCAN_IDE_EXT;
-    infoMsgS.infoConfS.infoMsgIDUI = 0x1C00EAECUL;
-    infoMsgS.datMsgUBA[0] = 0x7F;
-    infoMsgS.datMsgUBA[1] = UdsAnsData.UdsSer;
-    infoMsgS.datMsgUBA[2] = UdsAnsData.UdsSubSer;
-    infoMsgS.datMsgUBA[3] = 0x00;
-    infoMsgS.datMsgUBA[4] = 0x00;
-    infoMsgS.datMsgUBA[5] = 0x00;
-    infoMsgS.datMsgUBA[6] = 0x00;
-    infoMsgS.datMsgUBA[7] = 0x00;
-    MCANDrv_SendMsg(infoMsgS);
-}

+ 11 - 123
System/Vehicle/Communication/CANNet.c

@@ -13,21 +13,18 @@
  *   2011.07.14          00.01.00      李中     第一版
  *******************************************************************************/
 
+#include <CanProtocolFunc.h>
+#include <CanProtocolFunc.h>
 #include "HardwareLib.h"
 #include "CANNet.h"
 #include "AccPedCD.h"
-#include "BleCanProtocolFunc.h"
-#include "BcuCanProtocolFunc.h"
-#include "VcuCanProtocolFunc.h"
+
 MCANDrv_infoMsgConfS_TYPE CANNet_infoMsgTxConfSA[3];
 MCAN_stRetE_TYPE CAN1Result;
 uint16 CANNet_idxSchedUB;
 MCANDrv_infoMsgConfS_TYPE CANNet_InfoRxMsgConfSA[128];
 uint8 CANNet_datRxMsgBufM[128][9];
-CanMsgInfo infoVcuSendMsg;
-CanMsgInfo infoBmsSendMsg;
-volatile BOOL VcuSendFlg = FALSE;
-volatile BOOL BmsSendFlg = FALSE;
+
 void CANNet_Init(void)
 {
 	/*示例代码*/
@@ -89,100 +86,22 @@ void CANNet_Init(void)
 // CAN0接收消息处理函数 VCU
 void CANNet_RecvMsgCAN0(MCANDrv_infoMsgS_TYPE infoMsgS)
 {
-	//直连状态下,CAN0空置,连接CAN1
-	//非直连状态下,CAN0接收VCU消息
-	VcuDecodeFunction(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
-	infoVcuSendMsg.CanID = infoMsgS.infoConfS.infoMsgIDUI;
-	memcpy(infoVcuSendMsg.CanData,infoMsgS.datMsgUBA,8);
-	VcuSendFlg = TRUE;
-	if((infoVcuSendMsg.CanID&0x0000FFFF)==0x0000F3D0||(infoVcuSendMsg.CanID&0x0000FFFF)==0x000015F6||(infoVcuSendMsg.CanID&0x0000FFFF)==0x000051ED||(infoVcuSendMsg.CanID&0x0000FFFF)==0x1C00EDEA)
-	{
-		CANNet_infoMsgTxConfSA[1].infoMsgIDUI = infoVcuSendMsg.CanID;
-		infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[1];
-		memset(infoMsgS.datMsgUBA, 0x00, 8);
-		if((infoVcuSendMsg.CanID==0x1802F3D0)&& 0)
-		{
-			static uint8 VcuLife = 0;
-			uint8 chk = 0;
-			VcuLife = (VcuLife+1)>14?0:(VcuLife+1);
-			infoVcuSendMsg.CanData[1] = (BattHvCtl<<4)|(VcuLife&0x0F);
-			for(uint8 i=1;i<8;i++)
-			{
-				chk = chk^infoVcuSendMsg.CanData[i];
-			}
-			infoVcuSendMsg.CanData[0] = chk;
-		}
-		memcpy(infoMsgS.datMsgUBA,infoVcuSendMsg.CanData,8);
-		MCANDrv_SendMsg(infoMsgS);
-	}
-
+	Can0Decode(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
 }
 // CAN1接收消息处理函数
 void CANNet_RecvMsgCAN1(MCANDrv_infoMsgS_TYPE infoMsgS)
 {
-	BcuDecodeFunction(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
-	infoBmsSendMsg.CanID = infoMsgS.infoConfS.infoMsgIDUI;
-	memcpy(infoBmsSendMsg.CanData,infoMsgS.datMsgUBA,8);
-	BmsSendFlg = TRUE;
-	CANNet_infoMsgTxConfSA[0].infoMsgIDUI = infoBmsSendMsg.CanID;
-	static uint8 TmsErrorFltTemp = 0;
-	if((infoBmsSendMsg.CanID==0x1880D0F3)&& 0)//主负继电器状态和主正一起发出  加TMS故障屏蔽
-	{
-		uint8 DataTemp = 0x00;
-		if(((infoBmsSendMsg.CanData[1]>>4)&0x03)==0x02)//主负继电器状态和主正一起发出
-		{
-			DataTemp = infoBmsSendMsg.CanData[1]&0x3F;
-			DataTemp = DataTemp|((0x02)<<6);
-			infoBmsSendMsg.CanData[1] = DataTemp;
-		}
-		else
-		{
-			DataTemp = infoBmsSendMsg.CanData[1]&0x3F;
-			DataTemp = DataTemp|((0x01)<<6);
-			infoBmsSendMsg.CanData[1] = DataTemp;
-		}
-		if(infoBmsSendMsg.CanData[7]==93)//TMS故障屏蔽
-		{
-			TmsErrorFltTemp = 1;
-			clrbit(infoBmsSendMsg.CanData[4],6);
-			infoBmsSendMsg.CanData[7] = 0;
-		}
-	}
-	if((infoBmsSendMsg.CanID==0x1881D0F3)&& TmsErrorFltTemp)//屏蔽Tms出现的故障等级
-	{
-		uint8 chk = 0;
-		uint8 ErrNum = 0;
-		clrbit(infoBmsSendMsg.CanData[2],5);
-		clrbit(infoBmsSendMsg.CanData[2],6);
-		ErrNum = (infoBmsSendMsg.CanData[7]>>3);
-		ErrNum = (ErrNum-1)<=0?0:(ErrNum-1);
-		infoBmsSendMsg.CanData[7] = (infoBmsSendMsg.CanData[7]&0x03)|(ErrNum<<3);
-		for(uint8 i=1;i<8;i++)
-		{
-			chk = chk^infoBmsSendMsg.CanData[i];
-		}
-		infoVcuSendMsg.CanData[0] = chk;
-	}
-
-	infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[0];
-	memset(infoMsgS.datMsgUBA, 0x00, 8);
-	memcpy(infoMsgS.datMsgUBA,infoBmsSendMsg.CanData,8);
-	MCANDrv_SendMsg(infoMsgS);
-
+	Can1Decode(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
 }
 /*备注,CAN2接收报文时,需要配置接收报文的MO号,如果不配置,将进入不了CAN中断*/
 void CANNet_RecvMsgCAN2(MCANDrv_infoMsgS_TYPE infoMsgS)
 {
-	Can2ProtocolDecode(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
+
 }
 //发送消息管理
 void CAN0Net_Manage1ms(void)
 {
-	MCANDrv_infoMsgS_TYPE infoMsgS;
-	if(BmsSendFlg){
 
-		//BmsSendFlg = FALSE;
-	}
 }
 void CAN1Net_Manage1ms(void)
 {
@@ -192,23 +111,18 @@ void CAN1Net_Manage1ms(void)
 	MCANDrv_infoMsgS_TYPE infoMsgS;
 	if (Can1TimerCounter % 100 == 0)
 	{
-		if (Can1TimerCounter % (EbcOutTable[BcuIDIdx][1]) == 0)
+		if (Can1TimerCounter % (Can1OutTable[BcuIDIdx][1]) == 0)
 		{
-			CANNet_infoMsgTxConfSA[1].infoMsgIDUI = EbcOutTable[BcuIDIdx][0];
+			CANNet_infoMsgTxConfSA[1].infoMsgIDUI = Can1OutTable[BcuIDIdx][0];
 			infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[1];
 			memset(infoMsgS.datMsgUBA, 0x00, 8);
-			BcuEncodeFunction(EbcOutTable[BcuIDIdx][0], &(infoMsgS.datMsgUBA[0]));
+			Can1Encode(Can1OutTable[BcuIDIdx][0], &(infoMsgS.datMsgUBA[0]));
 			MCANDrv_SendMsg(infoMsgS);
 		}
 		BcuIDIdx++;
 		BcuChkFlg = FALSE;
 	}
-	else if(VcuSendFlg){
-
-		//VcuSendFlg = FALSE;
-	}
-
-	if (BcuIDIdx >= (sizeof(EbcOutTable) / 8))
+	if (BcuIDIdx >= (sizeof(Can1OutTable) / 8))
 	{
 		BcuIDIdx = 0;
 		BcuChkFlg = TRUE;
@@ -220,31 +134,5 @@ void CAN1Net_Manage1ms(void)
 }
 void CAN2Net_Manage1ms(void)
 {
-	MCANDrv_infoMsgS_TYPE infoMsgS;
-	static UINT32 Can2TimerCounter = 0;
-	Can2TimerCounter = Can2TimerCounter + 1;
 
-	uint8 cmdIdx = 0x00;
-	uint8 DataIdx = 0x00;
-	static uint8 AnsNum = 0x00; //应答次数
-	static uint8 AnsInterval = 0;
-	DataIdx = ebcd_st_toBleAns;
-	AnsInterval++;
-	if (ebcd_flg_Can2SendEnbale == TRUE && DataIdx > 0 && AnsInterval > 5)
-	{
-		if (AnsNum < DataPackCounter[DataIdx])
-		{
-			Can2ProtocolCode(cmdIdx, DataIdx, (DataPackBegin[DataIdx] + AnsNum), &(CANNet_infoMsgTxConfSA[2].infoMsgIDUI), &(infoMsgS.datMsgUBA[0]));
-			infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
-			MCANDrv_SendMsg(infoMsgS);
-			AnsNum++;
-			AnsInterval = 0;
-		}
-		else
-		{
-			AnsNum = 0;
-			ebcd_st_toBleAns = 0;
-			ebcd_flg_Can2SendEnbale = FALSE;
-		}
-	}
 }

+ 1 - 2
System/Vehicle/Communication/CANNet.h

@@ -16,8 +16,7 @@
 #ifndef __CANNET_H
     #define __CANNET_H
 	#include "CanVar.h"
-	#include "VcuCanProtocolFunc.h"
-	#include "BcuCanProtocolFunc.h"
+	#include "CanProtocolFunc.h"
     #include "Std_Types.h"
     #include "HardwareLib.h"
 

+ 276 - 0
System/Vehicle/Communication/CanProtocolFunc.c

@@ -0,0 +1,276 @@
+/*
+ * @Author       : ChenJie
+ * @Date         : 2021-12-20 14:47:39
+ * @Version      : V3.0
+ * @LastEditors  : ChenJie
+ * @LastEditTime : 2022-05-09 17:13:09
+ * @Description  : file content
+ * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\CanProtocolFunc.c
+ */
+/*
+ * CanProtocol.c
+ * can协议转换
+ *  Created on: 2021年12月20日
+ *      Author: QiXiang_CHENJIE
+ */
+#include <CanProtocolFunc.h>
+#include "HardwareLib.h"
+/******************************************
+ *
+ *Can0接收发送函数
+ **************************************** */
+void Can0RxMsgSetInvalidValue(UINT32 ID);
+
+void Can0Encode(UINT32 ID, UINT8 *rawData)
+{
+
+}
+void Can0Decode(UINT32 ID, UINT8 *rawData)
+{
+	switch(ID)
+	{
+	case 0x18FF5A51:
+	{
+		gashighLevel_gf1 = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
+		gaslowLevel_gf1 = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
+		temp_gf1 = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
+		warningLevel_gf1 = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
+		workMode_gf1 = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
+		fumesHigh_gf1 = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
+		fumesLow_gf1 = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
+		Can0RxFlag[0] = 0x01;
+		break;
+	}
+	case 0x18FF5A52:
+	{
+		gashighLevel_gf2 = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
+		gaslowLevel_gf2 = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
+		temp_gf2 = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
+		warningLevel_gf2 = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
+		workMode_gf2 = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
+		fumesHigh_gf2 = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
+		fumesLow_gf2 = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
+		Can0RxFlag[1] = 0x01;
+		break;
+	}
+	default:
+	{
+		break;
+	}
+	}
+}
+void Can0RxDiagnose(void)
+{
+	static UINT32 TimeCounter = 0;	// ms
+	TimeCounter = TimeCounter + 10; //
+	for (UINT8 i = 0; i < sizeof(Can0InTable) / 4; i++)
+	{
+		if (Can0RxFlag[i] == 1) // received msg, and clear the error conter
+		{
+			Can0RxErrorCounter[i] = 0;
+			Can0RxFlag[i] = 0;
+			continue;
+		}
+		if (Can0RxErrorCounter[i] < 3)
+		{
+			Can0RxShortError[i] = 0;
+			Can0RxLongError[i] = 0;
+		}
+		else if (Can0RxErrorCounter[i] >= 3 && Can0RxErrorCounter[i] < 50)
+		{
+			Can0RxShortError[i] = 1;
+			Can0RxLongError[i] = 0;
+		}
+		else if (Can0RxErrorCounter[i] >= 50)
+		{
+			Can0RxShortError[i] = 0;
+			Can0RxLongError[i] = 1;
+			Can0RxMsgSetInvalidValue(Can0InTable[i]);
+			Can0RxErrorCounter[i] = 0;
+		}
+		else if (Can0RxErrorCounter[i] == 0xFF)
+		{
+			Can0RxErrorCounter[i] = 0xFE;
+		}
+	}
+	if (TimeCounter % 100 == 0) // period <=100ms
+	{
+		Can0RxErrorCounter[0]++;
+	}
+}
+void Can0RxMsgSetInvalidValue(UINT32 ID)
+{
+	switch (ID)
+	{
+	case 0x18FF5A51:
+	{
+		gashighLevel_gf1 = 0xFF;
+		gaslowLevel_gf1 = 0xFF;
+		temp_gf1 = 0xFF;
+		warningLevel_gf1 = 0xFF;
+		workMode_gf1 = 0xFF;
+		fumesHigh_gf1 = 0xFF;
+		fumesLow_gf1 = 0xFF;
+		break;
+	}
+	case 0x18FF5A52:
+	{
+		gashighLevel_gf2 = 0xFF;
+		gaslowLevel_gf2 = 0xFF;
+		temp_gf2 = 0xFF;
+		warningLevel_gf2 = 0xFF;
+		workMode_gf2 = 0xFF;
+		fumesHigh_gf2 = 0xFF;
+		fumesLow_gf2 = 0xFF;
+		break;
+	}
+	default:
+		break;
+	}
+}
+
+/******************************************
+ *
+ *Can1接收发送函数
+ **************************************** */
+/**
+ * @brief : BMC发送
+ * @param {uint8} CmdIdx
+ * @return {*}
+ */
+void Can1RxMsgSetInvalidValue(UINT32 ID);
+void Can1Encode(UINT32 ID, UINT8 *rawData)
+{
+	switch(ID)
+	{
+	case 0x18FF1100:
+	{
+		*(rawData + 0) = connectorHvlock1;
+		*(rawData + 1) = connectorHvlock2;
+		*(rawData + 2) = chrgModuelPwrCtlFB;
+		*(rawData + 3) = paraChrgCtlFB;
+		*(rawData + 4) = outToChrgCtlFB_A;
+		*(rawData + 5) = outToBaseCtlFB_A;
+		*(rawData + 6) = outToChrgCtlFB_B;
+		*(rawData + 7) = outToBaseCtlFB_B;
+		break;
+	}
+	case 0x18FF1101:
+	{
+		*(rawData + 0) = fuseActionFB_A;
+		*(rawData + 1) = fuseActionFB_B;
+		*(rawData + 2) = sigSwitchReadyFB_A;
+		*(rawData + 3) = sigSwitchReadyFB_B;
+		*(rawData + 4) = ctrlFXFB1;
+		*(rawData + 5) = ctrlFXFB2;
+		*(rawData + 6) = 0xFF;
+		*(rawData + 7) = 0xFF;
+		break;
+	}
+	case 0x18FF1102:
+	{
+		*(rawData + 0) = conn1Temp1;
+		*(rawData + 1) = conn1Temp2;
+		*(rawData + 2) = conn2Temp1;
+		*(rawData + 3) = conn2Temp2;
+		*(rawData + 4) = chrgGunTemp1_A;
+		*(rawData + 5) = chrgGunTemp2_A;
+		*(rawData + 6) = chrgGunTemp1_B;
+		*(rawData + 7) = chrgGunTemp2_B;
+		break;
+	}
+	case 0x18FF1103:
+	{
+		*(rawData + 0) = chrgBoxTemp1;
+		*(rawData + 1) = chrgBoxTemp2;
+		*(rawData + 2) = chrgBoxGasOver1;
+		*(rawData + 3) = chrgBoxGasOver2;
+		*(rawData + 4) = chrgBoxFumesOver1;
+		*(rawData + 5) = chrgBoxFumesOver2;
+		*(rawData + 6) = chrgBox1Warning;
+		*(rawData + 7) = chrgBox2Warning;
+		break;
+	}
+	default:
+		break;
+	}
+}
+/**
+ * @brief : BMC解析
+ * @param {*}
+ * @return {*}
+ */
+void Can1Decode(UINT32 ID, UINT8 *rawData)
+{
+	switch(ID)
+	{
+	case 0x18FF1200:
+	{
+		chrgModulePwrCtrl = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
+		baseSwitchCtrl = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
+		paraChrgCtrlState = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
+		chrgStartState = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
+		chrgStopState = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
+		Can1RxFlag[0] = 0x01;
+		break;
+	}
+	default:
+	{
+		break;
+	}
+	}
+}
+void Can1RxDiagnose(void)
+{
+	static UINT32 TimeCounter = 0;	// ms
+	TimeCounter = TimeCounter + 10; //
+	for (UINT8 i = 0; i < sizeof(Can1InTable) / 4; i++)
+	{
+		if (Can1RxFlag[i] == 1) // received msg, and clear the error conter
+		{
+			Can1RxErrorCounter[i] = 0;
+			Can1RxFlag[i] = 0;
+			continue;
+		}
+		if (Can1RxErrorCounter[i] < 3)
+		{
+			Can1RxShortError[i] = 0;
+			Can1RxLongError[i] = 0;
+		}
+		else if (Can1RxErrorCounter[i] >= 3 && Can1RxErrorCounter[i] < 50)
+		{
+			Can1RxShortError[i] = 1;
+			Can1RxLongError[i] = 0;
+		}
+		else if (Can1RxErrorCounter[i] >= 50)
+		{
+			Can1RxShortError[i] = 0;
+			Can1RxLongError[i] = 1;
+			Can1RxMsgSetInvalidValue(Can1InTable[i]);
+			Can1RxErrorCounter[i] = 0;
+		}
+		else if (Can1RxErrorCounter[i] == 0xFF)
+		{
+			Can1RxErrorCounter[i] = 0xFE;
+		}
+	}
+	if (TimeCounter % 100 == 0) // period <=100ms
+	{
+		Can1RxErrorCounter[0]++;
+	}
+}
+void Can1RxMsgSetInvalidValue(UINT32 ID)
+{
+	switch (ID)
+	{
+	case 0x18FF1200:
+		chrgModulePwrCtrl = 0xFF;
+		baseSwitchCtrl = 0xFF;
+		paraChrgCtrlState = 0xFF;
+		chrgStartState = 0xFF;
+		chrgStopState = 0xFF;
+		break;
+	default:
+		break;
+	}
+}

+ 7 - 16
System/Vehicle/Communication/BleCanProtocolFunc.h → System/Vehicle/Communication/CanProtocolFunc.h

@@ -17,20 +17,11 @@
 #include "CanVar.h"
 #ifndef SYSTEM_VEHICLE_CANPROTOCOL_H_
 #define SYSTEM_VEHICLE_CANPROTOCOL_H_
-typedef struct
-{
-	uint8 UdsSer;
-	uint8 UdsSubSer;
-	uint8 Seq;
-	uint8 Data1;
-	uint8 Data2;
-	uint8 Data3;
-	uint8 Data4;
-} UdsAnsType;
-void UdsPosAns(UdsAnsType UdsAnsData);
-void UdsNegAns(UdsAnsType UdsAnsData);
-void Can2ProtocolCode(uint8 CmdIdx,uint8 DataIdx,uint8 Byte0Num,uint32 *InnerCanID,uint8 *Data);
-void Can2ProtocolDecode(uint32 Can2ID,uint8 Data[]);
-void Can2DataCode(uint8 DataIdx, uint8 Byte0Num,uint8 Data[]);
-void Can2DataDecode(uint8 Data[]);
+void Can0Encode(UINT32 ID, UINT8 *rawData);
+void Can0Decode(UINT32 ID, UINT8 *rawData);
+void Can0RxDiagnose(void);
+
+void Can1Encode(UINT32 ID, UINT8 *rawData);
+void Can1Decode(UINT32 ID, UINT8 *rawData);
+void Can1RxDiagnose(void);
 #endif /* SYSTEM_VEHICLE_CANPROTOCOL_H_ */

+ 81 - 383
System/Vehicle/Communication/CanVar.c

@@ -6,396 +6,97 @@
  *      Author: QiXiang_CHENJIE
  */
 #include "CanVar.h"
-UINT32 BcuInTable[28] = {
-	0x1801D0F3,
-	0x1801D8F3,
-	0x1880D0F3,
-	0x1881D0F3,
-	0x1882D0F3,
-	0x1883D0F3,
-	0x1884D0F3,
-	0x1885D0F3,
-	0x1886D0F3,
-	0x1887D0F3,
-	0x1888D0F3,
-	0x1889D0F3,
-	0x188AD0F3,
-	0x18C1D0F3,
-	0x18C2D0F3,
-	0x18E1D0F3,
-	0x18E2D0F3,
-	0x18E3D0F3,
-	0x18E4D0F3,
-	0x18E5D0F3,
-	0x18E6D0F3,
-	0x18F1D0F3,
-	0x18F2D0F3,
-	0x18F3D0F3,
-	0x18F4D0F3,
-	0x18F5D0F3,
-	0x18FF45F4,
-	0x18FFC13A,
+/************************************************************
+ *CAN0->BMC解码变量存放区
+ ************************************************************/
+UINT32 Can0InTable[2] =
+{
+	0x18FF5A51,
+	0x18FF5A52,
 };
+BOOL Can0RxShortError[2];
+BOOL Can0RxLongError[2];
+UINT8 Can0RxErrorCounter[2];
+UINT8 Can0RxFlag[2];
+
+UINT8 gashighLevel_gf1 = 0;
+UINT8 gaslowLevel_gf1 = 0;
+UINT8 temp_gf1 = 0;
+UINT8 warningLevel_gf1 = 0;
+UINT8 workMode_gf1 = 0;
+UINT8 fumesHigh_gf1 = 0;
+UINT8 fumesLow_gf1 = 0;
+UINT8 gashighLevel_gf2 = 0;
+UINT8 gaslowLevel_gf2 = 0;
+UINT8 temp_gf2 = 0;
+UINT8 warningLevel_gf2 = 0;
+UINT8 workMode_gf2 = 0;
+UINT8 fumesHigh_gf2 = 0;
+UINT8 fumesLow_gf2 = 0;
 
-BOOL BcuRxShortError[28];
-BOOL BcuRxLongError[28];
-UINT8 BcuRxErrorCounter[28];
-UINT8 BcuRxFlag[28];
 /************************************************************
- *BCU->Ebc解码变量存放区
+ *CAN1->BMC解码变量存放区
  ************************************************************/
-UINT8 BMS_ReqVIN = 0x00;					  //是否请求VIN码,0:预留;1:请求VIN;2:不请求VIN;3:无效;,Re-1,Off-0,
-UINT8 BMS_ReqHVOff = 0x00;					  //是否请求下高压,0:预留;1:请求下高压;2:不请求下高压;3:无效;,Re-1,Off-0,
-UINT8 BMS_ProtocolEditionH = 0x00;			  //通讯协议版本高位(例 : 版本为3 .1, 则此处发3),	, Re - 1, Off - 0,
-UINT8 BMS_ProtocolEditionL = 0x00;			  //通讯协议版本低位(例 : 版本为3 .1, 则此处发1),	, Re - 1, Off - 0,
-UINT8 BMS_CharDevNum = 0x00;				  //可充电装置系统序号(BMS是整车中可充电装置系统中的第几个, 需要整车告知),1,Re-1,Off-0,
-UINT8 BMS_FtPosRly = 0x00;					  //主正继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegRly = 0x00;					  //主负继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly1 = 0x00;				  //充正1继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly1 = 0x00;				  //充负1继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly2 = 0x00;				  //充正2继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly2 = 0x00;				  //充负2继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHeatRly1 = 0x00;				  //加热1/正继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHeatRly2 = 0x00;				  //加热2/负继电器粘连故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_StPosRly = 0x00;					  //主正继电器状态(如继电器状态由BMS检测),0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StNegRly = 0x00;					  //主负继电器状态(如继电器状态由BMS检测),0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StPreCharRly = 0x00;				  //预充继电器状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StPosCharRly1 = 0x00;				  //直流充正继电器1状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StNegCharRly1 = 0x00;				  //直流充负继电器1状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StPosCharRly2 = 0x00;				  //直流充正继电器2状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_StNegCharRly2 = 0x00;				  //直流充负继电器2状态,0:预留;1:开启;2:闭合;3:无效;,Re-1,Off-0,
-UINT8 BMS_FtAuxRelayWeld = 0x00;			  //附件继电器粘连故障(保留),0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_BraOpenCirc = 0x00;				  //支路断路故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtBackCharCurrOutLim = 0x00;		  //回充电流超限报警,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtPosRlyOpen = 0x00;				  //主正继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegRlyOpen = 0x00;				  //主负继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly1Open = 0x00;			  //直流充电正1继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPosCharRly2Open = 0x00;			  //直流充电正2继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly1Open = 0x00;			  //直流充电负1继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNegCharRly2Open = 0x00;			  //直流充电负2继电器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtTMSContClose = 0x00;			  //加热膜或TMS接触器无法断开报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtTMSContOpen = 0x00;				  //加热膜或TMS接触器无法闭合报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtTMS = 0x00;						  //热管理系统故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_Ft24VSpy = 0x00;					  // BMS 24V供电异常报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtPACKSelfProt = 0x00;			  //电池包自保护报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCharSockTempOver = 0x00;		  //充电插座过温报警,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtTempOutCtrl = 0x00;				  //热失控报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_StPosHeatRly = 0x00;				  //加热正继电器状态,0:保留;1:开启;2:闭合;3:无效,Re-1,Off-0,
-UINT8 BMS_StNegHeatRly = 0x00;				  //加热负继电器状态,0:保留;1:开启;2:闭合;3:无效,Re-1,Off-0,
-UINT8 BMS_CharSysNum = 0x00;				  //可充电储能子系统总数(保留),,Re-1,Off-0,
-UINT8 BMS_FtCode = 0x00;					  //电池系统故障码,详见附表电池系统故障码列表,Re-1,Off-0,
-UINT8 BMS_ST1CheckSum = 0x00;				  // B2V_ST1的CheckSum,Byte0=Byte1 XOR Byte2 XOR Byte3 XOR Byte4 XOR Byte5 XOR Byte6 XOR Byte7,Re-1,Off-0,
-UINT8 BMS_ST1Counter = 0x00;				  // B2V_ST1的生命信号,0~14循环,15:信号无效,Re-1,Off-0,
-UINT8 BMS_Mode = 0x00;						  // BMS当前状态,0:预留;1:高压上电;2:高压下电;3:无效;,Re-1,Off-0,
-UINT8 BMS_AuxRlySt = 0x00;					  //附件继电器状态,0:开启;1:闭合;,Re-1,Off-0,
-UINT8 BMS_BattBalaSt = 0x00;				  // BMS当前均衡状态,0:未开启均衡;1:开启均衡;,Re-1,Off-0,
-UINT8 BMS_CharGunSt = 0x00;					  //直流充电枪连接状态,0:未连接1 : 连接, Re - 1, Off - 0,
-UINT8 BMS_CharMode = 0x00;					  // BMS当前充电模式,0:预留1 : 直流充电 2 : 交流充电 3 : 其他充电, Re - 1, Off - 0,
-UINT8 BMS_CharSt = 0x00;					  //充电状态,0:可以充电1 : 正在充电 2 : 充电结束 3 : 充电故障, Re - 1, Off - 0,
-UINT8 BMS_FtLvl = 0x00;						  //当前最高故障等级,0:正常1 : 1级 轻微故障 2 : 2级 较严重故障 3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellTempDiff = 0x00;			  //电芯温差异常报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellTempHigh = 0x00;			  //电芯温度过高报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtPACKOverVolt = 0x00;			  // PACK过压报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtPACKUndeVolt = 0x00;			  // PACK欠压报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtSOCLow = 0x00;					  // SOC过低报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellOverVolt = 0x00;			  //单体电压过高报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellUndeVolt = 0x00;			  //单体电压欠压报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtIns = 0x00;						  //绝缘报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellOverVoltDiff = 0x00;		  //单体压差过大,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCharCurrOver = 0x00;			  //充电电流过大报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtDisCharCurrOver = 0x00;			  //放电电流过大报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtCellTempLow = 0x00;				  //电芯温度过低报警,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtBranVoltDifOver = 0x00;			  //支路压差过大报警(存在并联支路的系统),0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtBMSHardWare = 0x00;				  // BMS硬件故障,0:无故障; 1:1级 轻微故障; 2:2级 较严重故障3 : 3级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtSOCHigh = 0x00;					  // SOC过高报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtSOCJump = 0x00;					  // SOC跳变报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtInCom = 0x00;					  // BMS内部通信故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtSysMism = 0x00;					  // BMS/可充电储能系统不匹配报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHvIntLock = 0x00;				  //高压互锁报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtSmoke = 0x00;					  //火警探测器故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtFire = 0x00;					  //电池包火灾报警,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtNum = 0x00;						  // BMS当前发生的故障总数目(包括GB32960中规定的故障数目),,Re-1,Off-0,
-UINT8 BMS_PackSOC = 0x00;					  //电池包SOC,,Re-0.4,Off-0,
-UINT8 BMS_PackSOH = 0x00;					  //电池包SOH,,Re-0.4,Off-0,
-UINT8 BMS_MaxCellTemp = 0x00;				  //单体最高温度,,Re-1,Off--50,℃
-UINT8 BMS_MinCellTemp = 0x00;				  //单体最低温度,,Re-1,Off--50,℃
-UINT8 BMS_AverCellTemp = 0x00;				  //单体平均温度,,Re-1,Off--50,℃
-UINT8 BMS_MaxCellTempCSC = 0x00;			  //最高温度电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MaxCellTempNum = 0x00;			  //最高温度电芯所在子系统(CSC)内温度探针编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellTempCSC = 0x00;			  //最低温度电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellTempNum = 0x00;			  //最低温度电芯所在子系统(CSC)内温度探针编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MaxCellVoltCSC = 0x00;			  //最高电压电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MaxCellVoltNum = 0x00;			  //最高电压电芯所在子系统(CSC)内单体编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellVoltCSC = 0x00;			  //最低电压电芯所在子系统(CSC)编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_MinCellVoltNum = 0x00;			  //最低电压电芯所在子系统(CSC)内单体编号,范围(1~255),Re-1,Off-0,
-UINT8 BMS_InsDeteSt = 0x00;					  // BMS绝缘检测状态,0:停止检测;1:激活检测;,Re-1,Off-0,
-UINT8 BMS_FtCharInsLow = 0x00;				  //充电绝缘阻值低,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCurrSenr = 0x00;				  //电流传感器故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtHeatingFilm = 0x00;				  //加热膜加热回路故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtMainLoopPreChar = 0x00;			  //主回路预充或预检故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtAuxLoopPreChar = 0x00;			  //辅件回路预充或预检故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtACANLost = 0x00;				  // ACAN/整车CAN通讯故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtDCDC = 0x00;					  // BMS-DC-DC故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtSOCDif = 0x00;					  // SOC差异过大,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCellOverDisChar = 0x00;			  //电芯过放故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCharOver = 0x00;				  //车载储能装置过充报警,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtContDisCharCurrOverLoad = 0x00;	  //持续回充过流故障,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_FtContCharCurrOverLoad = 0x00;	  //持续放电过流故障,0:正常;1:1级 轻微故障;2:2级 较严重故障3 : 10级 最严重故障, Re - 1, Off - 0,
-UINT8 BMS_Gun1DCNegTemp = 0x00;				  //充电口1负温感值,,Re-1,Off--40,℃
-UINT8 BMS_Gun1DCPosTemp = 0x00;				  //充电口1正温感值,,Re-1,Off--40,℃
-UINT8 BMS_Gun2DCNegTemp = 0x00;				  //充电口2负温感值,,Re-1,Off--40,℃
-UINT8 BMS_Gun2DCPosTemp = 0x00;				  //充电口2正温感值,,Re-1,Off--40,℃
-UINT8 BMS_CurrHeatSt = 0x00;				  //当前加热状态,0:未加热;1:加热中;2:预留;3:无效;,Re-1,Off-0,
-UINT8 BMS_CurrCoolSt = 0x00;				  //当前冷却状态,0:未冷却;1:冷却中;2:预留;3:无效;,Re-1,Off-0,
-UINT8 BMS_FtCharCnct = 0x00;				  //插枪连接信号异常,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtOverDisCharCurrDuringChar = 0x00; //充电时放电电流过大,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtCharNTC = 0x00;					  //充电插座NTC故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_FtELock = 0x00;					  //电子锁故障,0:正常; 1:故障,Re-1,Off-0,
-UINT8 BMS_CellVoltFramNum = 0x00;			  //单体电压帧序号,有效值1~255,Re-1,Off-0,
-UINT8 BMS_CellTempFramNum = 0x00;			  //温度帧序号,有效值1~255,Re-1,Off-0,
-UINT8 BMS_CSC_Code = 0x00;					  //子系统编号CSC,有效值1~255,Re-1,Off-0,
-UINT8 BMS_CellTemp[64] = {0x00};			  //当前CSC下的第N个探针的温度,255 "Invalid" 0xFF 无效有效值 0 ~254, 单位 ℃, 范围(-50 ~204)℃, , Re - 1, Off-- 50,℃
-UINT8 BMS_Checksum = 0x00;					  //电池编码信息1的CheckSum,Byte0=Byte1 XOR Byte2 XOR Byte3 XOR Byte4 XOR Byte5 XOR Byte6 XOR Byte7,Re-1,Off-0,
-UINT8 BMS_PackComp = 0x00;					  //电池厂家,1:"CATL" 2:"Li Shen" 3:"MGL" 4:"SAMSUN" 5:"LG",Re-1,Off-0,
-UINT8 BMS_BattCodeLeng = 0x00;				  //电池编码长度,0:Do not transmit this Code,Re-1,Off-0,
-UINT8 BMS_SN[27] = {0x00};					  //电池编码(SN)字符1(ASCII),,Re-1,Off-0,
-UINT8 BMS_BattType = 0x00;					  //电池类型,1:铅酸电池; 2:镍氢电池; 3:磷酸铁锂电池; 4:锰酸锂电池; 5:钴酸锂电池; 6:三元材料电池; 7:聚合物锂离子电池; 8:钛酸锂电池; 9:超级电容; 10~13:保留; 14:燃料电池;15:保留,Re-1,Off-0,
-UINT8 BMS_CoolType = 0x00;					  //电池冷却方式,0:其他冷却方式1 : 自然冷却 2 : 风扇冷却 3 : 水冷却, Re - 1, Off - 0,
-UINT8 BMS_CSC_Total = 0x00;					  //电池系统中CSC总的数目,,Re-1,Off-0,
-UINT8 BMS_CellVoltLevel = 0x00;				  //单体平台电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
-UINT8 BMS_CellMinVolt = 0x00;				  //单体可用最低电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
-UINT8 BMS_CellMaxVolt = 0x00;				  //单体可用最高电压(非实时变化的值),有效值0~5V;  255 "Signal Invalid" 0xFF 无效,Re-0.1,Off-0,V
-UINT8 BMS_HVBranNum = 0x00;					  //电池系统高压支路数,,Re-1,Off-0,
-UINT8 BMS_SingleHVBranchCellNum = 0x00;		  //电池系统单支路电芯数,,Re-1,Off-0,
-UINT8 BMS_ReqMode = 0x00;					  // BMS请求设定模式,0:关机模式1 : 制冷模式 2 : 制热模式 3 : 自循环模式, Re - 1, Off - 0,
-UINT8 BMS_HVCmd = 0x00;						  //高压请求,0:请求上高压1 : 请求下高压, Re - 1, Off - 0,
-UINT8 BMS_ChgSts = 0x00;					  //充电状态,0:非充电1 : 充电, Re - 1, Off - 0,
-UINT8 BMS_HVRelaySts = 0x00;				  // BMS高压继电器状态,0:断开状态; 1:闭合状态; 2~3:无效,Re-1,Off-0,
-UINT8 BMS_SetTemp = 0x00;					  //设定温度,,Re-1,Off--40,
-UINT8 BMS_Life = 0x00;						  // BMS生命帧,,Re-1,Off-0,
-UINT8 BMS_CRC = 0x00;						  // CRC校验值,,Re-1,Off-0,
-UINT8 TMS_WorkStatus = 0x00;				  // TMS工作状态,0:关机模式1 : 制冷模式 2 : 制热模式 3 : 自循环模式, Re - 1, Off - 0,
-UINT8 TMS_HVRelayST = 0x00;					  // TMS高压继电器状态,0:断开状态; 1:闭合状态; 2~3:无效,Re-1,Off-0,
-UINT8 TMS_OutletTemp = 0x00;				  //出水温度(机组到电池),255:无效,Re-1,Off--40,
-UINT8 TMS_InletTemp = 0x00;					  //回水温度(电池到机组),255:无效,Re-1,Off--40,
-UINT8 TMS_ErrCode = 0x00;					  // TMS故障码,0:无故障; 出现 1 种以上循环发送,Re-1,Off-0,
-UINT8 TMS_FaultLevel = 0x00;				  // TMS故障码等级,0:无效1 : 1级故障 2 : 2级故障 3 : 3级故障, Re - 1, Off - 0,
-UINT16 BMS_SoftwareVersion = 0x00;			  //软件版本号:RyyyBzzz(R为软件版本、B为测试版本、正式版本不带B)  ,yyy:0~254,精度1,255:无效,不显示;zzz:0~254,精度1,255:无效,不显示;
-UINT16 BMS_HardwareVersion = 0x00;			  //硬件版本号:VyyyBzzz(V为硬件版本、B为测试版本、正式版本不带B)  ,,Re-1,Off-0,
-UINT16 BMS_PackCurr = 0x00;					  //电池包总电流,充电为负值,放电为正值,,Re-0.1,Off--1000,A
-UINT16 BMS_MaxCharCurr = 0x00;				  //电池包最大回充电流,,Re-0.1,Off--1000,A
-UINT16 BMS_MaxDisCharCurr = 0x00;			  //电池包最大放电电流,,Re-0.1,Off--1000,A
-UINT16 BMS_PosIns = 0x00;					  //母线正对车体绝缘电阻,,Re-1,Off-0,KΩ
-UINT16 BMS_NegIns = 0x00;					  //母线负对车体绝缘电阻,,Re-1,Off-0,KΩ
-UINT16 BMS_BattVolt = 0x00;					  //电池包内侧电压,,Re-0.1,Off-0,V
-UINT16 BMS_LinkVolt = 0x00;					  //电池包外侧电压,,Re-0.1,Off-0,V
-UINT16 BMS_MaxCellVolt = 0x00;				  //单体最高电压值,,Re-0.001,Off-0,V
-UINT16 BMS_AverCellVolt = 0x00;				  //电芯电压平均值,,Re-0.001,Off-0,V
-UINT16 BMS_MinCellVolt = 0x00;				  //电芯最低电压值,,Re-0.001,Off-0,V
-UINT16 BMS_ContChrgCurr = 0x00;				  // BMS允许的持续回充电流,,Re-0.1,Off-0,A
-UINT16 BMS_ContDisCharCurr = 0x00;			  // BMS允许的持续放电电流,,Re-0.1,Off--1000,A
-UINT16 BMS_CharReqVolt = 0x00;				  //充电所需电压(交流),,Re-0.1,Off-0,V
-UINT16 BMS_CharReqCurr = 0x00;				  //充电所需电流(交流),,Re-0.1,Off--1000,A
-UINT16 BMS_SysInsRes = 0x00;				  //系统绝缘电阻,,Re-1,Off-0,KΩ
-UINT16 BMS_MaxDisCharPwr = 0x00;			  //最大允许放电功率,,Re-0.1,Off-0,kw
-UINT16 BMS_MaxCharPwr = 0x00;				  //最大允许充电功率,,Re-0.1,Off-0,kw
-UINT16 BMS_ContDisCharPwr = 0x00;			  // BMS允许的持续放电功率,,Re-0.1,Off-0,kw
-UINT16 BMS_ContCharPwr = 0x00;				  // BMS允许的持续充电功率,,Re-0.1,Off-0,kw
-UINT16 BMS_InstEngyCons = 0x00;				  //动力电池瞬时百公里能耗,,Re-0.1,Off-0,kwh
-UINT16 BMS_TotalEngyCons = 0x00;			  //动力电池总/平均百公里能耗,,Re-0.1,Off-0,kwh
-UINT16 BMS_SOE = 0x00;						  //剩余电量,,Re-0.01,Off-0,kwh
-UINT16 BMS_RmanCharTime = 0x00;				  //剩余充电时间,,Re-1,Off-0,min
-UINT16 BMS_CharNum = 0x00;					  //充电次数,,Re-1,Off-0,
-UINT16 BMS_CellVolt[384] = {0x00};			  //电芯的电压,65535 "Invalid" 0xFFFF 无效有效值 0 ~65534, 范围(0 ~65.534) V, Re - 0.001, Off - 0, V
-UINT16 BMS_BattRateCap = 0x00;				  //电池包额定容量,有效值 0~65534,65535 "Signal Invalid" 无效,Re-1,Off-0,Ah
-UINT16 BMS_BattRateVolt = 0x00;				  //电池包额定电压,有效值 0~6553.4,65535 "Signal Invalid" 无效,Re-0.1,Off-0,V
-UINT16 BMS_BattRateEngy = 0x00;				  //电池包额定能量,有效值 0~6553.4,65535 "Signal Invalid" 无效,Re-0.1,Off-0,kWh
-UINT16 BMS_CellTotal = 0x00;				  // PACK中单体电芯的总数目,,Re-1,Off-0,
-UINT16 BMS_TempTotal = 0x00;				  // PACK中电芯温度点(探针)的总数目,,Re-1,Off-0,
-UINT16 BMS_SingleCharEngy = 0x00;			  //单次充电kWh 数,,Re-0.1,Off-0,KWh
-UINT16 BMS_SingleCharCapy = 0x00;			  //单次充电Ah 数,,Re-0.1,Off-0,Ah
-UINT16 BMS_HVVolt = 0x00;					  // BMS当前电压,,Re-1,Off-0,
-UINT16 TMS_ReqPow = 0x00;					  // TMS需求功率,65535:无效,Re-0.1,Off-0,Kw
-UINT32 BMS_TotalCharEngy = 0x00;			  //累计充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalDisCharEngy = 0x00;			  //累计放出kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalBackCharEngy = 0x00;		  //累计动能回馈充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalStaCharEngy = 0x00;			  //累计换电站充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalGunCharEngy = 0x00;			  //累计插枪充电充入kWh 数,,Re-0.1,Off-0,KWh
-UINT32 BMS_TotalGunCharCapy = 0x00;			  //累计插枪充电充入Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalCharCapy = 0x00;			  //累计充入Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalDisCharCapy = 0x00;			  //累计放出Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalBackCharCapy = 0x00;		  //累计动能回馈充入Ah 数,,Re-0.1,Off-0,Ah
-UINT32 BMS_TotalStaCharCapy = 0x00;			  //累计换电站充入Ah 数,,Re-0.1,Off-0,Ah
-/*VCU->EBC信号*****************************************/
-UINT32 VcuInTable[4] = {
-	0x18F101D0,
-	0x18F103D0,
-	0x18E1F3D0,
-	0x18FEF100};
-BOOL VcuRxShortError[4];
-BOOL VcuRxLongError[4];
-UINT8 VcuRxFlag[4];
-UINT8 VcuRxErrorCounter[4];
-UINT8 VCU_Num_VIN[17];			// VCU-VIN
-UINT8 VCU_St_VinRecv;			// VIN接收状态
-UINT8 VCU_St_BattRly = 0x00;	//电池接触器状态,0:闭合,指示灯灭 1:断开,指示灯亮 2:预留 3:无效,R-1,Off-0,
-UINT8 VCU_St_Check = 0x00;		// VCU自检状态,0:正在自检 1:自检成功 2:自检失败 3:无效,R-1,Off-0,
-UINT8 VCU_St_SysIntLock = 0x00; //系统互锁状态,0:没有互锁 1:充电互锁 2:预留 3:无效,R-1,Off-0,
-UINT8 VCU_St_Veh = 0x00;		//整车状态,0:Wait 1:Ready 2:预留 3:无效,R-1,Off-0,
-UINT8 VCU_St_Gear = 0x00;		//档位状态, -1:倒档  0:空档  1:1档  2:2档  3:3档  4:4档  5:5档  6:6档  7:7档  8:8档  9:9档  10:10档  11:11档  12:12档  13:13档  14:14无效 ,R-1,Off--125,
-UINT8 VCU_Ft_Sys = 0x00;		// VCU故障(与MCU故障点亮同一个符号),0:无故障 1:系统故障,R-1,Off-0,
-UINT8 VCU_Ft_Tran = 0x00;		//变速箱故障,0:正常 1:报警,R-1,Off-0,
-UINT8 VCU_Ft_BattSys = 0x00;	//动力电池系统故障,0:正常 1:报警,R-1,Off-0,
-UINT8 VCU_State_Veh = 0x00;		//车辆状态,1:车辆启动状态 2:熄火 3:其他状态 14:异常 15:无效,R-1,Off-0,
-UINT8 VCU_Counter = 0x00;		//循环计数器,,R-0.1,Off-0,
-UINT8 VCU_SoftVersion = 0x00;	// VCU软件版本号,,R-0.1,Off-0,
-UINT8 VCU_St_AccPedal = 0x00;	//加速踏板状态,,R-0.4,Off-0,
-UINT8 VCU_St_BrakePedal = 0x00; //刹车踏板状态,,R-0.4,Off-0,
-UINT8 VCU_St_ParkBrakeSw = 0;	//手刹状态
-// declear the UINT16 vars
-UINT16 VCU_VehSpd = 0x00;	//车速,,R-0.0039,Off-0,Km/h
-UINT16 VCU_RemaMile = 0x00; //剩余里程,,R-0.125,Off-0,Km
-/*EBC->CAN信号*****************************/
-UINT32 EbcOutTable[2][2] =
-	{{0x18FFF8A7, 100},
-	 {0x18FEF8A7, 100}};
-UINT8 EBC_Counter = 0;		   // EBC_Counter	LIFE 信号
-UINT8 EBC_LockSt = 0;		   // EBC_LockSt	锁止销反馈状态
-UINT8 EBC_CnctSt = 0;		   //换电连接器状态(充电回路&放电回路同时闭合代表闭合,有一路断开则为断开)
-UINT8 EBC_DisCharCnctSt = 0;   //	放电回路换电连接器状态(保留)
-UINT8 EBC_CharCnctSt = 0;	   //	充电回路换电连接器状态(保留)
-UINT8 EBC_FtLvl = 0;		   //换电系统故障等级
-UINT8 EBC_FtCode = 0;		   //换电系统故障码
-UINT8 EBC_AirPressure = 0;	   //气压值
-UINT8 EBC_CharSt = 0;		   //充电标志位
-UINT8 EBC_ActHeatReq = 0;	   //主动预热请求
-UINT8 EBC_InhiHVOn = 0;		   //禁止高压上电
-UINT8 EBC_ReqHVOff = 0;		   //请求高压下电
-UINT8 EBC_StopChgCmd = 0;	   //停止充电指令
-UINT8 EBC_State = 0;		   //换电控制器状态
-UINT8 EBC_DisCharPos1Temp = 0; //放电正1温度
-UINT8 EBC_DischarNeg1Temp = 0; //放电负1温度
-UINT8 EBC_DisCharPos2Temp = 0; //放电正2温度
-UINT8 EBC_DisCharNeg2Temp = 0; //放电负2温度
-UINT8 EBC_ChgPos1Temp = 0;	   //充电正1温度(保留)
-UINT8 EBC_ChgNeg1Temp = 0;	   //充电负1温度(保留)
-UINT8 EBC_ChgPos2Temp = 0;	   //充电正2温度(保留)
-UINT8 EBC_ChgNeg2Temp = 0;	   //充电负2温度(保留)
+UINT32 Can1InTable[1] =
+{
+	0x18FF1200,
+};
+BOOL Can1RxShortError[1];
+BOOL Can1RxLongError[1];
+UINT8 Can1RxErrorCounter[1];
+UINT8 Can1RxFlag[1];
 
-/*************************************************************
- *Ebc->Ble组码变量以及Ebc应用层变量存放区
+UINT8 chrgModulePwrCtrl = 0;		//充电模块总电源控制(交流接触器)XK36输出控制
+UINT8 baseSwitchCtrl = 0;			//底座/充电枪切换总控制(0X1切换到枪,充电停止状态可动作。0X0切换到底座,充电停止状态可动作。)
+UINT8 paraChrgCtrlState = 0;		//充电机并充控制状态
+UINT8 chrgStartState = 0;			//充电开始状态
+UINT8 chrgStopState = 0;			//充电停止状态
+/************************************************************
+ *BMC->CAN1解码变量存放区
  ************************************************************/
-uint8 g_c_BlePwr = 0;
-uint8 g_c_AirPwr = 0;
-uint8 g_c_LedPwr = 0;
-uint16 bcud_E_snglChrg; //单次充电能量,精度0.1kwh
+UINT32 Can1OutTable[4][4] =
+{
+		{0x18FF1100, 100},
+		{0x18FF1101, 100},
+		{0x18FF1102, 100},
+		{0x18FF1103, 100}
+};
+UINT8 connectorHvlock1 = 0;	  //动力连接器互锁信号1
+UINT8 connectorHvlock2 = 0;	  //动力连接器互锁信号2
+UINT8 chrgModuelPwrCtlFB = 0; //充电模块总电源控制反馈
+UINT8 paraChrgCtlFB = 0;	  //并充控制状态反馈
+UINT8 outToChrgCtlFB_A = 0;	  // A路至充电枪输出状态反馈
+UINT8 outToBaseCtlFB_A = 0;	  // A路至底座输出状态反馈
+UINT8 outToChrgCtlFB_B = 0;	  // B路至充电枪输出状态反馈
+UINT8 outToBaseCtlFB_B = 0;	  // B路至底座输出状态反馈
 
-uint16 bcud_pct_soc;		 //电池SOC,精度0.1
-uint16 bcud_Q_snglChrg;		 //单次充电容量,精度0.1Ah
-uint16 bcud_V_battU;		 //电池电压 精度0.1V
-uint32 bcud_E_accChrg;		 //累计充电能量,精度0.1kwh
-uint32 bcud_E_accDischrg;	 //累计放电能量,精度0.1kwh
-uint32 bcud_E_accPlugInChrg; //累计插枪充电能量,精度0.1kwh
-uint32 bcud_E_accRecovry;	 //累计回收能量,精度0.1kwh
-uint32 bcud_E_accSwapBatt;	 //累计换电站能量,精度0.1kwh
-uint32 bcud_Q_accChrg;		 //累计充电容量,精度0.1ah
-uint32 bcud_Q_accDischrg;	 //累计放电容量,精度0.1ah
-uint32 bcud_Q_accPlugInChrg; //累计插枪充电容量,精度0.1ah
-uint32 bcud_Q_accRecovry;	 //累计回收容量,精度0.1ah
-uint32 bcud_Q_accSwapBatt;	 //累计换电站容量,精度0.1ah
-uint32 vcud_M_accDrv;		 //累计行驶里程,精度0.1km
-uint8 bcud_pct_bcuSoh;		 //电池Soh,精度0.4%
-uint8 bcud_st_bcuComun;		 //电池通讯状态,0-通信中断,1-通信正常
-uint8 bcud_st_bcuMainRelay;	 //主继电器信号,0-保留 1-断开,2-关闭 3-异常
-uint8 bcud_st_bcuTmsLiquid;	 //热管理液位状态,1-液位正常,0-液位过低
-uint8 bcud_st_hvWork;		 //电池高压状态,0-高压开启 1-预充,2-高压关断,3-高压上电故障
-uint8 bcuv_Num_battSn[32];	 //电池SN号码
+UINT8 fuseActionFB_A = 0;	  // A路熔断器熔断反馈
+UINT8 fuseActionFB_B = 0;	  // B路熔断器熔断反馈
+UINT8 sigSwitchReadyFB_A = 0; // A路信号切换到位状态反馈
+UINT8 sigSwitchReadyFB_B = 0; // B路信号切换到位状态反馈
+UINT8 ctrlFXFB1 = 0;		  //执行气溶胶灭火装置1反馈
+UINT8 ctrlFXFB2 = 0;		  //执行气溶胶灭火装置2反馈
 
-uint8 vcud_P_airSensorBack;			   //后桥气压值,单位Mpa,精度0.01Mpa
-uint8 vcud_P_airSensorForward;		   //前桥气压值,单位Mpa,精度0.01Mpa
-uint8 vcud_st_carStart;				   //整车启动状态,0001-车辆启动状态,0010-熄火,0011-其他状态,1111-无效
-uint8 vcud_st_footbrake;			   //脚刹信号,0-无效,1-有效
-uint8 vcud_st_gear;					   //档位信号,FF-倒挡(R),0-空挡(N),X-前进档(DX)X取1-12
-uint8 vcud_st_handbrake;			   //手刹信号,0-无效,1-有效
-uint8 vcud_st_keyOn;				   //钥匙信号,1-上电,0-下电
-uint8 vcud_st_Steer;				   //方向盘信号,bit0-左侧转向灯,bit1-右侧转向灯,每bit 0-OFF,1-ON
-uint8 vcud_st_vcuComun;				   // vcu通讯状态,0-通信中断,1-通信正常
-uint8 vcuv_Num_vin[17];				   // VIN码
-uint8 bled_flg_lockCmd = 0;			   //锁钩电磁阀锁紧命令,1-有效,0-无效
-uint8 bled_flg_unlockCmd = 0;		   //锁钩电磁阀解锁命令,1-有效,0-无效
-uint8 bled_flg_lockCmdForce = 0;	   //锁钩电磁阀锁紧强制命令,1-有效,0-无效
-uint8 bled_flg_unlockCmdForce = 0;	   //锁钩电磁阀解锁强制命令,1-有效,0-无效
-uint8 bled_flg_topAscendCmd = 0;	   //顶板上升命令,1-有效,0-无效
-uint8 bled_flg_topDescendCmd = 0;	   //顶板下降命令,1-有效,0-无效
-uint8 bled_flg_topAscendCmdForce = 0;  //顶板强制上升命令,1-有效,0-无效
-uint8 bled_flg_topDescendCmdForce = 0; //顶板强制下降命令,1-有效,0-无效
-uint8 bled_flg_openDustReCmd = 0;	   //除尘打开指令,1-有效,0-无效
-uint8 bled_flg_closeDustReCmd = 0;	   //除尘关闭指令,1-有效,0-无效
-uint8 bled_flg_Heart = 0;			   //心跳维持指令
-uint8 bled_flg_getEbcData = 0;		   //获取ebc数据指令
-uint8 bled_flg_getVcuData = 0;		   //获取vcu数据指令
-uint8 bled_flg_getBmsData = 0;		   //获取bms数据指令
-uint8 bled_flg_handShake = 0;		   //握手指令
-uint8 bled_flg_swapBattDone = 0;	   //换电完成指令
-uint8 bled_flg_backToDrv = 0;		   //回到行驶状态指令
-uint8 bled_flg_autoLock = 0;		   //自动锁定指令
-uint8 bled_flg_autoUnlock = 0;		   //自动解锁指令
-uint8 bled_flg_toSwapMod = 0;		   //换到换电状态
-uint8 bled_flg_safeStopCmd = 0;		   //急停指令
-uint32 bled_Nr_softVer = 0;			   // BLE软件版本
-uint8 bled_flg_role = 0;			   // ble的主从模式 01-主,02-从
-uint8 bled_flg_bleConn = 0;			   // ble蓝牙连接状态
-uint8 bled_flg_bleDisconn = 0;		   // ble蓝牙断开状态
-uint8 bled_st_dataTrans = 0;		   //蓝牙数据传输状态
-/*
-ebc应用层变量
-*/
-uint8 ebcd_flg_Can2SendEnbale = 0;	 //应答BLE的使能
-uint8 ebcd_st_toBleAns = 0;			 //应答BLE的指令序号
-uint8 ebcd_P_airSensor = 0;			 //压力传感器气压值:单位Mpa,精度0.01Mpa
-uint8 ebcd_T_plugin[4] = {0};		 //四个接插件温度,加了偏移量40
-uint8 ebcd_flg_forbidHVOn = 0;		 //禁止高压上电 BMS
-uint8 ebcb_flg_reqHvOff = 0;		 //请求高压下电 BMS
-uint8 ebcd_flg_LockErr = 0;			 //锁紧机构故障状态,0-异常,1-正常
-uint8 ebcd_flg_dChrgLockErr = 0;	 //放电互锁故障状态
-uint8 ebcd_flg_chrgLockErr = 0;		 //充电互锁故障状态
-uint8 ebcd_flg_dChgCnctOverTemp = 0; //放电连接器过温标志
-uint8 ebcd_st_ebcWork = DriveMode;	 // Ebc当前状态 0-行车,1-通讯(握手才进入通讯状态),2-换电
-uint8 ebcd_Nr_errMax;				 //故障等级:当前故障最大等级
-uint8 ebcd_Num_faultCode;			 // ebc故障码,未定义
-uint8 ebcd_st_chargingMod;			 //充电模式,1-车载充电,2-换电站充电
-uint8 ebdc_st_lockUpState = 0;		 //锁止机构状态,0-故障,1-解锁成功,2-上锁成功
-uint8 ebdc_st_ConnecState = 0;		 //换电连接器状态(充电回路&放电回路同时闭合代表闭合,有一路断开则为断开),0_未连接 1_连接
-uint8 ebcd_flg_pluginLockSig;		 //互锁接插件信号状态,1-触发,0-无触发
-uint8 ebcd_flg_swapAdmit;			 //允许换电判断:0-不允许,1-允许
-uint8 ebcd_Num_err1;				 //故障码1
-uint8 ebcd_Num_err2;				 //故障码2
-uint8 ebcd_st_ebcConnect;			 // Ebc通讯模式,0-无线蓝牙,1-有线连接 ,默认0
-uint8 ebcd_st_ebcLockWork;			 // Ebc解锁模式,0-单步模式,1-自动模式
-uint8 ebcd_st_errTable1;			 //故障表1,bit0-气压异常,bit1-液位异常,bit2-Flash读取异常
-uint8 ebcd_st_errTable2;			 //故障表2,bit0-互锁异常,bit1-整车CAN异常,bit2-电池CAN异常,bit3-锁钩异常,bit4-升降机异常,bit5-电池位置异常
-uint8 ebcd_st_errTable3;			 //故障表3,bit0-放电互锁异常,bit1-充电互锁异常,bit2-整车高压互锁异常
-uint8 ebcd_st_lockSensor;			 //锁紧传感器信号:bit0-bit3:传感器0-3的状态每,bit:1-触发,0-不触发
-uint8 ebcd_st_lockSucJug;			 //锁紧完成判断:0-完全未锁紧,1-完全锁紧,2-未完全锁紧"
-uint8 ebcd_st_pedstSensor;			 //底座落座传感器:bit0-bit1:传感器0-1的状态,每bit:1-触发,0-无触发
-uint8 ebcd_st_pedstSucJug;			 //电池底座到位判断:0-完全未到位,1-完全到位,2-未完全到位
-uint8 ebcd_st_pluginLockSig;		 //互锁接插件信号具体状态,1-触发,0-无触发
-uint8 ebcd_st_unlockSensor;		 //解锁传感器信号:bit0-bit3:传感器0-3的状态每,bit:1-触发,0-不触发
-uint8 ebcd_st_unlockSucJug;			 //解锁完成判断:0-完全未解锁,1-完全解锁,2-未完全解锁
-uint8 m_flg_HVlock1 = 0;			 //互锁状态1,电池换电接插件
-uint8 m_flg_HVlock2 = 0;			 //互锁状态2,整车放电接插件
-uint16 Test_LockPressure = 0;		 //锁紧力测试
-uint8 ebcd_flg_ebcManCtrlEn = 0;	 // EBC手动控制使能
-uint8 ebcd_flg_ebcManCtrlMode = 0;	 // EBC手动控制模式
-uint8 BattHvCtl = 0;
+UINT8 conn1Temp1 = 0;		  //动力连接器1温度检测1
+UINT8 conn1Temp2 = 0;		  //动力连接器1温度检测2
+UINT8 conn2Temp1 = 0;		  //动力连接器2温度检测1
+UINT8 conn2Temp2 = 0;		  //动力连接器2温度检测2
+UINT8 chrgGunTemp1_A = 0;	  // A充电枪温度检测1
+UINT8 chrgGunTemp2_A = 0;	  // A充电枪温度检测2
+UINT8 chrgGunTemp1_B = 0;	  // B充电枪温度检测1
+UINT8 chrgGunTemp2_B = 0;	  // B充电枪温度检测2
+
+UINT8 chrgBoxTemp1 = 0;		  //充电仓温度1
+UINT8 chrgBoxTemp2 = 0;		  //充电仓温度2
+UINT8 chrgBoxGasOver1 = 0;	  //充电仓气体高 1
+UINT8 chrgBoxGasOver2 = 0;	  //充电仓气体高 2
+UINT8 chrgBoxFumesOver1 = 0;  //充电仓烟雾高1
+UINT8 chrgBoxFumesOver2 = 0;  //充电仓烟雾高2
+UINT8 chrgBox1Warning = 0;		//充电仓1预警等级
+UINT8 chrgBox2Warning = 0;		//充电仓2预警等级
 #define EEPDATA_START_SEC_VAR
 #include "MemMap.h"
-uint16 ebcd_Nr_swapBatt;	//换电次数
-uint16 ebcd_Nr_swapSucBatt; //换电成功次数
-uint16 ManuControlTimes = 0;
-uint16 LockDelayTime = 0;	//锁定延时时间(传感器到位以后延时多少时间确定为锁定成功
-uint16 UnlockDelayTime = 0; //解锁延时时间(传感器到位以后延时多少时间确定为解锁成功
-uint8 sfmv_Num_FltEEsave = 0;
+/*存储数据区*/
 #define EEPDATA_STOP_SEC_VAR
 #include "MemMap.h"
 #define APPLAYERVER_START_SEC_VAR
@@ -425,8 +126,5 @@ const uint32 R_table[240] = {125, 127, 129, 131, 133, 136, 138, 141, 143, 145, 1
 							 37558, 39315, 41166, 43117, 45174, 47343, 49633, 52049, 54599, 57293, 60140, 63148, 66329, 69693, 73252,
 							 77019, 81008, 85233, 89710, 94455, 99488, 104827, 110493, 116508, 122898, 129687, 136905, 144580,
 							 152746, 161438, 170694, 180554, 191063, 202269};
-
-const uint8 DataPackCounter[21] = {1, 1, 7, 5, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
-const uint8 DataPackBegin[21] = {0, 0x11, 0x21, 0x31, 0x40, 0x51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 #define APPLAYERVER_STOP_SEC_VAR
 #include "MemMap.h"

+ 66 - 353
System/Vehicle/Communication/CanVar.h

@@ -21,367 +21,80 @@
 #include "HardwareLib.h"
 #include "AppVar.h"
 /************************************************************
- *BCU->Ebc解码变量存放区
+ *CAN0->BMC解码变量存放区
  ************************************************************/
-extern UINT32 BcuInTable[28];
-extern BOOL BcuRxShortError[28];
-extern BOOL BcuRxLongError[28];
-extern UINT8 BcuRxErrorCounter[28];
-extern UINT8 BcuRxFlag[28];
-extern UINT8 BMS_ReqVIN;
-extern UINT8 BMS_ReqHVOff;
-extern UINT8 BMS_ProtocolEditionH;
-extern UINT8 BMS_ProtocolEditionL;
-extern UINT8 BMS_CharDevNum;
-extern UINT8 BMS_FtPosRly;
-extern UINT8 BMS_FtNegRly;
-extern UINT8 BMS_FtPosCharRly1;
-extern UINT8 BMS_FtNegCharRly1;
-extern UINT8 BMS_FtPosCharRly2;
-extern UINT8 BMS_FtNegCharRly2;
-extern UINT8 BMS_FtHeatRly1;
-extern UINT8 BMS_FtHeatRly2;
-extern UINT8 BMS_StPosRly;
-extern UINT8 BMS_StNegRly;
-extern UINT8 BMS_StPreCharRly;
-extern UINT8 BMS_StPosCharRly1;
-extern UINT8 BMS_StNegCharRly1;
-extern UINT8 BMS_StPosCharRly2;
-extern UINT8 BMS_StNegCharRly2;
-extern UINT8 BMS_FtAuxRelayWeld;
-extern UINT8 BMS_BraOpenCirc;
-extern UINT8 BMS_FtBackCharCurrOutLim;
-extern UINT8 BMS_FtPosRlyOpen;
-extern UINT8 BMS_FtNegRlyOpen;
-extern UINT8 BMS_FtPosCharRly1Open;
-extern UINT8 BMS_FtPosCharRly2Open;
-extern UINT8 BMS_FtNegCharRly1Open;
-extern UINT8 BMS_FtNegCharRly2Open;
-extern UINT8 BMS_FtTMSContClose;
-extern UINT8 BMS_FtTMSContOpen;
-extern UINT8 BMS_FtTMS;
-extern UINT8 BMS_Ft24VSpy;
-extern UINT8 BMS_FtPACKSelfProt;
-extern UINT8 BMS_FtCharSockTempOver;
-extern UINT8 BMS_FtTempOutCtrl;
-extern UINT8 BMS_StPosHeatRly;
-extern UINT8 BMS_StNegHeatRly;
-extern UINT8 BMS_CharSysNum;
-extern UINT8 BMS_FtCode;
-extern UINT8 BMS_ST1CheckSum;
-extern UINT8 BMS_ST1Counter;
-extern UINT8 BMS_Mode;
-extern UINT8 BMS_AuxRlySt;
-extern UINT8 BMS_BattBalaSt;
-extern UINT8 BMS_CharGunSt;
-extern UINT8 BMS_CharMode;
-extern UINT8 BMS_CharSt;
-extern UINT8 BMS_FtLvl;
-extern UINT8 BMS_FtCellTempDiff;
-extern UINT8 BMS_FtCellTempHigh;
-extern UINT8 BMS_FtPACKOverVolt;
-extern UINT8 BMS_FtPACKUndeVolt;
-extern UINT8 BMS_FtSOCLow;
-extern UINT8 BMS_FtCellOverVolt;
-extern UINT8 BMS_FtCellUndeVolt;
-extern UINT8 BMS_FtIns;
-extern UINT8 BMS_FtCellOverVoltDiff;
-extern UINT8 BMS_FtCharCurrOver;
-extern UINT8 BMS_FtDisCharCurrOver;
-extern UINT8 BMS_FtCellTempLow;
-extern UINT8 BMS_FtBranVoltDifOver;
-extern UINT8 BMS_FtBMSHardWare;
-extern UINT8 BMS_FtSOCHigh;
-extern UINT8 BMS_FtSOCJump;
-extern UINT8 BMS_FtInCom;
-extern UINT8 BMS_FtSysMism;
-extern UINT8 BMS_FtHvIntLock;
-extern UINT8 BMS_FtSmoke;
-extern UINT8 BMS_FtFire;
-extern UINT8 BMS_FtNum;
-extern UINT8 BMS_PackSOC;
-extern UINT8 BMS_PackSOH;
-extern UINT8 BMS_MaxCellTemp;
-extern UINT8 BMS_MinCellTemp;
-extern UINT8 BMS_AverCellTemp;
-extern UINT8 BMS_MaxCellTempCSC;
-extern UINT8 BMS_MaxCellTempNum;
-extern UINT8 BMS_MinCellTempCSC;
-extern UINT8 BMS_MinCellTempNum;
-extern UINT8 BMS_MaxCellVoltCSC;
-extern UINT8 BMS_MaxCellVoltNum;
-extern UINT8 BMS_MinCellVoltCSC;
-extern UINT8 BMS_MinCellVoltNum;
-extern UINT8 BMS_InsDeteSt;
-extern UINT8 BMS_FtCharInsLow;
-extern UINT8 BMS_FtCurrSenr;
-extern UINT8 BMS_FtHeatingFilm;
-extern UINT8 BMS_FtMainLoopPreChar;
-extern UINT8 BMS_FtAuxLoopPreChar;
-extern UINT8 BMS_FtACANLost;
-extern UINT8 BMS_FtDCDC;
-extern UINT8 BMS_FtSOCDif;
-extern UINT8 BMS_FtCellOverDisChar;
-extern UINT8 BMS_FtCharOver;
-extern UINT8 BMS_FtContDisCharCurrOverLoad;
-extern UINT8 BMS_FtContCharCurrOverLoad;
-extern UINT8 BMS_Gun1DCNegTemp;
-extern UINT8 BMS_Gun1DCPosTemp;
-extern UINT8 BMS_Gun2DCNegTemp;
-extern UINT8 BMS_Gun2DCPosTemp;
-extern UINT8 BMS_CurrHeatSt;
-extern UINT8 BMS_CurrCoolSt;
-extern UINT8 BMS_FtCharCnct;
-extern UINT8 BMS_FtOverDisCharCurrDuringChar;
-extern UINT8 BMS_FtCharNTC;
-extern UINT8 BMS_FtELock;
-extern UINT8 BMS_CellVoltFramNum;
-extern UINT8 BMS_CellTempFramNum;
-extern UINT8 BMS_CSC_Code;
-extern UINT8 BMS_CellTemp[64];
-extern UINT8 BMS_Checksum;
-extern UINT8 BMS_PackComp;
-extern UINT8 BMS_BattCodeLeng;
-extern UINT8 BMS_SN[27];
-extern UINT8 BMS_BattType;
-extern UINT8 BMS_CoolType;
-extern UINT8 BMS_CSC_Total;
-extern UINT8 BMS_CellVoltLevel;
-extern UINT8 BMS_CellMinVolt;
-extern UINT8 BMS_CellMaxVolt;
-extern UINT8 BMS_HVBranNum;
-extern UINT8 BMS_SingleHVBranchCellNum;
-extern UINT8 BMS_ReqMode;
-extern UINT8 BMS_HVCmd;
-extern UINT8 BMS_ChgSts;
-extern UINT8 BMS_HVRelaySts;
-extern UINT8 BMS_SetTemp;
-extern UINT8 BMS_Life;
-extern UINT8 BMS_CRC;
-extern UINT8 TMS_WorkStatus;
-extern UINT8 TMS_HVRelayST;
-extern UINT8 TMS_OutletTemp;
-extern UINT8 TMS_InletTemp;
-extern UINT8 TMS_ErrCode;
-extern UINT8 TMS_FaultLevel;
-extern UINT16 BMS_SoftwareVersion;
-extern UINT16 BMS_HardwareVersion;
-extern UINT16 BMS_PackCurr;
-extern UINT16 BMS_MaxCharCurr;
-extern UINT16 BMS_MaxDisCharCurr;
-extern UINT16 BMS_PosIns;
-extern UINT16 BMS_NegIns;
-extern UINT16 BMS_BattVolt;
-extern UINT16 BMS_LinkVolt;
-extern UINT16 BMS_MaxCellVolt;
-extern UINT16 BMS_AverCellVolt;
-extern UINT16 BMS_MinCellVolt;
-extern UINT16 BMS_ContChrgCurr;
-extern UINT16 BMS_ContDisCharCurr;
-extern UINT16 BMS_CharReqVolt;
-extern UINT16 BMS_CharReqCurr;
-extern UINT16 BMS_SysInsRes;
-extern UINT16 BMS_MaxDisCharPwr;
-extern UINT16 BMS_MaxCharPwr;
-extern UINT16 BMS_ContDisCharPwr;
-extern UINT16 BMS_ContCharPwr;
-extern UINT16 BMS_InstEngyCons;
-extern UINT16 BMS_TotalEngyCons;
-extern UINT16 BMS_SOE;
-extern UINT16 BMS_RmanCharTime;
-extern UINT16 BMS_CharNum;
-extern UINT16 BMS_CellVolt[384];
-extern UINT16 BMS_BattRateCap;
-extern UINT16 BMS_BattRateVolt;
-extern UINT16 BMS_BattRateEngy;
-extern UINT16 BMS_CellTotal;
-extern UINT16 BMS_TempTotal;
-extern UINT16 BMS_SingleCharEngy;
-extern UINT16 BMS_SingleCharCapy;
-extern UINT16 BMS_HVVolt;
-extern UINT16 TMS_ReqPow;
-extern UINT32 BMS_TotalCharEngy;
-extern UINT32 BMS_TotalDisCharEngy;
-extern UINT32 BMS_TotalBackCharEngy;
-extern UINT32 BMS_TotalStaCharEngy;
-extern UINT32 BMS_TotalGunCharEngy;
-extern UINT32 BMS_TotalGunCharCapy;
-extern UINT32 BMS_TotalCharCapy;
-extern UINT32 BMS_TotalDisCharCapy;
-extern UINT32 BMS_TotalBackCharCapy;
-extern UINT32 BMS_TotalStaCharCapy;
-/*Vcu->Ebc*********************************/
-extern UINT32 VcuInTable[4];
-extern UINT8 VcuRxFlag[4];
-extern BOOL VcuRxShortError[4];
-extern BOOL VcuRxLongError[4];
-extern UINT8 VcuRxErrorCounter[4];
-extern UINT8 VCU_Num_VIN[17];
-extern UINT8 VCU_St_VinRecv;
-extern UINT8 VCU_St_BattRly;
-extern UINT8 VCU_St_Check;
-extern UINT8 VCU_St_SysIntLock;
-extern UINT8 VCU_St_Veh;
-extern UINT8 VCU_St_Gear;
-extern UINT8 VCU_Ft_Sys;
-extern UINT8 VCU_Ft_Tran;
-extern UINT8 VCU_Ft_BattSys;
-extern UINT8 VCU_State_Veh;
-extern UINT8 VCU_Counter;
-extern UINT8 VCU_SoftVersion;
-extern UINT8 VCU_St_AccPedal;
-extern UINT8 VCU_St_BrakePedal;
-extern UINT8 VCU_St_ParkBrakeSw;
-/**********************************/
-extern UINT32 EbcOutTable[2][2];
-extern UINT8 EBC_Counter;
-extern UINT8 EBC_LockSt;
-extern UINT8 EBC_CnctSt;
-extern UINT8 EBC_DisCharCnctSt;
-extern UINT8 EBC_CharCnctSt;
-extern UINT8 EBC_FtLvl;
-extern UINT8 EBC_FtCode;
-extern UINT8 EBC_AirPressure;
-extern UINT8 EBC_CharSt;
-extern UINT8 EBC_ActHeatReq;
-extern UINT8 EBC_InhiHVOn;
-extern UINT8 EBC_ReqHVOff;
-extern UINT8 EBC_StopChgCmd;
-extern UINT8 EBC_State;
-extern UINT8 EBC_DisCharPos1Temp;
-extern UINT8 EBC_DischarNeg1Temp;
-extern UINT8 EBC_DisCharPos2Temp;
-extern UINT8 EBC_DisCharNeg2Temp;
-extern UINT8 EBC_ChgPos1Temp;
-extern UINT8 EBC_ChgNeg1Temp;
-extern UINT8 EBC_ChgPos2Temp;
-extern UINT8 EBC_ChgNeg2Temp;
+extern UINT32 Can0InTable[2];
+extern BOOL Can0RxShortError[2];
+extern BOOL Can0RxLongError[2];
+extern UINT8 Can0RxErrorCounter[2];
+extern UINT8 Can0RxFlag[2];
 
-/*************************************************************
- *Ebc->ble组码变量存放区
+extern UINT8 gashighLevel_gf1 ;
+extern UINT8 gaslowLevel_gf1 ;
+extern UINT8 temp_gf1 ;
+extern UINT8 warningLevel_gf1 ;
+extern UINT8 workMode_gf1 ;
+extern UINT8 fumesHigh_gf1 ;
+extern UINT8 fumesLow_gf1 ;
+extern UINT8 gashighLevel_gf2 ;
+extern UINT8 gaslowLevel_gf2 ;
+extern UINT8 temp_gf2 ;
+extern UINT8 warningLevel_gf2 ;
+extern UINT8 workMode_gf2 ;
+extern UINT8 fumesHigh_gf2 ;
+extern UINT8 fumesLow_gf2 ;
+/************************************************************
+ *CAN1->BMC解码变量存放区
  ************************************************************/
-// Ble
-extern uint16 bcud_E_snglChrg;		 //单次充电能量,精度0.1kwh
-extern uint16 bcud_pct_soc;			 //电池SOC,精度0.1
-extern uint16 bcud_Q_snglChrg;		 //单次充电容量,精度0.1Ah
-extern uint16 bcud_V_battU;			 //电池电压 精度0.1V
-extern uint32 bcud_E_accChrg;		 //累计充电能量,精度0.1kwh
-extern uint32 bcud_E_accDischrg;	 //累计放电能量,精度0.1kwh
-extern uint32 bcud_E_accPlugInChrg;	 //累计插枪充电能量,精度0.1kwh
-extern uint32 bcud_E_accRecovry;	 //累计回收能量,精度0.1kwh
-extern uint32 bcud_E_accSwapBatt;	 //累计换电站能量,精度0.1kwh
-extern uint32 bcud_Q_accChrg;		 //累计充电容量,精度0.1ah
-extern uint32 bcud_Q_accDischrg;	 //累计放电容量,精度0.1ah
-extern uint32 bcud_Q_accPlugInChrg;	 //累计插枪充电容量,精度0.1ah
-extern uint32 bcud_Q_accRecovry;	 //累计回收容量,精度0.1ah
-extern uint32 bcud_Q_accSwapBatt;	 //累计换电站容量,精度0.1ah
-extern uint32 vcud_M_accDrv;		 //累计行驶里程,精度0.1km
-extern uint8 bcud_pct_bcuSoh;		 //电池Soh,精度0.4%
-extern uint8 bcud_st_bcuComun;		 //电池通讯状态,0-通信中断,1-通信正常
-extern uint8 bcud_st_bcuMainRelay;	 //主继电器信号,0-保留 1-断开,2-关闭 3-异常
-extern uint8 bcud_st_bcuTmsLiquid;	 //热管理液位状态,1-液位正常,0-液位过低
-extern uint8 bcud_st_hvWork;		 //电池高压状态,0-高压开启 1-预充,2-高压关断,3-高压上电故障
-extern uint8 bcuv_Num_battSn[32];	 //电池SN号码
-extern uint8 ebcd_flg_pluginLockSig; //互锁接插件信号状态,1-触发,0-无触发
-extern uint8 ebcd_flg_swapAdmit;	 //允许换电判断:0-不允许,1-允许
-extern uint8 ebcd_Nr_errMax;		 //故障等级:当前故障最大等级
-extern uint8 ebcd_Num_err1;			 //故障码1
-extern uint8 ebcd_Num_err2;			 //故障码2
-extern uint8 ebcd_st_ebcConnect;	 // Ebc通讯模式,0-无线蓝牙,1-有线连接 ,默认0
-extern uint8 ebcd_st_ebcLockWork;	 // Ebc解锁模式,0-单步模式,1-自动模式
-extern uint8 ebcd_st_ebcWork;		 // Ebc当前状态 0-行车,1-通讯,2-换电
-extern uint8 ebcd_st_errTable1;		 //故障表1,bit0-气压异常,bit1-液位异常,bit2-Flash读取异常
-extern uint8 ebcd_st_errTable2;		 //故障表2,bit0-互锁异常,bit1-整车CAN异常,bit2-电池CAN异常,bit3-锁钩异常,bit4-升降机异常,bit5-电池位置异常
-extern uint8 ebcd_st_errTable3;		 //故障表3,bit0-放电互锁异常,bit1-充电互锁异常,bit2-整车高压互锁异常
-extern uint8 ebcd_st_lockSensor;	 //锁紧传感器信号:bit0-bit3:传感器0-3的状态每,bit:1-触发,0-不触发
-extern uint8 ebcd_st_lockSucJug;	 //锁紧完成判断:0-完全未锁紧,1-完全锁紧,2-未完全锁紧"
-extern uint8 ebcd_st_pedstSensor;	 //底座落座传感器:bit0-bit1:传感器0-1的状态,每bit:1-触发,0-无触发
-extern uint8 ebcd_st_pedstSucJug;	 //电池底座到位判断:0-完全未到位,1-完全到位,2-未完全到位
-extern uint8 ebcd_st_pluginLockSig;	 //互锁接插件信号具体状态,1-触发,0-无触发
-extern uint8 ebcd_st_unlockSensor;	 //解锁传感器信号:bit0-bit3:传感器0-3的状态每,bit:1-触发,0-不触发
-extern uint8 ebcd_st_unlockSucJug;	 //解锁完成判断:0-完全未解锁,1-完全解锁,2-未完全解锁
-// extern uint8 vcud_P_airSensor;            //压力传感器气压值:单位Mpa,精度0.01Mpa
-extern uint8 vcud_P_airSensorBack;		  //后桥气压值,单位Mpa,精度0.01Mpa
-extern uint8 vcud_P_airSensorForward;	  //前桥气压值,单位Mpa,精度0.01Mpa
-extern uint8 vcud_st_carStart;			  //整车启动状态,0001-车辆启动状态,0010-熄火,0011-其他状态,1111-无效
-extern uint8 vcud_st_footbrake;			  //脚刹信号,0-无效,1-有效
-extern uint8 vcud_st_gear;				  //档位信号,FF-倒挡(R),0-空挡(N),X-前进档(DX)X取1-12
-extern uint8 vcud_st_handbrake;			  //手刹信号,0-无效,1-有效
-extern uint8 vcud_st_keyOn;				  //钥匙信号,1-上电,0-下电
-extern uint8 vcud_st_Steer;				  //方向盘信号,bit0-左侧转向灯,bit1-右侧转向灯,每bit 0-OFF,1-ON
-extern uint8 vcud_st_vcuComun;			  // vcu通讯状态,0-通信中断,1-通信正常
-extern uint8 vcuv_Num_vin[17];			  // VIN码
-extern uint8 bled_flg_lockCmd;			  //锁钩电磁阀锁紧命令,1-有效,0-无效
-extern uint8 bled_flg_unlockCmd;		  //锁钩电磁阀解锁命令,1-有效,0-无效
-extern uint8 bled_flg_lockCmdForce;		  //锁钩电磁阀锁紧强制命令,1-有效,0-无效
-extern uint8 bled_flg_unlockCmdForce;	  //锁钩电磁阀解锁强制命令,1-有效,0-无效
-extern uint8 bled_flg_topAscendCmd;		  //顶板上升命令,1-有效,0-无效
-extern uint8 bled_flg_topDescendCmd;	  //顶板下降命令,1-有效,0-无效
-extern uint8 bled_flg_topAscendCmdForce;  //顶板强制上升命令,1-有效,0-无效
-extern uint8 bled_flg_topDescendCmdForce; //顶板强制下降命令,1-有效,0-无效
-extern uint8 bled_flg_openDustReCmd;	  //除尘打开指令,1-有效,0-无效
-extern uint8 bled_flg_closeDustReCmd;	  //除尘关闭指令,1-有效,0-无效
-extern uint8 bled_flg_Heart;			  //心跳维持指令
-extern uint8 bled_flg_getEbcData;		  //获取ebc数据指令
-extern uint8 bled_flg_getVcuData;		  //获取vcu数据指令
-extern uint8 bled_flg_getBmsData;		  //获取bms数据指令
-extern uint8 bled_flg_handShake;		  //握手指令
-extern uint8 bled_flg_swapBattDone;		  //换电完成指令
-extern uint8 bled_flg_backToDrv;		  //回到行驶状态指令
-extern uint8 bled_flg_autoLock;			  //自动锁定指令
-extern uint8 bled_flg_autoUnlock;		  //自动解锁指令
-extern uint8 bled_flg_toSwapMod;		  //换到换电状态
-extern uint8 bled_flg_safeStopCmd;		  //急停指令
-extern uint32 bled_Nr_softVer;			  // BLE软件版本
-extern uint8 bled_flg_role;				  // ble的主从模式 01-主,02-从
-extern uint8 bled_flg_bleConn;			  // ble蓝牙连接状态
-extern uint8 bled_flg_bleDisconn;		  // ble蓝牙断开状态
-extern uint8 bled_st_dataTrans;			  //蓝牙数据传输状态
-//正式变量
-typedef enum
-{
-	DriveMode = 0,
-	CommuMode = 1,
-	SwapMode = 2
-} WorkType;
-extern uint8 ebcd_flg_Can2SendEnbale;
-extern uint8 ebcd_st_toBleAns;
-extern uint8 ebcd_P_airSensor;
-extern uint8 ebcd_T_plugin[4];			//四个接插件温度
-extern uint8 ebcd_flg_forbidHVOn;		//禁止高压上电
-extern uint8 ebcb_flg_reqHvOff;			//请求高压下电
-extern uint8 ebcd_flg_LockErr;			//锁紧机构故障状态
-extern uint8 ebcd_flg_dChrgLockErr;		//放电互锁故障状态
-extern uint8 ebcd_flg_chrgLockErr;		//充电互锁故障状态
-extern uint8 ebcd_flg_dChgCnctOverTemp; //放电连接器过温标志
-extern uint8 ebcd_st_ebcWork;			// Ebc当前状态 0-行车,1-通讯,2-换电
-extern uint8 ebcd_Nr_errMax;			//故障等级:当前故障最大等级
-extern uint8 ebcd_Num_faultCode;		// ebc故障码,未定义
-extern uint8 ebcd_st_chargingMod;		//充电模式,1-车载充电,2-换电站充电
-extern uint8 ebdc_st_lockUpState;		//锁止机构状态,0-故障,1-解锁成功,2-上锁成功
-extern uint8 ebdc_st_ConnecState;		//换电连接器状态(充电回路&放电回路同时闭合代表闭合,有一路断开则为断开),0_未连接 1_连接
-extern uint8 m_flg_HVlock1;				//互锁状态1
-extern uint8 m_flg_HVlock2;				//互锁状态2
-extern uint16 Test_LockPressure;
-extern uint8 BattHvCtl;
-
-
-
+extern UINT32 Can1InTable[1];
+extern BOOL Can1RxShortError[1];
+extern BOOL Can1RxLongError[1];
+extern UINT8 Can1RxErrorCounter[1];
+extern UINT8 Can1RxFlag[1];
+extern UINT8 chrgModulePwrCtrl ;
+extern UINT8 baseSwitchCtrl ;
+extern UINT8 paraChrgCtrlState ;
+extern UINT8 chrgStartState ;
+extern UINT8 chrgStopState ;
+/************************************************************
+ *BMC->CAN2解码变量存放区
+ ************************************************************/
+extern UINT32 Can1OutTable[4][4];
+extern UINT8 connectorHvlock1;
+extern UINT8 connectorHvlock2;
+extern UINT8 chrgModuelPwrCtlFB;
+extern UINT8 paraChrgCtlFB;
+extern UINT8 outToChrgCtlFB_A ;
+extern UINT8 outToBaseCtlFB_A ;
+extern UINT8 outToChrgCtlFB_B ;
+extern UINT8 outToBaseCtlFB_B ;
+extern UINT8 fuseActionFB_A ;
+extern UINT8 fuseActionFB_B ;
+extern UINT8 sigSwitchReadyFB_A ;
+extern UINT8 sigSwitchReadyFB_B ;
+extern UINT8 ctrlFXFB1 ;
+extern UINT8 ctrlFXFB2 ;
+extern UINT8 conn1Temp1 ;
+extern UINT8 conn1Temp2 ;
+extern UINT8 conn2Temp1 ;
+extern UINT8 conn2Temp2 ;
+extern UINT8 chrgGunTemp1_A;
+extern UINT8 chrgGunTemp2_A ;
+extern UINT8 chrgGunTemp1_B;
+extern UINT8 chrgGunTemp2_B ;
+extern UINT8 chrgBoxTemp1 ;
+extern UINT8 chrgBoxTemp2 ;
+extern UINT8 chrgBoxGasOver1 ;
+extern UINT8 chrgBoxGasOver2 ;
+extern UINT8 chrgBoxFumesOver1 ;
+extern UINT8 chrgBoxFumesOver2 ;
+extern UINT8 chrgBox1Warning ;
+extern UINT8 chrgBox2Warning ;
 #define EEPDATA_START_SEC_VAR
 #include "MemMap.h"
-extern uint16 ebcd_Nr_swapBatt;		  //换电次数
-extern uint16 ebcd_Nr_swapSucBatt;	  //换电成功次数
-extern uint8 ebcd_flg_ebcManCtrlEn;	  // EBC手动控制使能
-extern uint8 ebcd_flg_ebcManCtrlMode; // EBC手动控制模式
-extern uint16 LockDelayTime;		  //锁定延时时间(传感器到位以后延时多少时间确定为锁定成功
-extern uint16 UnlockDelayTime;		  //解锁延时时间(传感器到位以后延时多少时间确定为解锁成功
-extern uint16 ManuControlTimes;
 
-extern uint8 sfmv_Num_FltEEsave;
 #define EEPDATA_STOP_SEC_VAR
 #include "MemMap.h"
 extern const uint8 T_table[240];
 extern const uint32 R_table[240];
-extern const uint8 DataPackCounter[21];
-extern const uint8 DataPackBegin[21];
 #endif /* SYSTEM_VEHICLE_COMMUNICATION_CANVAR_H_ */

+ 0 - 129
System/Vehicle/Communication/VcuCanProtocolFunc.c

@@ -1,129 +0,0 @@
-/*
- * @Author       : ChenJie
- * @Date         : 2021-12-24 15:26:57
- * @Version      : V3.0
- * @LastEditors  : ChenJie
- * @LastEditTime : 2022-05-09 16:13:46
- * @Description  : file content
- * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\VcuCanProtocolFunc.c
- */
-#include "VcuCanProtocolFunc.h"
-void VcuDecodeFunction(UINT32 ID, UINT8 *rawData)
-{
-	switch (ID)
-	{
-	case 0x18F101D0:
-		VCU_St_BattRly = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0x3);
-		VCU_St_Check = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
-		VCU_St_SysIntLock = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 4) & 0x3);
-		VCU_St_Veh = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 6) & 0x3);
-		VCU_St_Gear = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-		VCU_Ft_Sys = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x1);
-		VCU_Ft_Tran = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 1) & 0x1);
-		VCU_Ft_BattSys = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 5) & 0x1);
-		VCU_State_Veh = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xF);
-		VCU_Counter = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
-		VcuRxFlag[0] = 0x01;
-		break;
-	case 0x18F103D0:
-		VCU_SoftVersion = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		VCU_St_AccPedal = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
-		VCU_St_BrakePedal = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
-		VcuRxFlag[1] = 0x01;
-		break;
-	case 0x18E1F3D0:
-	{
-		UINT8 VinNum = 0;
-		VinNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
-		if (VinNum == 0 || VinNum > 3)
-		{
-			break;
-		}
-		VCU_St_VinRecv = ((VinNum == 1) | ((VinNum == 2) << 1) | ((VinNum == 3) << 2)) | VCU_St_VinRecv;
-		for (UINT8 i = 0; i < 7; i++)
-		{
-			if(((VinNum - 1) * 7 + i) < 17)
-			{
-				VCU_Num_VIN[(VinNum - 1) * 7 + i] = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF);;
-			}
-		}
-		VcuRxFlag[2] = 0x01;
-		break;
-	}
-	case 0x18FEF100:
-		VCU_St_ParkBrakeSw = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
-		VcuRxFlag[3] = 0x01;
-		break;
-	default:
-		break;
-	}
-}
-void VcuRxDiagnose(void)
-{
-	static UINT16 TimeCounter = 0;
-	TimeCounter = TimeCounter + 10;
-	for (UINT8 i = 0; i < sizeof(VcuInTable) / 4; i++)
-	{
-		if (VcuRxFlag[i] == 1) // received msg, and clear the error conter
-		{
-			VcuRxErrorCounter[i] = 0;
-			VcuRxFlag[i] = 0;
-			continue;
-		}
-		if (VcuRxErrorCounter[i] < 3)
-		{
-			VcuRxShortError[i] = 0;
-			VcuRxLongError[i] = 0;
-		}
-		else if (VcuRxErrorCounter[i] >= 3 && VcuRxErrorCounter[i] < 13)
-		{
-			VcuRxShortError[i] = 1;
-			VcuRxLongError[i] = 0;
-		}
-		else if (VcuRxErrorCounter[i] >= 13)
-		{
-			VcuRxShortError[i] = 0;
-			VcuRxLongError[i] = 1;
-			VcuRxMsgSetInvalidValue(VcuInTable[i]);
-			VcuRxErrorCounter[i] = 0;
-		}
-		else if (VcuRxErrorCounter[i] == 0xFF)
-		{
-			VcuRxErrorCounter[i] = 0xFE;
-		}
-	}
-	if (TimeCounter % 100 == 0) // period <=100ms
-	{
-		VcuRxErrorCounter[0]++; // can msg 0x18F101D0
-		// if(canRxErrorCounter[0]>=13)
-		VcuRxErrorCounter[1]++; // can msg 0x18F103D0
-								// if(canRxErrorCounter[1]>=13)
-	}
-}
-void VcuRxMsgSetInvalidValue(UINT32 ID)
-{
-	switch (ID)
-	{
-	case 0x18F101D0:
-		VCU_St_BattRly = 0xFF;
-		VCU_St_Check = 0xFF;
-		VCU_St_SysIntLock = 0xFF;
-		VCU_St_Veh = 0xFF;
-		VCU_St_Gear = 0xFF;
-		VCU_Ft_Sys = 0xFF;
-		VCU_Ft_Tran = 0xFF;
-		VCU_Ft_BattSys = 0xFF;
-		VCU_State_Veh = 0xFF;
-		VCU_Counter = 0xFF;
-		break;
-	case 0x18F103D0:
-		VCU_SoftVersion = 0xFF;
-		VCU_St_AccPedal = 0xFF;
-		VCU_St_BrakePedal = 0xFF;
-		break;
-	case 0x18FEF100:
-		break;
-	default:
-		break;
-	}
-}

+ 0 - 14
System/Vehicle/Communication/VcuCanProtocolFunc.h

@@ -1,14 +0,0 @@
-/*
- * @Author       : ChenJie
- * @Date         : 2021-12-24 15:26:57
- * @Version      : V3.0
- * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-27 16:11:49
- * @Description  : file content
- * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\VcuCanProtocolFunc.h
- */
-#include "CanVar.h"
-void VcuDecodeFunction(UINT32 ID, UINT8 *rawData);
-void VcuRxDiagnose(void);
-void VcuRxMsgSetInvalidValue(UINT32 ID);
-void VcuEncodeFunction(UINT32 ID, UINT8 *rawData);

+ 12 - 43
System/Vehicle/VehCo.c

@@ -71,40 +71,20 @@ void VehCo_Init(void)
     VehCo_pBootloaderUIP = (uint32)Bootloader_Entry;
 #endif
 
-/*********************************************************************************************/
-/*示例代码*/
-#ifdef _SAMPLE_CODE_
-    AccPedCD_Init();
-    // VehCo_uAccPedUW = 0;
-#endif //_SAMPLE_CODE_
-       /*********************************************************************************************/
-
     CANNet_Init();
 
-    /*打开强电主继电器*/
-    PSwtDrv_Interface(_PSWT_INDEX_MAINRELAY_CHAN, 1);
-    //打开蓝牙电源
-    PSwtDrv_Interface(_PSWT_INDEX_BLEPWRCONTROL, 1);
+//    /*打开强电主继电器*/
+//    PSwtDrv_Interface(_PSWT_INDEX_MAINRELAY_CHAN, 1);
+//    //打开蓝牙电源
+//    PSwtDrv_Interface(_PSWT_INDEX_BLEPWRCONTROL, 1);
 }
 
 //整车管理10ms基准运行任务
 void VehCo_Manage10ms(void)
 {
-/*********************************************************************************************/
-/*样例代码*/
-#ifdef _SAMPLE_CODE_
-    static UINT16 TimerMs = 0;
-    TimerMs = TimerMs + 10;
+	Can0RxDiagnose();
+//	Can1RxDiagnose();
     VehCo_Ctrl();
-    VcuRxDiagnose();
-    BcuRxDiagnose();
-    if (TimerMs % 100 == 0)
-    {
-        //FaultDiagnosisFunc();//此处有重启问题,待排查
-    }
-
-#endif //_SAMPLE_CODE_
-    /*********************************************************************************************/
 }
 
 //整车管理1ms基准运行任务
@@ -130,24 +110,15 @@ uint8 VehCo_Afterrun(void)
     else
     {
 //进入停机关电准备
-
-/*样例代码*/
-#ifdef _SAMPLE_CODE_
-
-        VehCo_Ctrl();
-
-#endif //_SAMPLE_CODE_
-        {
-            stRetUB = 1;
-        }
+	VehCo_Ctrl();
+	{
+		stRetUB = 1;
+	}
     }
     return stRetUB;
 }
 
 /*********************************************************************************************/
-/*样例代码*/
-#ifdef _SAMPLE_CODE_
-
 void VehCo_Ctrl(void)
 {
     /*在CAN唤醒的情况下,由上层算法决定CAN唤醒过程结束*/
@@ -159,10 +130,8 @@ void VehCo_Ctrl(void)
         }
     }
     /*正式程序开始*/
-    GetHVLockState();
-    GetDIOState();
     GetAIOValue();
-    LockAndUnlockCtrl();
+    GetDIOState();
+    ctrlFunc();
 }
-#endif //_SAMPLE_CODE_
 /*********************************************************************************************/

+ 1 - 2
System/Vehicle/VehCo.h

@@ -26,8 +26,7 @@
 #define __VEHCO_H
 #include "Std_Types.h"
 #include <AppFunc.h>
-#include "VcuCanProtocolFunc.h"
-#include "BcuCanProtocolFunc.h"
+#include "CanProtocolFunc.h"
 #include "CanVar.h"
 /********************************************************/
 /*ÉϲãÓëµ×²ãµÄµ÷¶È½Ó¿Ú*/