/* * @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; } 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); }