LAPTOP-KB7QFH2U\ChenJie-PC před 1 rokem
rodič
revize
81995f9825

+ 93 - 114
System/Vehicle/Communication/BleCanProtocolFunc.c

@@ -20,121 +20,100 @@
  * @param {uint8} CmdIdx
  * @return {*}
  */
-void Can2ProtocolCode(uint8 CmdIdx, uint8 DataIdx, uint8 Byte0Num, uint32 *InnerCanID, uint8 *Data)
+void Can2EncodeFunction(UINT32 ID, UINT8 *rawData)
 {
-    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;
-    }
+	uint8 Crc = 0;
+	static uint8 lifeTime = 0;
+	switch(ID)
+	{
+	case 0x1C00EBEC:
+	{
+		lifeTime = lifeTime+1<15? lifeTime+1 : 0;
+		*(rawData + 1) = lifeTime;
+		*(rawData + 2) = rted_st_bleConnCtrlCmd;
+		*(rawData + 3) = rted_st_blePwrCtrlCmd;
+		*(rawData + 4) = rted_st_wifiConnCtrlCmd;
+		*(rawData + 5) = rted_st_wifiPwrCtrlCmd;
+		*(rawData + 6) = 0;
+		*(rawData + 7) = 0;
+		for(uint8 i=1;i<8;i++)
+		{
+			Crc = Crc^(*(rawData + i));
+		}
+		*(rawData + 0) = Crc;
+		break;
+	}
+	case 0x1C01EBEC:
+	{
+		*(rawData + 0) = rted_st_ebcWorkMode;
+		*(rawData + 1) = rted_st_ebcCommMode;
+		*(rawData + 2) = rted_st_ebcManuMode;
+		*(rawData + 3) = rted_st_ebcPlugType;
+		*(rawData + 4) = rted_flg_ebcAllWOper;
+		*(rawData + 5) = 0;
+		*(rawData + 6) = 0;
+		*(rawData + 7) = 0;
+		break;
+	}
+	case 0x1C02EBEC:
+	{
+		break;
+	}
+	case 0x1C12EBEC:
+	{
+		break;
+	}
+	case 0x1C03EBEC:
+	{
+		break;
+	}
+	case 0x1C04EBEC:
+	{
+		break;
+	}
+	case 0x1C05EBEC:
+	{
+		break;
+	}
+	case 0x1C06EBEC:
+	{
+		break;
+	}
+	case 0x1C07EBEC:
+	{
+		break;
+	}
+	case 0x1C08EBEC:
+	{
+		break;
+	}
+	case 0x1C09EBEC:
+	{
+		break;
+	}
+	case 0x1C0AEBEC:
+	{
+		break;
+	}
+	case 0x1C0BEBEC:
+	{
+		break;
+	}
+	case 0x1C0CEBEC:
+	{
+		break;
+	}
+	case 0x1C0DEBEC:
+	{
+		break;
+	}
+	case 0x1C0EEBEC:
+	{
+		break;
+	}
+	default:
+		break;
+	}
 }
 /**
  * @brief : ebc对ble的数据应答,Ebc data ->Ble data

+ 19 - 19
System/Vehicle/Communication/CANNet.c

@@ -222,29 +222,29 @@ 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)
+	static uint8 Can2SendIdx = 0;
+	BOOL Can2SendChkFlg = 0;
+	if (Can2TimerCounter % 100 == 0)
 	{
-		if (AnsNum < DataPackCounter[DataIdx])
+		if (Can2TimerCounter % (Can2OutTable[Can2SendIdx][1]) == 0)
 		{
-			Can2ProtocolCode(cmdIdx, DataIdx, (DataPackBegin[DataIdx] + AnsNum), &(CANNet_infoMsgTxConfSA[2].infoMsgIDUI), &(infoMsgS.datMsgUBA[0]));
+			CANNet_infoMsgTxConfSA[2].infoMsgIDUI = Can2OutTable[Can2SendIdx][0];
 			infoMsgS.infoConfS = CANNet_infoMsgTxConfSA[2];
+			memset(infoMsgS.datMsgUBA, 0x00, 8);
+			Can2EncodeFunction(Can2OutTable[Can2SendIdx][0], &(infoMsgS.datMsgUBA[0]));
 			MCANDrv_SendMsg(infoMsgS);
-			AnsNum++;
-			AnsInterval = 0;
-		}
-		else
-		{
-			AnsNum = 0;
-			ebcd_st_toBleAns = 0;
-			ebcd_flg_Can2SendEnbale = FALSE;
 		}
+		Can2SendIdx++;
+		Can2SendChkFlg = FALSE;
 	}
+	if (Can2SendIdx >= (sizeof(Can2OutTable) / 8))
+	{
+		Can2SendIdx = 0;
+		Can2SendChkFlg = TRUE;
+	}
+	if (Can2SendChkFlg)
+	{
+		Can2TimerCounter = Can2TimerCounter + 1;
+	}
+
 }

+ 83 - 4
System/Vehicle/Communication/CanVar.c

@@ -6,6 +6,89 @@
  *      Author: QiXiang_CHENJIE
  */
 #include "CanVar.h"
