foxBMS - Unit Tests  1.4.0
The foxBMS Unit Tests API Documentation
can_cbs_tx_state.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file can_cbs_tx_state.c
44  * @author foxBMS Team
45  * @date 2021-07-21 (date of creation)
46  * @updated 2022-07-28 (date of last update)
47  * @version v1.4.0
48  * @ingroup DRIVER
49  * @prefix CAN
50  *
51  * @brief CAN driver Tx callback implementation
52  * @details CAN Tx callback for state messages
53  */
54 
55 /*========== Includes =======================================================*/
56 #include "bms.h"
57 #include "can_cbs.h"
58 #include "can_helper.h"
59 #include "diag.h"
60 #include "sys_mon.h"
61 
62 /*========== Macros and Definitions =========================================*/
63 
64 /*========== Static Constant and Variable Definitions =======================*/
65 
66 /*========== Extern Constant and Variable Definitions =======================*/
67 
68 /*========== Static Function Prototypes =====================================*/
69 /** get a boolean for if any timing error (current or recorded) occurred */
70 static bool CAN_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim);
71 
72 /*========== Static Function Implementations ================================*/
73 static bool CAN_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim) {
74  FAS_ASSERT(kpkCanShim != NULL_PTR);
75  SYSM_TIMING_VIOLATION_RESPONSE_s recordedTimingViolations = {0};
76  SYSM_GetRecordedTimingViolations(&recordedTimingViolations);
77 
78  const bool anyTimingViolation =
79  (recordedTimingViolations.recordedViolationAny || kpkCanShim->pTableErrorState->timingViolationEngine ||
82 
83  return anyTimingViolation;
84 }
85 
86 /*========== Extern Function Implementations ================================*/
87 extern uint32_t CAN_TxState(
88  uint32_t id,
89  uint8_t dlc,
90  CAN_ENDIANNESS_e endianness,
91  uint8_t *pCanData,
92  uint8_t *pMuxId,
93  const CAN_SHIM_s *const kpkCanShim) {
94  /* pMuxId is not used here, therefore has to be NULL_PTR */
95  FAS_ASSERT(pMuxId == NULL_PTR);
96 
97  FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */
98  FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */
99  FAS_ASSERT(pCanData != NULL_PTR);
100  FAS_ASSERT(kpkCanShim != NULL_PTR);
101  uint64_t message = 0;
102 
103  DATA_READ_DATA(kpkCanShim->pTableErrorState, kpkCanShim->pTableInsulation, kpkCanShim->pTableMsl);
104 
105  /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */
106  /* State */
107  uint64_t data = (uint64_t)BMS_GetState();
108  /* set data in CAN frame */
109  CAN_TxSetMessageDataWithSignalData(&message, 3u, 4u, data, endianness);
110 
111  /* Connected strings */
112  data = (uint64_t)BMS_GetNumberOfConnectedStrings();
113  /* set data in CAN frame */
114  CAN_TxSetMessageDataWithSignalData(&message, 7u, 4u, data, endianness);
115 
116  /* General error - implement now */
118  CAN_TxSetMessageDataWithSignalData(&message, 11u, 1u, data, endianness);
119 
120  /* General warning: TODO */
121 
122  /* Emergency shutoff */
124  CAN_TxSetMessageDataWithSignalData(&message, 10u, 1u, data, endianness);
125 
126  /* Number of deactivated strings: TODO */
127 
128  /* sys mon error */
130  CAN_TxSetMessageDataWithSignalData(&message, 12u, 1u, data, endianness);
131 
132  /* Insulation monitoring active */
134  CAN_TxSetMessageDataWithSignalData(&message, 13u, 1u, data, endianness);
135 
136  /* Error: insulation */
138  CAN_TxSetMessageDataWithSignalData(&message, 23u, 1u, data, endianness);
139 
140  /* Insulation resistance */
141  float signalData = (float)kpkCanShim->pTableInsulation->insulationResistance_kOhm;
142  signalData = signalData * 0.1f; /* convert kOhm to 10kOhm */
143  data = (uint64_t)signalData;
144  CAN_TxSetMessageDataWithSignalData(&message, 63u, 8u, data, endianness);
145 
146  /* Charging complete: TODO */
147 
148  /* Heater state: TODO */
149  /* Cooling state: TODO */
150 
151  /* Error: Precharge voltage: TODO */
152  /* Error: Precharge current: TODO */
153 
154  /* Error: MCU die temperature */
155  data = kpkCanShim->pTableErrorState->mcuDieTemperature;
156  CAN_TxSetMessageDataWithSignalData(&message, 18u, 1u, data, endianness);
157 
158  /* Error: master overtemperature: TODO */
159  /* Error: master undertemperature: TODO */
160 
161  /* Error: interlock */
162  data = kpkCanShim->pTableErrorState->interlock;
163  CAN_TxSetMessageDataWithSignalData(&message, 22u, 1u, data, endianness);
164 
165  /* Main fuse state: TODO */
166 
167  /* Error: Can timing */
168  data = kpkCanShim->pTableErrorState->canTiming;
169  CAN_TxSetMessageDataWithSignalData(&message, 24u, 1u, data, endianness);
170 
171  /* Error: Overcurrent pack charge */
172  data = kpkCanShim->pTableMsl->packChargeOvercurrent;
173  CAN_TxSetMessageDataWithSignalData(&message, 25u, 1u, data, endianness);
174 
175  /* Error: Overcurrent pack discharge */
176  data = kpkCanShim->pTableMsl->packDischargeOvercurrent;
177  CAN_TxSetMessageDataWithSignalData(&message, 26u, 1u, data, endianness);
178  /* AXIVION Enable Style Generic-NoMagicNumbers: */
179 
180  /* now copy data in the buffer that will be use to send data */
181  CAN_TxSetCanDataWithMessageData(message, pCanData, endianness);
182 
183  return 0;
184 }
185 
186 extern uint32_t CAN_TxDetailState(
187  uint32_t id,
188  uint8_t dlc,
189  CAN_ENDIANNESS_e endianness,
190  uint8_t *pCanData,
191  uint8_t *pMuxId,
192  const CAN_SHIM_s *const kpkCanShim) {
193  /* pMuxId is not used here, therefore has to be NULL_PTR */
194  FAS_ASSERT(pMuxId == NULL_PTR);
195 
196  FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */
197  FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */
198  FAS_ASSERT(pCanData != NULL_PTR);
199  FAS_ASSERT(kpkCanShim != NULL_PTR);
200  uint64_t message = 0;
201 
202  DATA_READ_DATA(kpkCanShim->pTableErrorState);
203  SYSM_TIMING_VIOLATION_RESPONSE_s recordedTimingViolations = {0};
204  SYSM_GetRecordedTimingViolations(&recordedTimingViolations);
205 
206  /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */
207  /* current violation engine */
209  CAN_TxSetMessageDataWithSignalData(&message, 0u, 1u, data, endianness);
210  /* current violation 1ms */
212  CAN_TxSetMessageDataWithSignalData(&message, 1u, 1u, data, endianness);
213  /* current violation 10ms */
215  CAN_TxSetMessageDataWithSignalData(&message, 2u, 1u, data, endianness);
216  /* current violation 100ms */
218  CAN_TxSetMessageDataWithSignalData(&message, 3u, 1u, data, endianness);
219  /* current violation 100ms algorithm */
221  CAN_TxSetMessageDataWithSignalData(&message, 4u, 1u, data, endianness);
222 
223  /* recorded violation engine */
224  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolationEngine);
225  CAN_TxSetMessageDataWithSignalData(&message, 8u, 1u, data, endianness);
226  /* recorded violation 1ms */
227  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation1ms);
228  CAN_TxSetMessageDataWithSignalData(&message, 9u, 1u, data, endianness);
229  /* recorded violation 10ms */
230  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation10ms);
231  CAN_TxSetMessageDataWithSignalData(&message, 10u, 1u, data, endianness);
232  /* recorded violation 100ms */
233  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation100ms);
234  CAN_TxSetMessageDataWithSignalData(&message, 11u, 1u, data, endianness);
235  /* recorded violation 100ms algorithm */
236  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation100msAlgo);
237  CAN_TxSetMessageDataWithSignalData(&message, 12u, 1u, data, endianness);
238  /* AXIVION Enable Style Generic-NoMagicNumbers: */
239 
240  /* now copy data in the buffer that will be use to send data */
241  CAN_TxSetCanDataWithMessageData(message, pCanData, endianness);
242 
243  return 0;
244 }
245 
246 extern uint32_t CAN_TxStringState(
247  uint32_t id,
248  uint8_t dlc,
249  CAN_ENDIANNESS_e endianness,
250  uint8_t *pCanData,
251  uint8_t *pMuxId,
252  const CAN_SHIM_s *const kpkCanShim) {
253  FAS_ASSERT(id < CAN_MAX_11BIT_ID); /* Currently standard ID, 11 bit */
254  FAS_ASSERT(dlc <= CAN_MAX_DLC); /* Currently max 8 bytes in a CAN frame */
255  FAS_ASSERT(pCanData != NULL_PTR);
256  FAS_ASSERT(pMuxId != NULL_PTR);
257  FAS_ASSERT(*pMuxId < BS_NR_OF_STRINGS);
258  FAS_ASSERT(kpkCanShim != NULL_PTR);
259  uint64_t message = 0;
260  uint64_t data = 0;
261 
262  const uint8_t stringNumber = *pMuxId;
263 
264  /* First signal to transmit cell voltages: get database values */
265  if (stringNumber == 0u) {
266  /* Do not read pTableMsl and pTableErrorState as they already are read
267  * with a higher frequency from CAN_TxState callback */
268  DATA_READ_DATA(kpkCanShim->pTableRsl, kpkCanShim->pTableMol);
269  }
270 
271  /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */
272  /* mux value */
273  data = (uint64_t)stringNumber;
274  /* set data in CAN frame */
275  CAN_TxSetMessageDataWithSignalData(&message, 3u, 4u, data, endianness);
276 
277  /* String connected */
278  data = CAN_ConvertBooleanToInteger(BMS_IsStringClosed(stringNumber));
279  CAN_TxSetMessageDataWithSignalData(&message, 4u, 1u, data, endianness);
280 
281  /* Balancing active: TODO */
282 
283  /* String fuse blown */
284  if ((kpkCanShim->pTableErrorState->fuseStateCharge[stringNumber] == 1u) ||
285  (kpkCanShim->pTableErrorState->fuseStateNormal[stringNumber] == 1u)) {
286  data = 1u;
287  } else {
288  data = 0u;
289  }
290  CAN_TxSetMessageDataWithSignalData(&message, 6u, 1u, data, endianness);
291 
292  /* Error: Deep-discharge */
293  data = kpkCanShim->pTableErrorState->deepDischargeDetected[stringNumber];
294  CAN_TxSetMessageDataWithSignalData(&message, 7u, 1u, data, endianness);
295 
296  /* Error: Overtemperature charge */
297  data = kpkCanShim->pTableMsl->overtemperatureCharge[stringNumber];
298  CAN_TxSetMessageDataWithSignalData(&message, 8u, 1u, data, endianness);
299 
300  /* Error: Undertemperature charge */
301  data = kpkCanShim->pTableMsl->undertemperatureCharge[stringNumber];
302  CAN_TxSetMessageDataWithSignalData(&message, 9u, 1u, data, endianness);
303 
304  /* Error: Overtemperature discharge */
305  data = kpkCanShim->pTableMsl->overtemperatureDischarge[stringNumber];
306  CAN_TxSetMessageDataWithSignalData(&message, 10u, 1u, data, endianness);
307 
308  /* Error: Undertemperature discharge */
309  data = kpkCanShim->pTableMsl->undertemperatureDischarge[stringNumber];
310  CAN_TxSetMessageDataWithSignalData(&message, 11u, 1u, data, endianness);
311 
312  /* Error: Overcurrent charge */
313  if ((kpkCanShim->pTableMsl->cellChargeOvercurrent[stringNumber] == 1u) ||
314  (kpkCanShim->pTableMsl->stringChargeOvercurrent[stringNumber] == 1u)) {
315  data = 1u;
316  } else {
317  data = 0u;
318  }
319  CAN_TxSetMessageDataWithSignalData(&message, 12u, 1u, data, endianness);
320 
321  /* Error: Overcurrent discharge */
322  if ((kpkCanShim->pTableMsl->cellDischargeOvercurrent[stringNumber] == 1u) ||
323  (kpkCanShim->pTableMsl->stringDischargeOvercurrent[stringNumber] == 1u)) {
324  data = 1u;
325  } else {
326  data = 0u;
327  }
328  CAN_TxSetMessageDataWithSignalData(&message, 13u, 1u, data, endianness);
329 
330  /* Error: Overvoltage */
331  data = kpkCanShim->pTableMsl->overVoltage[stringNumber];
332  CAN_TxSetMessageDataWithSignalData(&message, 14u, 1u, data, endianness);
333 
334  /* Error: Undervoltage */
335  data = kpkCanShim->pTableMsl->underVoltage[stringNumber];
336  CAN_TxSetMessageDataWithSignalData(&message, 15u, 1u, data, endianness);
337 
338  /* Info: Overtemperature charge - MOL */
339  data = kpkCanShim->pTableMol->overtemperatureCharge[stringNumber];
340  CAN_TxSetMessageDataWithSignalData(&message, 16u, 1u, data, endianness);
341 
342  /* Info: Undertemperature charge - MOL */
343  data = kpkCanShim->pTableMol->undertemperatureCharge[stringNumber];
344  CAN_TxSetMessageDataWithSignalData(&message, 17u, 1u, data, endianness);
345 
346  /* Info: Overtemperature discharge - MOL */
347  data = kpkCanShim->pTableMol->overtemperatureDischarge[stringNumber];
348  CAN_TxSetMessageDataWithSignalData(&message, 18u, 1u, data, endianness);
349 
350  /* Info: Undertemperature discharge - MOL */
351  data = kpkCanShim->pTableMol->undertemperatureCharge[stringNumber];
352  CAN_TxSetMessageDataWithSignalData(&message, 19u, 1u, data, endianness);
353 
354  /* Info: Overcurrent charge - MOL */
355  if ((kpkCanShim->pTableMol->cellChargeOvercurrent[stringNumber] == 1u) ||
356  (kpkCanShim->pTableMol->stringChargeOvercurrent[stringNumber] == 1u)) {
357  data = 1u;
358  } else {
359  data = 0u;
360  }
361  CAN_TxSetMessageDataWithSignalData(&message, 20u, 1u, data, endianness);
362 
363  /* Info: Overcurrent discharge - MOL */
364  if ((kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber] == 1u) ||
365  (kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber] == 1u)) {
366  data = 1u;
367  } else {
368  data = 0u;
369  }
370  CAN_TxSetMessageDataWithSignalData(&message, 21u, 1u, data, endianness);
371 
372  /* Info: Overvoltage - MOL */
373  data = kpkCanShim->pTableMol->overVoltage[stringNumber];
374  CAN_TxSetMessageDataWithSignalData(&message, 22u, 1u, data, endianness);
375 
376  /* Info: Undervoltage - MOL */
377  data = kpkCanShim->pTableMol->underVoltage[stringNumber];
378  CAN_TxSetMessageDataWithSignalData(&message, 23u, 1u, data, endianness);
379 
380  /* Warning: Overtemperature charge - RSL */
381  data = kpkCanShim->pTableRsl->overtemperatureCharge[stringNumber];
382  CAN_TxSetMessageDataWithSignalData(&message, 24u, 1u, data, endianness);
383 
384  /* Warning: Undertemperature charge - RSL */
385  data = kpkCanShim->pTableRsl->undertemperatureCharge[stringNumber];
386  CAN_TxSetMessageDataWithSignalData(&message, 25u, 1u, data, endianness);
387 
388  /* Warning: Overtemperature discharge - RSL */
389  data = kpkCanShim->pTableRsl->overtemperatureDischarge[stringNumber];
390  CAN_TxSetMessageDataWithSignalData(&message, 26u, 1u, data, endianness);
391 
392  /* Warning: Undertemperature discharge - RSL */
393  data = kpkCanShim->pTableRsl->undertemperatureDischarge[stringNumber];
394  CAN_TxSetMessageDataWithSignalData(&message, 27u, 1u, data, endianness);
395 
396  /* Warning: Overcurrent charge - RSL */
397  if ((kpkCanShim->pTableRsl->cellChargeOvercurrent[stringNumber] == 1u) ||
398  (kpkCanShim->pTableRsl->stringChargeOvercurrent[stringNumber] == 1u)) {
399  data = 1u;
400  } else {
401  data = 0u;
402  }
403  CAN_TxSetMessageDataWithSignalData(&message, 28u, 1u, data, endianness);
404 
405  /* Warning: Overcurrent discharge - RSL */
406  if ((kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber] == 1u) ||
407  (kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber] == 1u)) {
408  data = 1u;
409  } else {
410  data = 0u;
411  }
412  CAN_TxSetMessageDataWithSignalData(&message, 29u, 1u, data, endianness);
413 
414  /* Warning: Overvoltage - RSL */
415  data = kpkCanShim->pTableRsl->overVoltage[stringNumber];
416  CAN_TxSetMessageDataWithSignalData(&message, 30u, 1u, data, endianness);
417 
418  /* Warning: Undervoltage - RSL */
419  data = kpkCanShim->pTableRsl->underVoltage[stringNumber];
420  CAN_TxSetMessageDataWithSignalData(&message, 31u, 1u, data, endianness);
421 
422  /* Error: Positive string contactor: TODO */
423  /* Error: Negative string contactor: TODO */
424  /* Error: Slave hardware: TODO */
425 
426  /* Error: Daisy-chain base: communication */
427  data = kpkCanShim->pTableErrorState->spiError[stringNumber];
428  CAN_TxSetMessageDataWithSignalData(&message, 35u, 1u, data, endianness);
429 
430  /* Error: Daisy-chain redundancy: communication: TODO */
431  /* Error: Daisy-chain base: CRC */
432  data = kpkCanShim->pTableErrorState->crcError[stringNumber];
433  CAN_TxSetMessageDataWithSignalData(&message, 37u, 1u, data, endianness);
434 
435  /* Error: Daisy-chain redundancy: CRC: TODO */
436  /* Error: Daisy-chain base: Voltage out of operating range */
437  data = kpkCanShim->pTableErrorState->afeCellVoltageError[stringNumber];
438  CAN_TxSetMessageDataWithSignalData(&message, 39u, 1u, data, endianness);
439 
440  /* Error: Daisy-chain redundancy: Voltage out of operating range: TODO */
441  /* Error: Daisy-chain base: Temperature out of operating range */
442  data = kpkCanShim->pTableErrorState->afeCellTemperatureError[stringNumber];
443  CAN_TxSetMessageDataWithSignalData(&message, 41u, 1u, data, endianness);
444 
445  /* Error: Daisy-chain redundancy: Voltage out of operating range: TODO */
446 
447  /* Error: current measurement */
448  if ((kpkCanShim->pTableErrorState->currentMeasurementError[stringNumber] == 1u) ||
449  (kpkCanShim->pTableErrorState->currentMeasurementTimeout[stringNumber] == 1u)) {
450  data = 1u;
451  } else {
452  data = 0u;
453  }
454  CAN_TxSetMessageDataWithSignalData(&message, 43u, 1u, data, endianness);
455 
456  /* Error: Coulomb counting measurement */
457  data = kpkCanShim->pTableErrorState->canTimingCc[stringNumber];
458  CAN_TxSetMessageDataWithSignalData(&message, 44u, 1u, data, endianness);
459 
460  /* Error: Energy counting measurement */
461  data = kpkCanShim->pTableErrorState->canTimingEc[stringNumber];
462  CAN_TxSetMessageDataWithSignalData(&message, 45u, 1u, data, endianness);
463 
464  /* Error: Current sensor V1 measurement */
465  data = kpkCanShim->pTableErrorState->currentSensorTimeoutV1[stringNumber];
466  CAN_TxSetMessageDataWithSignalData(&message, 46u, 1u, data, endianness);
467 
468  /* Error: Current sensor V2 measurement: TODO */
469  /* Error: Current sensor V3 measurement */
470  data = kpkCanShim->pTableErrorState->currentSensorTimeoutV3[stringNumber];
471  CAN_TxSetMessageDataWithSignalData(&message, 48u, 1u, data, endianness);
472 
473  /* Error: Open wire */
474  data = kpkCanShim->pTableErrorState->open_wire[stringNumber];
475  CAN_TxSetMessageDataWithSignalData(&message, 49u, 1u, data, endianness);
476 
477  /* Error: Plausibility: Cell temperature */
478  data = kpkCanShim->pTableErrorState->plausibilityCheckCelltemperature[stringNumber];
479  CAN_TxSetMessageDataWithSignalData(&message, 51u, 1u, data, endianness);
480 
481  /* Error: Plausibility: Cell voltage */
482  data = kpkCanShim->pTableErrorState->plausibilityCheckCellVoltage[stringNumber];
483  CAN_TxSetMessageDataWithSignalData(&message, 52u, 1u, data, endianness);
484 
485  /* Error: Plausibility: String voltage */
486  data = kpkCanShim->pTableErrorState->plausibilityCheckPackvoltage[stringNumber];
487  CAN_TxSetMessageDataWithSignalData(&message, 53u, 1u, data, endianness);
488 
489  /* Error: Plausibility: Cell temperature spread */
490  data = kpkCanShim->pTableErrorState->plausibilityCheckCelltemperatureSpread[stringNumber];
491  CAN_TxSetMessageDataWithSignalData(&message, 54u, 1u, data, endianness);
492 
493  /* Error: Plausibility: Cell voltage spread */
494  data = kpkCanShim->pTableErrorState->plausibilityCheckCellVoltageSpread[stringNumber];
495  CAN_TxSetMessageDataWithSignalData(&message, 55u, 1u, data, endianness);
496  /* AXIVION Enable Style Generic-NoMagicNumbers: */
497 
498  /* Open wire number: TODO */
499 
500  /* now copy data in the buffer that will be used to send data */
501  CAN_TxSetCanDataWithMessageData(message, pCanData, endianness);
502 
503  /* Increment multiplexer for next cell */
504  (*pMuxId)++;
505 
506  /* Check mux value */
507  if (*pMuxId >= BS_NR_OF_STRINGS) {
508  *pMuxId = 0u;
509  }
510 
511  return 0;
512 }
513 
514 /*========== Externalized Static Function Implementations (Unit Test) =======*/
515 #ifdef UNITY_UNIT_TEST
516 
517 #endif
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
bool BMS_IsTransitionToErrorStateActive(void)
Check if transition in to error state is active.
Definition: bms.c:1325
uint8_t BMS_GetNumberOfConnectedStrings(void)
Returns number of connected strings.
Definition: bms.c:1321
bool BMS_IsStringClosed(uint8_t stringNumber)
Returns string state (closed or open)
Definition: bms.c:1303
BMS_STATEMACH_e BMS_GetState(void)
Returns the current state.
Definition: bms.c:631
bms driver header
CAN callbacks header.
uint32_t CAN_TxDetailState(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for detail state
uint32_t CAN_TxStringState(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for string state values
static bool CAN_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim)
uint32_t CAN_TxState(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for state
CAN_ENDIANNESS_e
Definition: can_cfg.h:298
#define CAN_MAX_11BIT_ID
Definition: can_cfg.h:86
#define CAN_MAX_DLC
Definition: can_cfg.h:88
void CAN_TxSetMessageDataWithSignalData(uint64_t *pMessage, uint64_t bitStart, uint8_t bitLength, uint64_t canSignal, CAN_ENDIANNESS_e endianness)
Puts CAN signal data in a 64-bit variable. This function is used to compose a 64-bit CAN message....
Definition: can_helper.c:167
void CAN_TxSetCanDataWithMessageData(uint64_t message, uint8_t *pCanData, CAN_ENDIANNESS_e endianness)
Copy CAN data from a 64-bit variable to 8 bytes. This function is used to copy a 64-bit CAN message t...
Definition: can_helper.c:206
uint8_t CAN_ConvertBooleanToInteger(bool input)
Transform a bool to a bit (set if true)
Definition: can_helper.c:336
Headers for the helper functions for the CAN module.
#define DATA_READ_DATA(...)
Definition: database.h:83
bool DIAG_IsAnyFatalErrorSet(void)
Check if any fatal error is set.
Definition: diag.c:376
Diagnosis driver header.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:248
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76
DATA_BLOCK_RSL_FLAG_s * pTableRsl
Definition: can_cfg.h:325
DATA_BLOCK_ERRORSTATE_s * pTableErrorState
Definition: can_cfg.h:322
DATA_BLOCK_MSL_FLAG_s * pTableMsl
Definition: can_cfg.h:324
DATA_BLOCK_MOL_FLAG_s * pTableMol
Definition: can_cfg.h:326
DATA_BLOCK_INSULATION_MONITORING_s * pTableInsulation
Definition: can_cfg.h:323
uint8_t plausibilityCheckCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:367
uint8_t currentMeasurementError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:345
uint8_t plausibilityCheckCelltemperature[BS_NR_OF_STRINGS]
Definition: database_cfg.h:370
uint8_t plausibilityCheckCelltemperatureSpread[BS_NR_OF_STRINGS]
Definition: database_cfg.h:369
uint8_t plausibilityCheckPackvoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:366
uint8_t currentSensorTimeoutV1[BS_NR_OF_STRINGS]
Definition: database_cfg.h:346
uint8_t fuseStateCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:358
uint8_t crcError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:334
uint8_t currentSensorTimeoutV3[BS_NR_OF_STRINGS]
Definition: database_cfg.h:347
uint8_t deepDischargeDetected[BS_NR_OF_STRINGS]
Definition: database_cfg.h:371
uint8_t afeCellTemperatureError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:339
uint8_t canTimingEc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:363
uint8_t open_wire[BS_NR_OF_STRINGS]
Definition: database_cfg.h:359
uint8_t plausibilityCheckCellVoltageSpread[BS_NR_OF_STRINGS]
Definition: database_cfg.h:368
uint8_t currentMeasurementTimeout[BS_NR_OF_STRINGS]
Definition: database_cfg.h:344
uint8_t fuseStateNormal[BS_NR_OF_STRINGS]
Definition: database_cfg.h:357
uint8_t afeCellVoltageError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:338
uint8_t spiError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:336
uint8_t canTimingCc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:362
uint8_t cellChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:499
uint8_t underVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:494
uint8_t cellDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:501
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:496
uint8_t overVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:493
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:495
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:497
uint8_t stringChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:500
uint8_t stringDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:502
uint8_t stringChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:460
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:458
uint8_t cellChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:459
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:455
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:456
uint8_t stringDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:462
uint8_t underVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:454
uint8_t cellDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:461
uint8_t overVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:453
uint8_t packDischargeOvercurrent
Definition: database_cfg.h:452
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:457
uint8_t underVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:474
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:478
uint8_t stringChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:480
uint8_t overVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:473
uint8_t cellChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:479
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:477
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:476
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:475
void SYSM_GetRecordedTimingViolations(SYSM_TIMING_VIOLATION_RESPONSE_s *pAnswer)
Returns the timing violation flags determined from fram state.
Definition: sys_mon.c:200
system monitoring module