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