/* * @Author: chenjie * @Date: 2022-10-27 * @LastEditTime: 2022-11-10 * @LastEditors: chenjie * @Description: * @FilePath: \S32K146_4G\code\app\AppTaskCan.c * Copyright (c) 2022 by chenjie, All Rights Reserved. */ #include "AppTaskCan.h" #include "AppFuncLib.h" #ifdef APP_CAN_ENABLE static uint8 BattSendFlg = 0; static void UDSAnsFunc(uint8 *rawData); static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx, uint8 *AnsData, uint8 AnsDataLen); static void BattSendFunc(void); void CanTask(void *pvParameters) { uint32 timerCANIdle = 0x00; uint32 timerCounterNow = 0; (void)pvParameters; CanIf_bRxFlag = false; Can_Msg_Type_Data CanRxMsg; CanRecvQueueHandle1 = xQueueCreate(100, sizeof(Can_Msg_Type_Data)); BaseType_t ret = pdFALSE; GsensorInit(); while (1) { Can_MainFunction_Read(); do { memset(&CanRxMsg, 0, sizeof(CanRxMsg)); ret = xQueueReceive(CanRecvQueueHandle1, &CanRxMsg, 1); if (ret == pdPASS) { timerCANIdle = 0x00; if (IsJumptoBootloader(CanRxMsg.id, CanRxMsg.data)) { DoRoutinePositiveAnswer(); RequestEnterBootloader(); DoResetECUWithWdg(); break; } else { if(CanRxMsg.id==0x1C00EDEA) { UDSAnsFunc(CanRxMsg.data); } else { BcuDecodeFunction(CanRxMsg.id, CanRxMsg.data); // can协议解析 } } } if (timerCANIdle > 10*1000) { timerCANIdle = 0; xSemaphoreGive(sleep_mutex); } } while (ret == pdPASS); if ((TimerCounter - timerCounterNow) >= 100) { timerCANIdle = timerCANIdle + 100; BcuRxDiagnose(); timerCounterNow = TimerCounter; } } } // 注意解码超限问题 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; } BMS_CellRecvCounter = (BMS_CellRecvCounter + 1) >= 128 ? 128 : (BMS_CellRecvCounter + 1); 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_CSC_Code == 0 || BMS_CSC_Code > 8) { break; } uint8 tempCount = 0,offvalue = 0; if(BMS_CellTempFramNum%2==0) { tempCount = 2; offvalue = 6; } else { tempCount = 6; offvalue = 0; } for(uint8 i=0; i= 10)) { BMS_CellTemp[(BMS_CSC_Code - 1) * 8 + i + offvalue] = (UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF)- 10; } } 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; case 0x18E1F3D0: { uint8 VIN_FrameNo; VIN_FrameNo = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF); if (VIN_FrameNo - 1 > 2) { break; } for (UINT8 i = 0; i < 7; i++) { if (((VIN_FrameNo-1) * 7 + i) < sizeof(VIN)) { VIN[(VIN_FrameNo-1) * 7 + i] = (UINT8)(((*(UINT8 *)(rawData + 1 + i))) & 0xFF); } } break; } default: break; } } static void UDSAnsFunc(uint8 *rawData) { static uint8 UdsStates = 1; uint8 Data[8] = {0}; memcpy(Data, rawData, 8); uint8 UdsService = 0; uint8 UdsSubService = 0; UdsService = Data[0]; UdsSubService = Data[1]; uint8 AnsData[24] = {0}; static uint8 deviceSnRecvFlg = 0; switch (UdsService) { case 0x10: // 模式切换 { if (UdsSubService == 0x01) { UdsStates = 0x01; // 关闭UDS诊断 UdsAns(true, UdsService, UdsSubService, 0x00, NULL, 0); } else if (UdsSubService == 0x02) { if (UdsStates == 0x01 || UdsStates == 0x02) { UdsStates = 0x02; // 打开UDS诊断 UdsAns(true, UdsService, UdsSubService, 0x00, NULL, 0); } else { UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); } } break; } case 0x11: // 控制 { if (UdsStates == 0x02) { switch (UdsSubService) { case 0x01: // 重启 { AnsData[0] = AppSwVersion >> 24; AnsData[1] = AppSwVersion >> 16; AnsData[2] = AppSwVersion >> 8; AnsData[3] = AppSwVersion >> 0; UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 4); AppConfigInfo.appSaveFlg = true; vTaskDelay(pdMS_TO_TICKS(1000)); DoResetECUWithWdg(); break; } default: { UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); break; } } } else { UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); } break; } case 0x22: // 查询 { if (UdsStates == 0x02) { switch (UdsSubService) { case 0x01: // 版本号查询 { AnsData[0] = AppSwVersion >> 24; AnsData[1] = AppSwVersion >> 16; AnsData[2] = AppSwVersion >> 8; AnsData[3] = AppSwVersion >> 0; UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 4); break; } case 0x02: // SN号码查询 { memcpy(AnsData, AppConfigInfo.deviceSn, 17); for (uint8 i = 0; i < 5; i++) { UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4); } break; } case 0x03: // ICCID查询 { memcpy(AnsData, IccidNum, 20); for (uint8 i = 0; i < 5; i++) { UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4); } break; } case 0x04: // IMEI查询 { memcpy(AnsData, ImeiNum, 15); for (uint8 i = 0; i < 4; i++) { UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4); } break; } case 0x05: // 驻网状态查询 { AnsData[0] = RegChkRet; UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1); break; } case 0x06: // 联网状态查询 { AnsData[0] = SocketId; UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1); break; } case 0x07: // 定位信息查询 { GPSInfo GpsRecvData; if (xQueuePeek(GpsDataQueueHandle, &GpsRecvData, 0) == pdPASS) { AnsData[0] = GpsRecvData.locateMark; AnsData[4] = GpsRecvData.longitude[0]; AnsData[5] = GpsRecvData.longitude[1]; AnsData[6] = GpsRecvData.longitude[2]; AnsData[7] = GpsRecvData.longitude[3]; AnsData[8] = GpsRecvData.latitude[0]; AnsData[9] = GpsRecvData.latitude[1]; AnsData[10] = GpsRecvData.latitude[2]; AnsData[11] = GpsRecvData.latitude[3]; AnsData[12] = GpsRecvData.altitude[0]; AnsData[13] = GpsRecvData.altitude[1]; AnsData[14] = GpsRecvData.satelliteNum; for (uint8 i = 0; i < 4; i++) { UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4); } break; } else { AnsData[0] = 0xFF; UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1); } break; } case 0x08: // 温度检测查询 { UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1); break; } case 0x09: // 电池信息查询 { UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1); BattSendFlg = 1; break; } case 0x0A: // 三轴数据查询 { AnsData[0] = xyzData[0] >> 8; AnsData[1] = xyzData[0] >> 0; AnsData[2] = xyzData[1] >> 8; AnsData[3] = xyzData[1] >> 0; AnsData[4] = xyzData[2] >> 8; AnsData[5] = xyzData[2] >> 0; for (uint8 i = 0; i < 2; i++) { UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4); } break; } } // switch } // if else { UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); } break; } case 0x27: // 控制 { if (UdsStates == 0x02) { } else { UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); } break; } case 0x2E: // 写入 { if (UdsStates == 0x02) { switch (UdsSubService) { case 0x01://下线检测SN写入,自动存储 { setbit(deviceSnRecvFlg, Data[3]); if (Data[3] < 0x04) { memcpy(&AppConfigInfo.deviceSn[Data[3] * 4], &Data[4], 4); UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 4); } else if (Data[3] == 0x04) { memcpy(&AppConfigInfo.deviceSn[Data[3] * 4], &Data[4], 1); UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 4); } if (deviceSnRecvFlg == 0x1F) { deviceSnRecvFlg = 0; AppConfigInfo.appSaveFlg = true; AppConfigInfo.eolFlg = true; } break; } case 0x02://出厂检测联网测试 { if(Data[4]==0x01) { AppConfigInfo.eolFlg = true; AppConfigInfo.appSaveFlg = false; } else { AppConfigInfo.eolFlg = false; AppConfigInfo.appSaveFlg = true; } UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 1); break; } default: UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); break; } } else { UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); } break; } case 0x31: // 控制 { if (UdsStates == 0x02) { } else { UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0); } break; } default: break; } return; } static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx, uint8 *AnsData, uint8 AnsDataLen) { Can_Msg_Type CanTxMsg; uint32 CanAnsId = 0x1C00EAED; uint8 SendData[8] = {0}; if (PosFlg) { SendData[0] = 0x78; SendData[1] = UdsService; SendData[2] = UdsSubService; SendData[3] = Idx; if (AnsData != NULL && AnsDataLen != 0x00) { memcpy(&SendData[4], AnsData, AnsDataLen); } } else { SendData[0] = 0x7F; SendData[1] = UdsService; SendData[2] = UdsSubService; SendData[3] = 0x00; } CanTxMsg.id = CanAnsId; CanTxMsg.idFrame = CAN_EXTENDED_ID_TYPE; CanTxMsg.sdu = SendData; CanTxMsg.length = 8; CanIf_SendMessage(CAN1, CanTxMsg); } static void BattSendFunc(void) { // Can_Msg_Type CanTxMsg; // uint32 CanAnsId = 0; // uint8 SendData[8] = {0}; // static uint8 SendStep = 0; // static uint8 SendCounter = 0; // switch (SendStep) // { // case 0x00: // { // SendStep++; // break; // } // case 0x01: // { // CanAnsId = 0x1C01EAED; // SendData[0] = battHeatState; // SendData[1] = battFanState; // SendData[2] = battRelayState; // SendData[3] = battConverState; // SendStep++; // break; // } // case 0x02: // { // uint16 ErrorTemp ; // ErrorTemp = GetErrorNum(ErrorArray,sizeof(ErrorArray)/2); // CanAnsId = 0x1C09EAED; // SendData[0] = battWorkState; // SendData[1] = ErrorTemp>>8; // SendData[2] = ErrorTemp; // SendData[3] = 0; // SendData[4] = 0; // SendData[5] = 0; // SendData[6] = 0; // SendData[7] = 0; // SendStep++; // break; // } // case 0x03: // { // CanAnsId = 0x1C0AEAED; // uint16 SocTemp = battSOC*10; // SendData[0] = battI>>8; // SendData[1] = battI; // SendData[2] = battPackVol>>8; // SendData[3] = battPackVol; // SendData[4] = SocTemp>>8; // SendData[5] = SocTemp; // SendData[6] = battSOH; // SendData[7] = battMOSSwitchState; // SendStep++; // break; // } // case 0x04: // { // CanAnsId = 0x1C10EAED + (SendCounter<<16); // if((SendCounter*8 + 7)>BMS_TEMPNUM) // { // SendCounter = 0; // SendStep++; // break; // } // else // { // SendData[0] = battCellTemp[SendCounter*8 + 0]; // SendData[1] = battCellTemp[SendCounter*8 + 1]; // SendData[2] = battCellTemp[SendCounter*8 + 2]; // SendData[3] = battCellTemp[SendCounter*8 + 3]; // SendData[4] = battCellTemp[SendCounter*8 + 4]; // SendData[5] = battCellTemp[SendCounter*8 + 5]; // SendData[6] = battCellTemp[SendCounter*8 + 6]; // SendData[7] = battCellTemp[SendCounter*8 + 7]; // } // break; // } // case 0x05: // { // CanAnsId = 0x1CA0EAED + (SendCounter<<16); // if((SendCounter*4 + 3)>BMS_CELLNUM) // { // SendCounter = 0; // SendStep++; // break; // } // else // { // SendData[0] = battCellU[SendCounter*4 + 0]>>8; // SendData[1] = battCellU[SendCounter*4 + 0]; // SendData[2] = battCellU[SendCounter*4 + 1]>>8; // SendData[3] = battCellU[SendCounter*4 + 1]; // SendData[4] = battCellU[SendCounter*4 + 2]>>8; // SendData[5] = battCellU[SendCounter*4 + 2]; // SendData[6] = battCellU[SendCounter*4 + 3]>>8; // SendData[7] = battCellU[SendCounter*4 + 3]; // } // break; // } // default: // { // SendStep = 0; // BattSendFlg = 0; // return; // break; // } // } // CanTxMsg.id = CanAnsId; // CanTxMsg.idFrame = CAN_EXTENDED_ID_TYPE; // CanTxMsg.sdu = SendData; // CanTxMsg.length = 8; // CanIf_SendMessage(CAN1, CanTxMsg); } void BcuRxDiagnose(void) // 100ms调用一次 { 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; BMS_CellRecvCounter = 0; 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 = BMS_CELL_MAX_NUM; // BMS_TempTotal = BMS_TEMP_MAX_NUM; 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; } } #endif