AppTaskCan.c 41 KB

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