AppTaskCan.c 41 KB

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