AppTaskCan.c 41 KB

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