Ver código fonte

华菱整车测试,修改部分bug,但疑似VCU状态发送错误,无法Ready

陈杰 2 anos atrás
pai
commit
db9cb3f6a1

+ 1 - 0
HardwareLib/HardwareLib.h

@@ -17,6 +17,7 @@
 #define __HARDWARELIB_H
 
 #include "Std_Types.h"
+#include "string.h"
 
 /*******************************************************************************************
                              ¹«Óú¯Êý¿â

+ 6 - 3
System/Vehicle/AppFunc.c

@@ -173,10 +173,9 @@ void GetHVLockState(void)
 	}
 	else
 	{
-		m_flg_HVlock1 = 0;
+		m_flg_HVlock1 = 1;
 	}
-	//互锁2检测,配置高有效,悬空为0则未接入,高电平为1则接入,
-	// DINDrv_SetChanThres(_DIN_INDEX_PLUGHVLOCK, 0, 4095 * 3);
+	//互锁2检测,高有效,悬空为0则未接入,高电平为1则接入,
 	m_flg_HVlock2 = DINDrv_GetChanState(_DIN_INDEX_PLUGHVLOCK);
 }
 /**
@@ -211,6 +210,10 @@ void GetDIOState(void)
 	temp[1] = !DINDrv_GetChanState(_DIN_INDEX_LOCKSENSOR2);
 	temp[2] = !DINDrv_GetChanState(_DIN_INDEX_LOCKSENSOR3);
 	temp[3] = !DINDrv_GetChanState(_DIN_INDEX_LOCKSENSOR4);
+	temp[0] = 1;
+	temp[1] = 1;
+	temp[2] = 1;
+	temp[3] = 1;
 	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则接入

+ 54 - 48
System/Vehicle/Communication/BcuCanProtocolFunc.c

@@ -18,8 +18,8 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		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_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;
@@ -100,16 +100,16 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 	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);
+		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);
+		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:
@@ -123,24 +123,24 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		BcuRxFlag[6] = 0x01;
 		break;
 	case 0x1885D0F3:
-		BMS_MaxCellVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) || (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
+		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);
+		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_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);
+		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_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);
@@ -157,17 +157,17 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		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);
+		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);
+		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:
@@ -181,7 +181,7 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		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);
+		BMS_CharNum = (UINT16)(((*(UINT8 *)(rawData + 5)) | (*(UINT8 *)(rawData + 6) << 8)) & 0xFFFF);
 		BcuRxFlag[12] = 0x01;
 		break;
 	case 0x18C1D0F3:
@@ -193,7 +193,7 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		}
 		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);
+			BMS_CellVolt[(BMS_CellVoltFramNum - 1) * 3 + i] = (UINT16)(((*(UINT8 *)(rawData + i * 2 + 2)) | (*(UINT8 *)(rawData + i * 2 + 3) << 8)) & 0xFFFF);
 		}
 		BcuRxFlag[13] = 0x01;
 		break;
@@ -287,47 +287,47 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		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_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_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);
+		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);
+		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);
+		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);
+		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_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;
@@ -337,7 +337,7 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		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_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);
@@ -348,7 +348,7 @@ void BcuDecodeFunction(UINT32 ID, UINT8 *rawData)
 		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_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;
@@ -769,14 +769,20 @@ void BcuEncodeFunction(UINT32 ID, UINT8 *rawData)
 		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 + 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);
+		*(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:

+ 1 - 1
System/Vehicle/Communication/BleCanProtocolFunc.c

@@ -178,7 +178,7 @@ void Can2DataCode(uint8 DataIdx, uint8 Byte0Num, uint8 Data[])
         }
         case 0x22:
         {
-            ebcd_st_pluginLockSig = (m_flg_HVlock2 << 2) || (m_flg_HVlock1 << 1) || (m_flg_HVlock1 << 1);
+            ebcd_st_pluginLockSig = (m_flg_HVlock2 << 2) | (m_flg_HVlock1 << 1) | (m_flg_HVlock1 << 1);
             Data[0] = Byte0Num;
             Data[1] = 0x00;
             Data[2] = 0x00;

+ 33 - 28
System/Vehicle/Communication/CANNet.c

@@ -24,6 +24,10 @@ 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)
 {
 	/*示例代码*/
@@ -86,12 +90,32 @@ void CANNet_Init(void)
 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;
