AppTaskCan.c 43 KB

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