AppTaskCan.c 41 KB

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