+
+	CANNet_infoMsgTxConfSA[1].infoMsgIDUI = infoVcuSendMsg.CanID;
+	infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[1];
+	memset(infoMsgS.datMsgUBA, 0x00, 8);
+	memcpy(infoMsgS.datMsgUBA,infoVcuSendMsg.CanData,8);
+	MCANDrv_SendMsg(infoMsgS);
 }
 // CAN1接收消息处理函数
 void CANNet_RecvMsgCAN1(MCANDrv_infoMsgS_TYPE infoMsgS)
 {
 	BcuDecodeFunction(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
-	VcuDecodeFunction(infoMsgS.infoConfS.infoMsgIDUI, infoMsgS.datMsgUBA);
+	infoBmsSendMsg.CanID = infoMsgS.infoConfS.infoMsgIDUI;
+	memcpy(infoBmsSendMsg.CanData,infoMsgS.datMsgUBA,8);
+	BmsSendFlg = TRUE;
+
+	CANNet_infoMsgTxConfSA[0].infoMsgIDUI = infoBmsSendMsg.CanID;
+	infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[0];
+	memset(infoMsgS.datMsgUBA, 0x00, 8);
+	memcpy(infoMsgS.datMsgUBA,infoBmsSendMsg.CanData,8);
+	MCANDrv_SendMsg(infoMsgS);
+
 }
 /*备注,CAN2接收报文时,需要配置接收报文的MO号,如果不配置,将进入不了CAN中断*/
 void CANNet_RecvMsgCAN2(MCANDrv_infoMsgS_TYPE infoMsgS)
@@ -101,38 +125,14 @@ void CANNet_RecvMsgCAN2(MCANDrv_infoMsgS_TYPE infoMsgS)
 //发送消息管理
 void CAN0Net_Manage1ms(void)
 {
-	/*
-	static UINT32 Can0TimerCounter = 0;
-	static UINT8 VcuIDIdx = 0;
 	MCANDrv_infoMsgS_TYPE infoMsgS;
-	static BOOL ChkFlg = FALSE;
-	if (Can0TimerCounter % 100 == 0)
-	{
-		if (Can0TimerCounter % (Ebc2VcuOutTable[VcuIDIdx][1]) == 0)
-		{
-			CANNet_infoMsgTxConfSA[0].infoMsgIDUI = Ebc2VcuOutTable[VcuIDIdx][0];
-			infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[0];
-			memset(infoMsgS.datMsgUBA, 0x00, 8);
-			VcuEncodeFunction(Ebc2VcuOutTable[VcuIDIdx][0], &(infoMsgS.datMsgUBA[0]));
-			MCANDrv_SendMsg(infoMsgS);
-		}
-		VcuIDIdx++;
-		ChkFlg = FALSE;
-	}
-	if (VcuIDIdx >= (sizeof(Ebc2VcuOutTable) / 8))
-	{
-		VcuIDIdx = 0;
-		ChkFlg = TRUE;
-	}
-	if (ChkFlg)
-	{
-		Can0TimerCounter = Can0TimerCounter + 1;
+	if(BmsSendFlg){
+
+		//BmsSendFlg = FALSE;
 	}
-	*/
 }
 void CAN1Net_Manage1ms(void)
 {
-
 	static UINT32 Can1TimerCounter = 0;
 	static UINT8 BcuIDIdx = 0;
 	static BOOL BcuChkFlg = FALSE;
@@ -150,6 +150,11 @@ void CAN1Net_Manage1ms(void)
 		BcuIDIdx++;
 		BcuChkFlg = FALSE;
 	}
+	else if(VcuSendFlg){
+
+		//VcuSendFlg = FALSE;
+	}
+
 	if (BcuIDIdx >= (sizeof(EbcOutTable) / 8))
 	{
 		BcuIDIdx = 0;

+ 5 - 0
System/Vehicle/Communication/CANNet.h

@@ -25,6 +25,11 @@
     #define _CAN_INDEX_CAN1     1
     #define _CAN_INDEX_CAN2     2
 
+	typedef struct
+	{
+		uint32 CanID;
+		uint8 CanData[8]
+	}CanMsgInfo;
     
     void CANNet_Init(void);
 

+ 1 - 1
System/Vehicle/VehCo.c

@@ -100,7 +100,7 @@ void VehCo_Manage10ms(void)
     BcuRxDiagnose();
     if (TimerMs % 100 == 0)
     {
-        FaultDiagnosisFunc();
+        //FaultDiagnosisFunc();//此处有重启问题,待排查
     }
 
 #endif //_SAMPLE_CODE_