AppTaskCan.c 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  1. /*
  2. * @Author: chenjie
  3. * @Date: 2022-10-27
  4. * @LastEditTime: 2022-11-10
  5. * @LastEditors: chenjie
  6. * @Description:
  7. * @FilePath: \S32K146_4G\code\app\AppTaskCan.c
  8. * Copyright (c) 2022 by chenjie, All Rights Reserved.
  9. */
  10. #include "AppTaskCan.h"
  11. #include "AppFuncLib.h"
  12. #ifdef APP_CAN_ENABLE
  13. static uint8 BattSendFlg = 0;
  14. static void UDSAnsFunc(uint8 *rawData);
  15. static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx, uint8 *AnsData, uint8 AnsDataLen);
  16. static void BattSendFunc(void);
  17. void CanTask(void *pvParameters)
  18. {
  19. uint32 timerCANIdle = 0x00;
  20. uint32 timerCounterNow = 0;
  21. (void)pvParameters;
  22. CanIf_bRxFlag = false;
  23. Can_Msg_Type_Data CanRxMsg;
  24. CanRecvQueueHandle1 = xQueueCreate(100, sizeof(Can_Msg_Type_Data));
  25. BaseType_t ret = pdFALSE;
  26. GsensorInit();
  27. while (1)
  28. {
  29. Can_MainFunction_Read();
  30. do
  31. {
  32. memset(&CanRxMsg, 0, sizeof(CanRxMsg));
  33. ret = xQueueReceive(CanRecvQueueHandle1, &CanRxMsg, 1);
  34. if (ret == pdPASS)
  35. {
  36. timerCANIdle = 0x00;
  37. if (IsJumptoBootloader(CanRxMsg.id, CanRxMsg.data))
  38. {
  39. DoRoutinePositiveAnswer();
  40. RequestEnterBootloader();
  41. SystemSoftwareReset();
  42. // DoResetECUWithWdg();
  43. break;
  44. }
  45. else
  46. {
  47. if(CanRxMsg.id==0x1C00EDEA)
  48. {
  49. UDSAnsFunc(CanRxMsg.data);
  50. }
  51. else
  52. {
  53. BcuDecodeFunction(CanRxMsg.id, CanRxMsg.data); // can协议解析
  54. }
  55. }
  56. }
  57. if (timerCANIdle > 10*1000)
  58. {
  59. timerCANIdle = 0;
  60. xSemaphoreGive(sleep_mutex);
  61. }
  62. } while (ret == pdPASS);
  63. if ((TimerCounter - timerCounterNow) >= 100)
  64. {
  65. timerCANIdle = timerCANIdle + 100;
  66. BcuRxDiagnose();
  67. timerCounterNow = TimerCounter;
  68. }
  69. }
  70. }
  71. // 注意解码超限问题
  72. void BcuDecodeFunction(uint32 ID, uint8 *rawData)
  73. {
  74. switch (ID)
  75. {
  76. case 0x1801D0F3:
  77. BMS_ReqVIN = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0x3);
  78. BMS_ReqHVOff = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
  79. BcuRxFlag[0] = 0x01;
  80. break;
  81. case 0x1801D8F3:
  82. BMS_SoftwareVersion = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  83. BMS_HardwareVersion = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
  84. BMS_ProtocolEditionH = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x3);
  85. BMS_ProtocolEditionL = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0xF);
  86. BcuRxFlag[1] = 0x01;
  87. break;
  88. case 0x1880D0F3:
  89. BMS_CharDevNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xF);
  90. BMS_FtPosRly = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 4) & 0x1);
  91. BMS_FtNegRly = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 5) & 0x1);
  92. BMS_FtPosCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 6) & 0x1);
  93. BMS_FtNegCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 7) & 0x1);
  94. BMS_FtPosCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0x1);
  95. BMS_FtNegCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 1) & 0x1);
  96. BMS_FtHeatRly1 = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 2) & 0x1);
  97. BMS_FtHeatRly2 = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 3) & 0x1);
  98. BMS_StPosRly = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 4) & 0x3);
  99. BMS_StNegRly = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 6) & 0x3);
  100. BMS_StPreCharRly = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0x3);
  101. BMS_StPosCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 2) & 0x3);
  102. BMS_StNegCharRly1 = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 4) & 0x3);
  103. BMS_StPosCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 6) & 0x3);
  104. BMS_StNegCharRly2 = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0x3);
  105. BMS_FtAuxRelayWeld = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 2) & 0x1);
  106. BMS_BraOpenCirc = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 3) & 0x1);
  107. BMS_FtBackCharCurrOutLim = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 4) & 0x3);
  108. BMS_FtPosRlyOpen = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 6) & 0x1);
  109. BMS_FtNegRlyOpen = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 7) & 0x1);
  110. BMS_FtPosCharRly1Open = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x1);
  111. BMS_FtPosCharRly2Open = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 1) & 0x1);
  112. BMS_FtNegCharRly1Open = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0x1);
  113. BMS_FtNegCharRly2Open = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 3) & 0x1);
  114. BMS_FtTMSContClose = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 4) & 0x1);
  115. BMS_FtTMSContOpen = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 5) & 0x1);
  116. BMS_FtTMS = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 6) & 0x1);
  117. BMS_Ft24VSpy = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 7) & 0x1);
  118. BMS_FtPACKSelfProt = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0x1);
  119. BMS_FtCharSockTempOver = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 1) & 0x3);
  120. BMS_FtTempOutCtrl = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 3) & 0x1);
  121. BMS_StPosHeatRly = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 4) & 0x3);
  122. BMS_StNegHeatRly = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 6) & 0x3);
  123. BMS_CharSysNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xF);
  124. BMS_FtCode = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  125. BcuRxFlag[2] = 0x01;
  126. break;
  127. case 0x1881D0F3:
  128. BMS_ST1CheckSum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  129. BMS_ST1Counter = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xF);
  130. BMS_Mode = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 4) & 0x3);
  131. BMS_AuxRlySt = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 6) & 0x1);
  132. BMS_BattBalaSt = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 7) & 0x1);
  133. BMS_CharGunSt = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0x1);
  134. BMS_CharMode = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 1) & 0x3);
  135. BMS_CharSt = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 3) & 0x3);
  136. BMS_FtLvl = (UINT8)(((*(UINT8 *)(rawData + 2)) >> 5) & 0x3);
  137. BMS_FtCellTempDiff = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0x3);
  138. BMS_FtCellTempHigh = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 2) & 0x3);
  139. BMS_FtPACKOverVolt = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 4) & 0x3);
  140. BMS_FtPACKUndeVolt = (UINT8)(((*(UINT8 *)(rawData + 3)) >> 6) & 0x3);
  141. BMS_FtSOCLow = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x3);
  142. BMS_FtCellOverVolt = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0x3);
  143. BMS_FtCellUndeVolt = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 4) & 0x3);
  144. BMS_FtIns = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 6) & 0x3);
  145. BMS_FtCellOverVoltDiff = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0x3);
  146. BMS_FtCharCurrOver = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 2) & 0x3);
  147. BMS_FtDisCharCurrOver = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 4) & 0x3);
  148. BMS_FtCellTempLow = (UINT8)(((*(UINT8 *)(rawData + 5)) >> 6) & 0x3);
  149. BMS_FtBranVoltDifOver = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0x3);
  150. BMS_FtBMSHardWare = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 2) & 0x3);
  151. BMS_FtSOCHigh = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x1);
  152. BMS_FtSOCJump = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 5) & 0x1);
  153. BMS_FtInCom = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 6) & 0x1);
  154. BMS_FtSysMism = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 7) & 0x1);
  155. BMS_FtHvIntLock = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x1);
  156. BMS_FtSmoke = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 1) & 0x1);
  157. BMS_FtFire = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 2) & 0x1);
  158. BMS_FtNum = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 3) & 0x1F);
  159. BcuRxFlag[3] = 0x01;
  160. break;
  161. case 0x1882D0F3:
  162. BMS_PackSOC = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  163. BMS_PackSOH = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  164. BMS_PackCurr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
  165. BMS_MaxCharCurr = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  166. BMS_MaxDisCharCurr = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
  167. BcuRxFlag[4] = 0x01;
  168. break;
  169. case 0x1883D0F3:
  170. BMS_PosIns = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  171. BMS_NegIns = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
  172. BMS_BattVolt = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  173. BMS_LinkVolt = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
  174. BcuRxFlag[5] = 0x01;
  175. break;
  176. case 0x1884D0F3:
  177. BMS_MaxCellTemp = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  178. BMS_MinCellTemp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  179. BMS_AverCellTemp = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  180. BMS_MaxCellTempCSC = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  181. BMS_MaxCellTempNum = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
  182. BMS_MinCellTempCSC = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
  183. BMS_MinCellTempNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  184. BcuRxFlag[6] = 0x01;
  185. break;
  186. case 0x1885D0F3:
  187. BMS_MaxCellVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  188. BMS_MaxCellVoltCSC = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  189. BMS_MaxCellVoltNum = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  190. BMS_AverCellVolt = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  191. BcuRxFlag[7] = 0x01;
  192. break;
  193. case 0x1886D0F3:
  194. BMS_MinCellVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  195. BMS_MinCellVoltCSC = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  196. BMS_MinCellVoltNum = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  197. BMS_ContChrgCurr = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  198. BMS_ContDisCharCurr = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
  199. BcuRxFlag[8] = 0x01;
  200. break;
  201. case 0x1887D0F3:
  202. BMS_CharReqVolt = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  203. BMS_CharReqCurr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
  204. BMS_SysInsRes = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  205. BMS_InsDeteSt = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0x1);
  206. BMS_FtCharInsLow = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 1) & 0x1);
  207. BMS_FtCurrSenr = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 2) & 0x1);
  208. BMS_FtHeatingFilm = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 3) & 0x1);
  209. BMS_FtMainLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x1);
  210. BMS_FtAuxLoopPreChar = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 5) & 0x1);
  211. BMS_FtACANLost = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 6) & 0x1);
  212. BMS_FtDCDC = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 7) & 0x1);
  213. BMS_FtSOCDif = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x1);
  214. BMS_FtCellOverDisChar = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 1) & 0x1);
  215. BMS_FtCharOver = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 2) & 0x3);
  216. BMS_FtContDisCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 4) & 0x3);
  217. BMS_FtContCharCurrOverLoad = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 6) & 0x3);
  218. BcuRxFlag[9] = 0x01;
  219. break;
  220. case 0x1888D0F3:
  221. BMS_MaxDisCharPwr = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  222. BMS_MaxCharPwr = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
  223. BMS_ContDisCharPwr = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  224. BMS_ContCharPwr = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
  225. BcuRxFlag[10] = 0x01;
  226. break;
  227. case 0x1889D0F3:
  228. BMS_InstEngyCons = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  229. BMS_TotalEngyCons = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
  230. BMS_SOE = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  231. BMS_RmanCharTime = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
  232. BcuRxFlag[11] = 0x01;
  233. break;
  234. case 0x188AD0F3:
  235. BMS_Gun1DCNegTemp = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  236. BMS_Gun1DCPosTemp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  237. BMS_Gun2DCNegTemp = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  238. BMS_Gun2DCPosTemp = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  239. BMS_CurrHeatSt = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0x3);
  240. BMS_CurrCoolSt = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 2) & 0x3);
  241. BMS_FtCharCnct = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 4) & 0x1);
  242. BMS_FtOverDisCharCurrDuringChar = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 5) & 0x1);
  243. BMS_FtCharNTC = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 6) & 0x1);
  244. BMS_FtELock = (UINT8)(((*(UINT8 *)(rawData + 4)) >> 7) & 0x1);
  245. BMS_CharNum = (UINT16)(((*(UINT8 *)(rawData + 5)) | (*(UINT8 *)(rawData + 6) << 8)) & 0xFFFF);
  246. BcuRxFlag[12] = 0x01;
  247. break;
  248. case 0x18C1D0F3:
  249. BMS_CellVoltFramNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  250. BMS_CSC_Code = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  251. if (BMS_CellVoltFramNum == 0 || BMS_CellVoltFramNum > 128)
  252. {
  253. break;
  254. }
  255. BMS_CellRecvCounter = (BMS_CellRecvCounter + 1) >= 128 ? 128 : (BMS_CellRecvCounter + 1);
  256. for (UINT8 i = 0; i < 3; i++)
  257. {
  258. BMS_CellVolt[(BMS_CellVoltFramNum - 1) * 3 + i] = (UINT16)(((*(UINT8 *)(rawData + i * 2 + 2)) | (*(UINT8 *)(rawData + i * 2 + 3) << 8)) & 0xFFFF);
  259. }
  260. BcuRxFlag[13] = 0x01;
  261. break;
  262. case 0x18C2D0F3:
  263. BMS_CellTempFramNum = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  264. BMS_CSC_Code = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  265. if (BMS_CSC_Code == 0 || BMS_CSC_Code > 8)
  266. {
  267. break;
  268. }
  269. uint8 tempCount = 0,offvalue = 0;
  270. if(BMS_CellTempFramNum%2==0)
  271. {
  272. tempCount = 2;
  273. offvalue = 6;
  274. }
  275. else
  276. {
  277. tempCount = 6;
  278. offvalue = 0;
  279. }
  280. for(uint8 i=0; i<tempCount; i++)
  281. {
  282. if (((BMS_CSC_Code - 1) * 8 + i + offvalue) < sizeof(BMS_CellTemp) && ((UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF) >= 10))
  283. {
  284. BMS_CellTemp[(BMS_CSC_Code - 1) * 8 + i + offvalue] = (UINT8)(((*(UINT8 *)(rawData + 2 + i))) & 0xFF)- 10;
  285. }
  286. }
  287. BcuRxFlag[14] = 0x01;
  288. break;
  289. case 0x18E1D0F3:
  290. BMS_Checksum = 0;
  291. for (UINT8 i = 1; i < 8; i++)
  292. {
  293. BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
  294. }
  295. if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
  296. {
  297. BMS_PackComp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0x7);
  298. BMS_BattCodeLeng = (UINT8)(((*(UINT8 *)(rawData + 1)) >> 3) & 0x1F);
  299. BMS_SN[0] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  300. BMS_SN[1] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  301. BMS_SN[2] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
  302. BMS_SN[3] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
  303. BMS_SN[4] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  304. BMS_SN[5] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  305. }
  306. BcuRxFlag[15] = 0x01;
  307. break;
  308. case 0x18E2D0F3:
  309. BMS_Checksum = 0;
  310. for (UINT8 i = 1; i < 8; i++)
  311. {
  312. BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
  313. }
  314. if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
  315. {
  316. BMS_SN[6] = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  317. BMS_SN[7] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  318. BMS_SN[8] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  319. BMS_SN[9] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
  320. BMS_SN[10] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
  321. BMS_SN[11] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  322. BMS_SN[12] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  323. }
  324. BcuRxFlag[16] = 0x01;
  325. break;
  326. case 0x18E3D0F3:
  327. BMS_Checksum = 0;
  328. for (UINT8 i = 1; i < 8; i++)
  329. {
  330. BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
  331. }
  332. if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
  333. {
  334. BMS_SN[13] = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  335. BMS_SN[14] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  336. BMS_SN[15] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  337. BMS_SN[16] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
  338. BMS_SN[17] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
  339. BMS_SN[18] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  340. BMS_SN[19] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  341. }
  342. BcuRxFlag[17] = 0x01;
  343. break;
  344. case 0x18E4D0F3:
  345. BMS_Checksum = 0;
  346. for (UINT8 i = 1; i < 8; i++)
  347. {
  348. BMS_Checksum = (UINT8)(((*(UINT8 *)(rawData + i))) & 0xFF) ^ BMS_Checksum;
  349. }
  350. if (BMS_Checksum == (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF))
  351. {
  352. BMS_SN[20] = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  353. BMS_SN[21] = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  354. BMS_SN[22] = (UINT8)(((*(UINT8 *)(rawData + 3))) & 0xFF);
  355. BMS_SN[23] = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
  356. BMS_SN[24] = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
  357. BMS_SN[25] = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  358. BMS_SN[26] = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  359. }
  360. BcuRxFlag[18] = 0x01;
  361. break;
  362. case 0x18E5D0F3:
  363. BMS_BattRateCap = (UINT16)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8)) & 0xFFFF);
  364. BMS_BattRateVolt = (UINT16)(((*(UINT8 *)(rawData + 2)) | (*(UINT8 *)(rawData + 3) << 8)) & 0xFFFF);
  365. BMS_BattRateEngy = (UINT16)(((*(UINT8 *)(rawData + 4)) | (*(UINT8 *)(rawData + 5) << 8)) & 0xFFFF);
  366. BMS_BattType = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xF);
  367. BMS_CoolType = (UINT8)(((*(UINT8 *)(rawData + 6)) >> 4) & 0x3);
  368. BcuRxFlag[19] = 0x01;
  369. break;
  370. case 0x18E6D0F3:
  371. BMS_CSC_Total = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  372. BMS_CellTotal = (UINT16)(((*(UINT8 *)(rawData + 1)) | (*(UINT8 *)(rawData + 2) << 8)) & 0xFFFF);
  373. BMS_TempTotal = (UINT16)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8)) & 0xFFFF);
  374. BMS_CellVoltLevel = (UINT8)(((*(UINT8 *)(rawData + 5))) & 0xFF);
  375. BMS_CellMinVolt = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  376. BMS_CellMaxVolt = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  377. BcuRxFlag[20] = 0x01;
  378. break;
  379. case 0x18F1D0F3:
  380. BMS_TotalCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
  381. BMS_TotalDisCharEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
  382. BMS_SingleCharEngy = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
  383. BcuRxFlag[21] = 0x01;
  384. break;
  385. case 0x18F2D0F3:
  386. BMS_TotalBackCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
  387. BMS_TotalStaCharEngy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
  388. BcuRxFlag[22] = 0x01;
  389. break;
  390. case 0x18F3D0F3:
  391. BMS_TotalGunCharEngy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
  392. BMS_TotalGunCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
  393. BcuRxFlag[23] = 0x01;
  394. break;
  395. case 0x18F4D0F3:
  396. BMS_TotalCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
  397. BMS_TotalDisCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
  398. BMS_SingleCharCapy = (UINT16)(((*(UINT8 *)(rawData + 6)) | (*(UINT8 *)(rawData + 7) << 8)) & 0xFFFF);
  399. BcuRxFlag[24] = 0x01;
  400. break;
  401. case 0x18F5D0F3:
  402. BMS_TotalBackCharCapy = (UINT32)(((*(UINT8 *)(rawData + 0)) | (*(UINT8 *)(rawData + 1) << 8) | (*(UINT8 *)(rawData + 2) << 16) | (*(UINT8 *)(rawData + 3) << 24)) & 0xFFFFFF);
  403. BMS_TotalStaCharCapy = (UINT32)(((*(UINT8 *)(rawData + 3)) | (*(UINT8 *)(rawData + 4) << 8) | (*(UINT8 *)(rawData + 5) << 16) | (*(UINT8 *)(rawData + 6) << 24)) & 0xFFFFFF);
  404. BMS_HVBranNum = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  405. BMS_SingleHVBranchCellNum = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  406. BcuRxFlag[25] = 0x01;
  407. break;
  408. case 0x18FF45F4:
  409. BMS_ReqMode = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0x3);
  410. BMS_HVCmd = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
  411. BMS_ChgSts = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 4) & 0x3);
  412. BMS_HVRelaySts = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 6) & 0x3);
  413. BMS_HVVolt = (UINT16)(((*(UINT8 *)(rawData + 1)) | (*(UINT8 *)(rawData + 2) << 8)) & 0xFFFF);
  414. BMS_SetTemp = (UINT8)(((*(UINT8 *)(rawData + 4))) & 0xFF);
  415. BMS_Life = (UINT8)(((*(UINT8 *)(rawData + 6))) & 0xFF);
  416. BMS_CRC = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0xFF);
  417. BcuRxFlag[26] = 0x01;
  418. break;
  419. case 0x18FFC13A:
  420. TMS_WorkStatus = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0x3);
  421. TMS_HVRelayST = (UINT8)(((*(UINT8 *)(rawData + 0)) >> 2) & 0x3);
  422. TMS_OutletTemp = (UINT8)(((*(UINT8 *)(rawData + 1))) & 0xFF);
  423. TMS_InletTemp = (UINT8)(((*(UINT8 *)(rawData + 2))) & 0xFF);
  424. TMS_ReqPow = (UINT16)(((*(UINT8 *)(rawData + 5)) | (*(UINT8 *)(rawData + 6) << 8)) & 0xFFFF);
  425. TMS_ErrCode = (UINT8)(((*(UINT8 *)(rawData + 7))) & 0x3F);
  426. TMS_FaultLevel = (UINT8)(((*(UINT8 *)(rawData + 7)) >> 6) & 0x3);
  427. BcuRxFlag[27] = 0x01;
  428. break;
  429. case 0x18E1F3D0:
  430. {
  431. uint8 VIN_FrameNo;
  432. VIN_FrameNo = (UINT8)(((*(UINT8 *)(rawData + 0))) & 0xFF);
  433. if (VIN_FrameNo - 1 > 2)
  434. {
  435. break;
  436. }
  437. for (UINT8 i = 0; i < 7; i++)
  438. {
  439. if (((VIN_FrameNo-1) * 7 + i) < sizeof(VIN))
  440. {
  441. VIN[(VIN_FrameNo-1) * 7 + i] = (UINT8)(((*(UINT8 *)(rawData + 1 + i))) & 0xFF);
  442. }
  443. }
  444. break;
  445. }
  446. default:
  447. break;
  448. }
  449. }
  450. static void UDSAnsFunc(uint8 *rawData)
  451. {
  452. static uint8 UdsStates = 1;
  453. uint8 Data[8] = {0};
  454. memcpy(Data, rawData, 8);
  455. uint8 UdsService = 0;
  456. uint8 UdsSubService = 0;
  457. UdsService = Data[0];
  458. UdsSubService = Data[1];
  459. uint8 AnsData[24] = {0};
  460. static uint8 deviceSnRecvFlg = 0;
  461. switch (UdsService)
  462. {
  463. case 0x10: // 模式切换
  464. {
  465. if (UdsSubService == 0x01)
  466. {
  467. UdsStates = 0x01; // 关闭UDS诊断
  468. UdsAns(true, UdsService, UdsSubService, 0x00, NULL, 0);
  469. }
  470. else if (UdsSubService == 0x02)
  471. {
  472. if (UdsStates == 0x01 || UdsStates == 0x02)
  473. {
  474. UdsStates = 0x02; // 打开UDS诊断
  475. UdsAns(true, UdsService, UdsSubService, 0x00, NULL, 0);
  476. }
  477. else
  478. {
  479. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  480. }
  481. }
  482. break;
  483. }
  484. case 0x11: // 控制
  485. {
  486. if (UdsStates == 0x02)
  487. {
  488. switch (UdsSubService)
  489. {
  490. case 0x01: // 重启
  491. {
  492. AnsData[0] = AppSwVersion >> 24;
  493. AnsData[1] = AppSwVersion >> 16;
  494. AnsData[2] = AppSwVersion >> 8;
  495. AnsData[3] = AppSwVersion >> 0;
  496. UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 4);
  497. AppConfigInfo.appSaveFlg = true;
  498. vTaskDelay(pdMS_TO_TICKS(1000));
  499. SystemSoftwareReset();
  500. break;
  501. }
  502. default:
  503. {
  504. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  505. break;
  506. }
  507. }
  508. }
  509. else
  510. {
  511. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  512. }
  513. break;
  514. }
  515. case 0x22: // 查询
  516. {
  517. if (UdsStates == 0x02)
  518. {
  519. switch (UdsSubService)
  520. {
  521. case 0x01: // 版本号查询
  522. {
  523. AnsData[0] = AppSwVersion >> 24;
  524. AnsData[1] = AppSwVersion >> 16;
  525. AnsData[2] = AppSwVersion >> 8;
  526. AnsData[3] = AppSwVersion >> 0;
  527. UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 4);
  528. break;
  529. }
  530. case 0x02: // SN号码查询
  531. {
  532. memcpy(AnsData, AppConfigInfo.deviceSn, 17);
  533. for (uint8 i = 0; i < 5; i++)
  534. {
  535. UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4);
  536. }
  537. break;
  538. }
  539. case 0x03: // ICCID查询
  540. {
  541. memcpy(AnsData, IccidNum, 20);
  542. for (uint8 i = 0; i < 5; i++)
  543. {
  544. UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4);
  545. }
  546. break;
  547. }
  548. case 0x04: // IMEI查询
  549. {
  550. memcpy(AnsData, ImeiNum, 15);
  551. for (uint8 i = 0; i < 4; i++)
  552. {
  553. UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4);
  554. }
  555. break;
  556. }
  557. case 0x05: // 驻网状态查询
  558. {
  559. AnsData[0] = RegChkRet;
  560. UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
  561. break;
  562. }
  563. case 0x06: // 联网状态查询
  564. {
  565. AnsData[0] = SocketId;
  566. UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
  567. break;
  568. }
  569. case 0x07: // 定位信息查询
  570. {
  571. GPSInfo GpsRecvData;
  572. if (xQueuePeek(GpsDataQueueHandle, &GpsRecvData, 0) == pdPASS)
  573. {
  574. AnsData[0] = GpsRecvData.locateMark;
  575. AnsData[4] = GpsRecvData.longitude[0];
  576. AnsData[5] = GpsRecvData.longitude[1];
  577. AnsData[6] = GpsRecvData.longitude[2];
  578. AnsData[7] = GpsRecvData.longitude[3];
  579. AnsData[8] = GpsRecvData.latitude[0];
  580. AnsData[9] = GpsRecvData.latitude[1];
  581. AnsData[10] = GpsRecvData.latitude[2];
  582. AnsData[11] = GpsRecvData.latitude[3];
  583. AnsData[12] = GpsRecvData.altitude[0];
  584. AnsData[13] = GpsRecvData.altitude[1];
  585. AnsData[14] = GpsRecvData.satelliteNum;
  586. for (uint8 i = 0; i < 4; i++)
  587. {
  588. UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4);
  589. }
  590. break;
  591. }
  592. else
  593. {
  594. AnsData[0] = 0xFF;
  595. UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
  596. }
  597. break;
  598. }
  599. case 0x08: // 温度检测查询
  600. {
  601. UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
  602. break;
  603. }
  604. case 0x09: // 电池信息查询
  605. {
  606. UdsAns(true, UdsService, UdsSubService, 0x00, AnsData, 1);
  607. BattSendFlg = 1;
  608. break;
  609. }
  610. case 0x0A: // 三轴数据查询
  611. {
  612. AnsData[0] = xyzData[0] >> 8;
  613. AnsData[1] = xyzData[0] >> 0;
  614. AnsData[2] = xyzData[1] >> 8;
  615. AnsData[3] = xyzData[1] >> 0;
  616. AnsData[4] = xyzData[2] >> 8;
  617. AnsData[5] = xyzData[2] >> 0;
  618. for (uint8 i = 0; i < 2; i++)
  619. {
  620. UdsAns(true, UdsService, UdsSubService, i, &AnsData[i * 4], 4);
  621. }
  622. break;
  623. }
  624. } // switch
  625. } // if
  626. else
  627. {
  628. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  629. }
  630. break;
  631. }
  632. case 0x27: // 控制
  633. {
  634. if (UdsStates == 0x02)
  635. {
  636. }
  637. else
  638. {
  639. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  640. }
  641. break;
  642. }
  643. case 0x2E: // 写入
  644. {
  645. if (UdsStates == 0x02)
  646. {
  647. switch (UdsSubService)
  648. {
  649. case 0x01://下线检测SN写入,自动存储
  650. {
  651. setbit(deviceSnRecvFlg, Data[3]);
  652. if (Data[3] < 0x04)
  653. {
  654. memcpy(&AppConfigInfo.deviceSn[Data[3] * 4], &Data[4], 4);
  655. UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 4);
  656. }
  657. else if (Data[3] == 0x04)
  658. {
  659. memcpy(&AppConfigInfo.deviceSn[Data[3] * 4], &Data[4], 1);
  660. UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 4);
  661. }
  662. if (deviceSnRecvFlg == 0x1F)
  663. {
  664. deviceSnRecvFlg = 0;
  665. AppConfigInfo.appSaveFlg = true;
  666. AppConfigInfo.eolFlg = true;
  667. }
  668. break;
  669. }
  670. case 0x02://出厂检测联网测试
  671. {
  672. if(Data[4]==0x01)
  673. {
  674. AppConfigInfo.eolFlg = true;
  675. AppConfigInfo.appSaveFlg = false;
  676. }
  677. else
  678. {
  679. AppConfigInfo.eolFlg = false;
  680. AppConfigInfo.appSaveFlg = true;
  681. }
  682. UdsAns(true, UdsService, UdsSubService, 0x00, &Data[4], 1);
  683. break;
  684. }
  685. default:
  686. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  687. break;
  688. }
  689. }
  690. else
  691. {
  692. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  693. }
  694. break;
  695. }
  696. case 0x31: // 控制
  697. {
  698. if (UdsStates == 0x02)
  699. {
  700. }
  701. else
  702. {
  703. UdsAns(false, UdsService, UdsSubService, 0x00, NULL, 0);
  704. }
  705. break;
  706. }
  707. default:
  708. break;
  709. }
  710. return;
  711. }
  712. static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx, uint8 *AnsData, uint8 AnsDataLen)
  713. {
  714. Can_Msg_Type CanTxMsg;
  715. uint32 CanAnsId = 0x1C00EAED;
  716. uint8 SendData[8] = {0};
  717. if (PosFlg)
  718. {
  719. SendData[0] = 0x78;
  720. SendData[1] = UdsService;
  721. SendData[2] = UdsSubService;
  722. SendData[3] = Idx;
  723. if (AnsData != NULL && AnsDataLen != 0x00)
  724. {
  725. memcpy(&SendData[4], AnsData, AnsDataLen);
  726. }
  727. }
  728. else
  729. {
  730. SendData[0] = 0x7F;
  731. SendData[1] = UdsService;
  732. SendData[2] = UdsSubService;
  733. SendData[3] = 0x00;
  734. }
  735. CanTxMsg.id = CanAnsId;
  736. CanTxMsg.idFrame = CAN_EXTENDED_ID_TYPE;
  737. CanTxMsg.sdu = SendData;
  738. CanTxMsg.length = 8;
  739. CanIf_SendMessage(CAN1, CanTxMsg);
  740. }
  741. static void BattSendFunc(void)
  742. {
  743. // Can_Msg_Type CanTxMsg;
  744. // uint32 CanAnsId = 0;
  745. // uint8 SendData[8] = {0};
  746. // static uint8 SendStep = 0;
  747. // static uint8 SendCounter = 0;
  748. // switch (SendStep)
  749. // {
  750. // case 0x00:
  751. // {
  752. // SendStep++;
  753. // break;
  754. // }
  755. // case 0x01:
  756. // {
  757. // CanAnsId = 0x1C01EAED;
  758. // SendData[0] = battHeatState;
  759. // SendData[1] = battFanState;
  760. // SendData[2] = battRelayState;
  761. // SendData[3] = battConverState;
  762. // SendStep++;
  763. // break;
  764. // }
  765. // case 0x02:
  766. // {
  767. // uint16 ErrorTemp ;
  768. // ErrorTemp = GetErrorNum(ErrorArray,sizeof(ErrorArray)/2);
  769. // CanAnsId = 0x1C09EAED;
  770. // SendData[0] = battWorkState;
  771. // SendData[1] = ErrorTemp>>8;
  772. // SendData[2] = ErrorTemp;
  773. // SendData[3] = 0;
  774. // SendData[4] = 0;
  775. // SendData[5] = 0;
  776. // SendData[6] = 0;
  777. // SendData[7] = 0;
  778. // SendStep++;
  779. // break;
  780. // }
  781. // case 0x03:
  782. // {
  783. // CanAnsId = 0x1C0AEAED;
  784. // uint16 SocTemp = battSOC*10;
  785. // SendData[0] = battI>>8;
  786. // SendData[1] = battI;
  787. // SendData[2] = battPackVol>>8;
  788. // SendData[3] = battPackVol;
  789. // SendData[4] = SocTemp>>8;
  790. // SendData[5] = SocTemp;
  791. // SendData[6] = battSOH;
  792. // SendData[7] = battMOSSwitchState;
  793. // SendStep++;
  794. // break;
  795. // }
  796. // case 0x04:
  797. // {
  798. // CanAnsId = 0x1C10EAED + (SendCounter<<16);
  799. // if((SendCounter*8 + 7)>BMS_TEMPNUM)
  800. // {
  801. // SendCounter = 0;
  802. // SendStep++;
  803. // break;
  804. // }
  805. // else
  806. // {
  807. // SendData[0] = battCellTemp[SendCounter*8 + 0];
  808. // SendData[1] = battCellTemp[SendCounter*8 + 1];
  809. // SendData[2] = battCellTemp[SendCounter*8 + 2];
  810. // SendData[3] = battCellTemp[SendCounter*8 + 3];
  811. // SendData[4] = battCellTemp[SendCounter*8 + 4];
  812. // SendData[5] = battCellTemp[SendCounter*8 + 5];
  813. // SendData[6] = battCellTemp[SendCounter*8 + 6];
  814. // SendData[7] = battCellTemp[SendCounter*8 + 7];
  815. // }
  816. // break;
  817. // }
  818. // case 0x05:
  819. // {
  820. // CanAnsId = 0x1CA0EAED + (SendCounter<<16);
  821. // if((SendCounter*4 + 3)>BMS_CELLNUM)
  822. // {
  823. // SendCounter = 0;
  824. // SendStep++;
  825. // break;
  826. // }
  827. // else
  828. // {
  829. // SendData[0] = battCellU[SendCounter*4 + 0]>>8;
  830. // SendData[1] = battCellU[SendCounter*4 + 0];
  831. // SendData[2] = battCellU[SendCounter*4 + 1]>>8;
  832. // SendData[3] = battCellU[SendCounter*4 + 1];
  833. // SendData[4] = battCellU[SendCounter*4 + 2]>>8;
  834. // SendData[5] = battCellU[SendCounter*4 + 2];
  835. // SendData[6] = battCellU[SendCounter*4 + 3]>>8;
  836. // SendData[7] = battCellU[SendCounter*4 + 3];
  837. // }
  838. // break;
  839. // }
  840. // default:
  841. // {
  842. // SendStep = 0;
  843. // BattSendFlg = 0;
  844. // return;
  845. // break;
  846. // }
  847. // }
  848. // CanTxMsg.id = CanAnsId;
  849. // CanTxMsg.idFrame = CAN_EXTENDED_ID_TYPE;
  850. // CanTxMsg.sdu = SendData;
  851. // CanTxMsg.length = 8;
  852. // CanIf_SendMessage(CAN1, CanTxMsg);
  853. }
  854. void BcuRxDiagnose(void) // 100ms调用一次
  855. {
  856. static UINT32 TimeCounter = 0; // ms
  857. TimeCounter = TimeCounter + 10; //
  858. for (UINT8 i = 0; i < sizeof(BcuInTable) / 4; i++)
  859. {
  860. if (BcuRxFlag[i] == 1) // received msg, and clear the error conter
  861. {
  862. BcuRxErrorCounter[i] = 0;
  863. BcuRxFlag[i] = 0;
  864. continue;
  865. }
  866. if (BcuRxErrorCounter[i] < 3)
  867. {
  868. BcuRxShortError[i] = 0;
  869. BcuRxLongError[i] = 0;
  870. }
  871. else if (BcuRxErrorCounter[i] >= 3 && BcuRxErrorCounter[i] < 13)
  872. {
  873. BcuRxShortError[i] = 1;
  874. BcuRxLongError[i] = 0;
  875. }
  876. else if (BcuRxErrorCounter[i] >= 13)
  877. {
  878. BcuRxShortError[i] = 0;
  879. BcuRxLongError[i] = 1;
  880. BcuRxMsgSetInvalidValue(BcuInTable[i]);
  881. BcuRxErrorCounter[i] = 0;
  882. }
  883. else if (BcuRxErrorCounter[i] == 0xFF)
  884. {
  885. BcuRxErrorCounter[i] = 0xFE;
  886. }
  887. }
  888. if (TimeCounter % 100 == 0) // period <=100ms
  889. {
  890. BcuRxErrorCounter[0]++; // can msg 0x1801D0F3
  891. // if(BcuRxErrorCounter[0]>=13)
  892. BcuRxErrorCounter[2]++; // can msg 0x1880D0F3
  893. // if(BcuRxErrorCounter[2]>=13)
  894. BcuRxErrorCounter[3]++; // can msg 0x1881D0F3
  895. // if(BcuRxErrorCounter[3]>=13)
  896. BcuRxErrorCounter[4]++; // can msg 0x1882D0F3
  897. // if(BcuRxErrorCounter[4]>=13)
  898. BcuRxErrorCounter[5]++; // can msg 0x1883D0F3
  899. // if(BcuRxErrorCounter[5]>=13)
  900. BcuRxErrorCounter[6]++; // can msg 0x1884D0F3
  901. // if(BcuRxErrorCounter[6]>=13)
  902. BcuRxErrorCounter[7]++; // can msg 0x1885D0F3
  903. // if(BcuRxErrorCounter[7]>=13)
  904. BcuRxErrorCounter[8]++; // can msg 0x1886D0F3
  905. // if(BcuRxErrorCounter[8]>=13)
  906. BcuRxErrorCounter[9]++; // can msg 0x1887D0F3
  907. // if(BcuRxErrorCounter[9]>=13)
  908. BcuRxErrorCounter[10]++; // can msg 0x1888D0F3
  909. // if(BcuRxErrorCounter[10]>=13)
  910. BcuRxErrorCounter[13]++; // can msg 0x18C1D0F3
  911. // if(BcuRxErrorCounter[13]>=13)
  912. BcuRxErrorCounter[14]++; // can msg 0x18C2D0F3
  913. // if(BcuRxErrorCounter[14]>=13)
  914. BcuRxErrorCounter[19]++; // can msg 0x18E5D0F3
  915. // if(BcuRxErrorCounter[19]>=13)
  916. BcuRxErrorCounter[20]++; // can msg 0x18E6D0F3
  917. // if(BcuRxErrorCounter[20]>=13)
  918. }
  919. if (TimeCounter % 1000 == 0) // period ==1000ms
  920. {
  921. BcuRxErrorCounter[11]++; // can msg 0x1889D0F3
  922. // if(BcuRxErrorCounter[11]>=13)
  923. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[11]);
  924. BcuRxErrorCounter[12]++; // can msg 0x188AD0F3
  925. // if(BcuRxErrorCounter[12]>=13)
  926. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[12]);
  927. BcuRxErrorCounter[15]++; // can msg 0x18E1D0F3
  928. // if(BcuRxErrorCounter[15]>=13)
  929. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[15]);
  930. BcuRxErrorCounter[16]++; // can msg 0x18E2D0F3
  931. // if(BcuRxErrorCounter[16]>=13)
  932. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[16]);
  933. BcuRxErrorCounter[17]++; // can msg 0x18E3D0F3
  934. // if(BcuRxErrorCounter[17]>=13)
  935. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[17]);
  936. BcuRxErrorCounter[18]++; // can msg 0x18E4D0F3
  937. // if(BcuRxErrorCounter[18]>=13)
  938. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[18]);
  939. BcuRxErrorCounter[26]++; // can msg 0x18FF45F4
  940. // if(BcuRxErrorCounter[26]>=13)
  941. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[26]);
  942. BcuRxErrorCounter[27]++; // can msg 0x18FFC13A
  943. // if(BcuRxErrorCounter[27]>=13)
  944. // printf("can msg 0x%x lost,cycle time1000ms\n",COMInTable[27]);
  945. }
  946. if (TimeCounter % 30000 == 0) // period ==30000ms
  947. {
  948. BcuRxErrorCounter[1]++; // can msg 0x1801D8F3
  949. // if(BcuRxErrorCounter[1]>=13)
  950. // printf("can msg 0x%x lost,cycle time30000ms\n",COMInTable[1]);
  951. }
  952. }
  953. void BcuRxMsgSetInvalidValue(uint32 ID)
  954. {
  955. switch (ID)
  956. {
  957. case 0x1801D0F3:
  958. BMS_ReqVIN = 0xFF;
  959. BMS_ReqHVOff = 0xFF;
  960. break;
  961. case 0x1801D8F3:
  962. BMS_SoftwareVersion = 0xFFFF;
  963. BMS_HardwareVersion = 0xFFFF;
  964. BMS_ProtocolEditionH = 0xFF;
  965. BMS_ProtocolEditionL = 0xFF;
  966. break;
  967. case 0x1880D0F3:
  968. BMS_CharDevNum = 0xFF;
  969. BMS_FtPosRly = 0xFF;
  970. BMS_FtNegRly = 0xFF;
  971. BMS_FtPosCharRly1 = 0xFF;
  972. BMS_FtNegCharRly1 = 0xFF;
  973. BMS_FtPosCharRly2 = 0xFF;
  974. BMS_FtNegCharRly2 = 0xFF;
  975. BMS_FtHeatRly1 = 0xFF;
  976. BMS_FtHeatRly2 = 0xFF;
  977. BMS_StPosRly = 0xFF;
  978. BMS_StNegRly = 0xFF;
  979. BMS_StPreCharRly = 0xFF;
  980. BMS_StPosCharRly1 = 0xFF;
  981. BMS_StNegCharRly1 = 0xFF;
  982. BMS_StPosCharRly2 = 0xFF;
  983. BMS_StNegCharRly2 = 0xFF;
  984. BMS_FtAuxRelayWeld = 0xFF;
  985. BMS_BraOpenCirc = 0xFF;
  986. BMS_FtBackCharCurrOutLim = 0xFF;
  987. BMS_FtPosRlyOpen = 0xFF;
  988. BMS_FtNegRlyOpen = 0xFF;
  989. BMS_FtPosCharRly1Open = 0xFF;
  990. BMS_FtPosCharRly2Open = 0xFF;
  991. BMS_FtNegCharRly1Open = 0xFF;
  992. BMS_FtNegCharRly2Open = 0xFF;
  993. BMS_FtTMSContClose = 0xFF;
  994. BMS_FtTMSContOpen = 0xFF;
  995. BMS_FtTMS = 0xFF;
  996. BMS_Ft24VSpy = 0xFF;
  997. BMS_FtPACKSelfProt = 0xFF;
  998. BMS_FtCharSockTempOver = 0xFF;
  999. BMS_FtTempOutCtrl = 0xFF;
  1000. BMS_StPosHeatRly = 0xFF;
  1001. BMS_StNegHeatRly = 0xFF;
  1002. BMS_CharSysNum = 0xFF;
  1003. BMS_FtCode = 0xFF;
  1004. break;
  1005. case 0x1881D0F3:
  1006. BMS_ST1CheckSum = 0xFF;
  1007. BMS_ST1Counter = 0xFF;
  1008. BMS_Mode = 0xFF;
  1009. BMS_AuxRlySt = 0xFF;
  1010. BMS_BattBalaSt = 0xFF;
  1011. BMS_CharGunSt = 0xFF;
  1012. BMS_CharMode = 0xFF;
  1013. BMS_CharSt = 0xFF;
  1014. BMS_FtLvl = 0xFF;
  1015. BMS_FtCellTempDiff = 0xFF;
  1016. BMS_FtCellTempHigh = 0xFF;
  1017. BMS_FtPACKOverVolt = 0xFF;
  1018. BMS_FtPACKUndeVolt = 0xFF;
  1019. BMS_FtSOCLow = 0xFF;
  1020. BMS_FtCellOverVolt = 0xFF;
  1021. BMS_FtCellUndeVolt = 0xFF;
  1022. BMS_FtIns = 0xFF;
  1023. BMS_FtCellOverVoltDiff = 0xFF;
  1024. BMS_FtCharCurrOver = 0xFF;
  1025. BMS_FtDisCharCurrOver = 0xFF;
  1026. BMS_FtCellTempLow = 0xFF;
  1027. BMS_FtBranVoltDifOver = 0xFF;
  1028. BMS_FtBMSHardWare = 0xFF;
  1029. BMS_FtSOCHigh = 0xFF;
  1030. BMS_FtSOCJump = 0xFF;
  1031. BMS_FtInCom = 0xFF;
  1032. BMS_FtSysMism = 0xFF;
  1033. BMS_FtHvIntLock = 0xFF;
  1034. BMS_FtSmoke = 0xFF;
  1035. BMS_FtFire = 0xFF;
  1036. BMS_FtNum = 0xFF;
  1037. break;
  1038. case 0x1882D0F3:
  1039. BMS_PackSOC = 0xFF;
  1040. BMS_PackSOH = 0xFF;
  1041. BMS_PackCurr = 0xFFFF;
  1042. BMS_MaxCharCurr = 0xFFFF;
  1043. BMS_MaxDisCharCurr = 0xFFFF;
  1044. break;
  1045. case 0x1883D0F3:
  1046. BMS_PosIns = 0xFFFF;
  1047. BMS_NegIns = 0xFFFF;
  1048. BMS_BattVolt = 0xFFFF;
  1049. BMS_LinkVolt = 0xFFFF;
  1050. break;
  1051. case 0x1884D0F3:
  1052. BMS_MaxCellTemp = 0xFF;
  1053. BMS_MinCellTemp = 0xFF;
  1054. BMS_AverCellTemp = 0xFF;
  1055. BMS_MaxCellTempCSC = 0xFF;
  1056. BMS_MaxCellTempNum = 0xFF;
  1057. BMS_MinCellTempCSC = 0xFF;
  1058. BMS_MinCellTempNum = 0xFF;
  1059. break;
  1060. case 0x1885D0F3:
  1061. BMS_MaxCellVolt = 0xFFFF;
  1062. BMS_MaxCellVoltCSC = 0xFF;
  1063. BMS_MaxCellVoltNum = 0xFF;
  1064. BMS_AverCellVolt = 0xFFFF;
  1065. break;
  1066. case 0x1886D0F3:
  1067. BMS_MinCellVolt = 0xFFFF;
  1068. BMS_MinCellVoltCSC = 0xFF;
  1069. BMS_MinCellVoltNum = 0xFF;
  1070. BMS_ContChrgCurr = 0xFFFF;
  1071. BMS_ContDisCharCurr = 0xFFFF;
  1072. break;
  1073. case 0x1887D0F3:
  1074. BMS_CharReqVolt = 0xFFFF;
  1075. BMS_CharReqCurr = 0xFFFF;
  1076. BMS_SysInsRes = 0xFFFF;
  1077. BMS_InsDeteSt = 0xFF;
  1078. BMS_FtCharInsLow = 0xFF;
  1079. BMS_FtCurrSenr = 0xFF;
  1080. BMS_FtHeatingFilm = 0xFF;
  1081. BMS_FtMainLoopPreChar = 0xFF;
  1082. BMS_FtAuxLoopPreChar = 0xFF;
  1083. BMS_FtACANLost = 0xFF;
  1084. BMS_FtDCDC = 0xFF;
  1085. BMS_FtSOCDif = 0xFF;
  1086. BMS_FtCellOverDisChar = 0xFF;
  1087. BMS_FtCharOver = 0xFF;
  1088. BMS_FtContDisCharCurrOverLoad = 0xFF;
  1089. BMS_FtContCharCurrOverLoad = 0xFF;
  1090. break;
  1091. case 0x1888D0F3:
  1092. BMS_MaxDisCharPwr = 0xFFFF;
  1093. BMS_MaxCharPwr = 0xFFFF;
  1094. BMS_ContDisCharPwr = 0xFFFF;
  1095. BMS_ContCharPwr = 0xFFFF;
  1096. break;
  1097. case 0x1889D0F3:
  1098. BMS_InstEngyCons = 0xFFFF;
  1099. BMS_TotalEngyCons = 0xFFFF;
  1100. BMS_SOE = 0xFFFF;
  1101. BMS_RmanCharTime = 0xFFFF;
  1102. break;
  1103. case 0x188AD0F3:
  1104. BMS_Gun1DCNegTemp = 0xFF;
  1105. BMS_Gun1DCPosTemp = 0xFF;
  1106. BMS_Gun2DCNegTemp = 0xFF;
  1107. BMS_Gun2DCPosTemp = 0xFF;
  1108. BMS_CurrHeatSt = 0xFF;
  1109. BMS_CurrCoolSt = 0xFF;
  1110. BMS_FtCharCnct = 0xFF;
  1111. BMS_FtOverDisCharCurrDuringChar = 0xFF;
  1112. BMS_FtCharNTC = 0xFF;
  1113. BMS_FtELock = 0xFF;
  1114. BMS_CharNum = 0xFFFF;
  1115. break;
  1116. case 0x18C1D0F3:
  1117. BMS_CellVoltFramNum = 0xFF;
  1118. BMS_CellRecvCounter = 0;
  1119. for (UINT16 i = 0; i < sizeof(BMS_CellVolt) / 2; i++)
  1120. {
  1121. BMS_CellVolt[i] = 0xFFFF;
  1122. }
  1123. break;
  1124. case 0x18C2D0F3:
  1125. BMS_CellTempFramNum = 0xFF;
  1126. BMS_CSC_Code = 0xFF;
  1127. for (UINT8 i = 0; i < sizeof(BMS_CellTemp); i++)
  1128. {
  1129. BMS_CellTemp[i] = 0xFF;
  1130. }
  1131. break;
  1132. case 0x18E1D0F3:
  1133. BMS_Checksum = 0xFF;
  1134. BMS_PackComp = 0xFF;
  1135. BMS_BattCodeLeng = 0xFF;
  1136. BMS_SN[0] = 0xFF;
  1137. BMS_SN[1] = 0xFF;
  1138. BMS_SN[2] = 0xFF;
  1139. BMS_SN[3] = 0xFF;
  1140. BMS_SN[4] = 0xFF;
  1141. BMS_SN[5] = 0xFF;
  1142. break;
  1143. case 0x18E2D0F3:
  1144. BMS_Checksum = 0xFF;
  1145. BMS_SN[6] = 0xFF;
  1146. BMS_SN[7] = 0xFF;
  1147. BMS_SN[8] = 0xFF;
  1148. BMS_SN[9] = 0xFF;
  1149. BMS_SN[10] = 0xFF;
  1150. BMS_SN[11] = 0xFF;
  1151. BMS_SN[12] = 0xFF;
  1152. break;
  1153. case 0x18E3D0F3:
  1154. BMS_Checksum = 0xFF;
  1155. BMS_SN[13] = 0xFF;
  1156. BMS_SN[14] = 0xFF;
  1157. BMS_SN[15] = 0xFF;
  1158. BMS_SN[16] = 0xFF;
  1159. BMS_SN[17] = 0xFF;
  1160. BMS_SN[18] = 0xFF;
  1161. BMS_SN[19] = 0xFF;
  1162. break;
  1163. case 0x18E4D0F3:
  1164. BMS_Checksum = 0xFF;
  1165. BMS_SN[20] = 0xFF;
  1166. BMS_SN[21] = 0xFF;
  1167. BMS_SN[22] = 0xFF;
  1168. BMS_SN[23] = 0xFF;
  1169. BMS_SN[24] = 0xFF;
  1170. BMS_SN[25] = 0xFF;
  1171. BMS_SN[26] = 0xFF;
  1172. break;
  1173. case 0x18E5D0F3:
  1174. BMS_BattRateCap = 0xFFFF;
  1175. BMS_BattRateVolt = 0xFFFF;
  1176. BMS_BattRateEngy = 0xFFFF;
  1177. BMS_BattType = 0xFF;
  1178. BMS_CoolType = 0xFF;
  1179. break;
  1180. case 0x18E6D0F3:
  1181. BMS_CSC_Total = 0xFF;
  1182. // BMS_CellTotal = BMS_CELL_MAX_NUM;
  1183. // BMS_TempTotal = BMS_TEMP_MAX_NUM;
  1184. BMS_CellVoltLevel = 0xFF;
  1185. BMS_CellMinVolt = 0xFF;
  1186. BMS_CellMaxVolt = 0xFF;
  1187. break;
  1188. case 0x18F1D0F3:
  1189. BMS_TotalCharEngy = 0xFFFFFFFF;
  1190. BMS_TotalDisCharEngy = 0xFFFFFFFF;
  1191. BMS_SingleCharEngy = 0xFFFF;
  1192. break;
  1193. case 0x18F2D0F3:
  1194. BMS_TotalBackCharEngy = 0xFFFFFFFF;
  1195. BMS_TotalStaCharEngy = 0xFFFFFFFF;
  1196. break;
  1197. case 0x18F3D0F3:
  1198. BMS_TotalGunCharEngy = 0xFFFFFFFF;
  1199. BMS_TotalGunCharCapy = 0xFFFFFFFF;
  1200. break;
  1201. case 0x18F4D0F3:
  1202. BMS_TotalCharCapy = 0xFFFFFFFF;
  1203. BMS_TotalDisCharCapy = 0xFFFFFFFF;
  1204. BMS_SingleCharCapy = 0xFFFF;
  1205. break;
  1206. case 0x18F5D0F3:
  1207. BMS_TotalBackCharCapy = 0xFFFFFFFF;
  1208. BMS_TotalStaCharCapy = 0xFFFFFFFF;
  1209. BMS_HVBranNum = 0xFF;
  1210. BMS_SingleHVBranchCellNum = 0xFF;
  1211. break;
  1212. case 0x18FF45F4:
  1213. BMS_ReqMode = 0xFF;
  1214. BMS_HVCmd = 0xFF;
  1215. BMS_ChgSts = 0xFF;
  1216. BMS_HVRelaySts = 0xFF;
  1217. BMS_HVVolt = 0xFFFF;
  1218. BMS_SetTemp = 0xFF;
  1219. BMS_Life = 0xFF;
  1220. BMS_CRC = 0xFF;
  1221. break;
  1222. case 0x18FFC13A:
  1223. TMS_WorkStatus = 0xFF;
  1224. TMS_HVRelayST = 0xFF;
  1225. TMS_OutletTemp = 0xFF;
  1226. TMS_InletTemp = 0xFF;
  1227. TMS_ReqPow = 0xFFFF;
  1228. TMS_ErrCode = 0xFF;
  1229. TMS_FaultLevel = 0xFF;
  1230. break;
  1231. default:
  1232. break;
  1233. }
  1234. }
  1235. #endif