+/******************************CAN2变量区域****************************************/
+UINT32 Can2OutTable[16][2] =
+	{{0x1C00EBEC, 100},
+	 {0x1C01EBEC, 100},
+	 {0x1C02EBEC, 100},
+	 {0x1C03EBEC, 100},
+	 {0x1C04EBEC, 100},
+	 {0x1C05EBEC, 100},
+	 {0x1C06EBEC, 100},
+	 {0x1C07EBEC, 100},
+	 {0x1C08EBEC, 100},
+	 {0x1C09EBEC, 100},
+	 {0x1C0AEBEC, 100},
+	 {0x1C0BEBEC, 100},
+	 {0x1C0CEBEC, 100},
+	 {0x1C0DEBEC, 100},
+	 {0x1C0EEBEC, 100},
+	 {0x1C12EBEC, 100}};
+
+/*Can变量区
+uint8 cand_st_bleConnCtrlCmd = 0;	//蓝牙连接控制,0-无操作 1-连接蓝牙 2-断开蓝牙
+uint8 cand_st_blePwrCtrlCmd = 0;		//蓝牙电源控制,0-无操作 1-关闭蓝牙 2-开启蓝牙
+uint8 cand_st_wifiConnCtrlCmd = 0;	//WiFi连接控制,0-无操作 1-连接WiFi 2-断开WiFI
+uint8 cand_st_wifiPwrCtrlCmd = 0;	//WIFI电源控制,0-无操作 1-关闭WiFI 2-开启WiFI
+
+uint8 cand_st_ebcWorkMode = 0;	//换电当前状态,0-行车 1-通信 2-换电
+uint8 cand_st_ebcCommMode = 0;	//换电通讯状态,0-无线蓝牙 1-有线连接 默认无线连接
+uint8 cand_st_ebcManuMode = 0;	//换电操作状态,0-单步模式 1-自动模式 默认为单步模式
+uint8 cand_st_ebcPlugType = 0;	//连接器类型,0-四连接器 1-单连接器
+uint8 cand_flg_ebcAllWOper = 0;	//允许换电判断,0-不允许 1-允许
+
+uint8 cand_st_unlockSnsrJug = 0;	//0-完全未解锁 1-完全解锁 2-未完全解锁
+uint8 cand_st_lockSnsrJug = 0;	//0-完全未锁紧 1-完全锁紧 2-未完全锁紧
+uint8 cand_st_placeSnsrJug = 0;//0-完全未到位 1-完全到位 2-未完全到位
+uint8 cand_flg_unlockSnsrBit = 0;//传感器0-3的状态 每bit:1-触发,0-不触发
+uint8 cand_flg_lockSnsrBit = 0;//传感器0-3的状态 每bit:1-触发,0-不触发
+uint8 cand_flg_placeSnsrBit = 0;//bit0-bit1:传感器0-1的状态 每bit:1-触发,0-无触发
+uint8 cand_flg_hvLokcBit = 0;//bit0:连接器互锁,bit1:整车互锁
+
+uint8 cand_Mpa_airPress = 0;//单位Mpa,精度0.01Mpa
+uint8 cand = 0;//1-液位正常 0-液位过低
+
+uint8 cand_flg_vehiComm = 0;
+uint8 cand_flg_vehiKeyon = 0;
+uint8 cand_st_vehiStart = 0;
+uint8 cand_flg_vehiBrakeBit = 0;
+uint8 cand_st_vehiGear = 0;
+uint8 cand_st_vehiWheel = 0;
+uint8 cand_Mpa_vehiFrAirP = 0;
+uint8 cand_Mpa_vehiBkAirP = 0;
+
+uint8 cand_flg_battCanComm = 0;
+uint8 cand_st_battBmsState = 0;
+uint8 cand_st_battMainRely = 0;
+uint8 cand_pct_battSoc = 0;
+*/
+
+
+/******************************CAN2变量区域****************************************/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 UINT32 BcuInTable[28] = {
 	0x1801D0F3,
 	0x1801D8F3,
@@ -36,7 +119,6 @@ UINT32 BcuInTable[28] = {
 	0x18FF45F4,
 	0x18FFC13A,
 };
-
 BOOL BcuRxShortError[28];
 BOOL BcuRxLongError[28];
 UINT8 BcuRxErrorCounter[28];
@@ -425,8 +507,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"