foxBMS - Unit Tests  1.4.1
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-10-27 (date of last update)
47  * @version v1.4.1
48  * @ingroup DRIVER
49  * @prefix CANTX
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_tx.h"
59 #include "can_helper.h"
60 #include "diag.h"
61 #include "sys_mon.h"
62 
63 /*========== Macros and Definitions =========================================*/
64 
65 /*========== Static Constant and Variable Definitions =======================*/
66 
67 /*========== Extern Constant and Variable Definitions =======================*/
68 
69 /*========== Static Function Prototypes =====================================*/
70 /** get a boolean for if any timing error (current or recorded) occurred */
71 static bool CANTX_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim);
72 
73 /*========== Static Function Implementations ================================*/
74 static bool CANTX_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim) {
75  FAS_ASSERT(kpkCanShim != NULL_PTR);
76  SYSM_TIMING_VIOLATION_RESPONSE_s recordedTimingViolations = {0};
77  SYSM_GetRecordedTimingViolations(&recordedTimingViolations);
78 
79  const bool anyTimingViolation =
80  (recordedTimingViolations.recordedViolationAny || kpkCanShim->pTableErrorState->timingViolationEngine ||
83 
84  return anyTimingViolation;
85 }
86 
87 /*========== Extern Function Implementations ================================*/
88 extern uint32_t CANTX_BmsState(
90  uint8_t *pCanData,
91  uint8_t *pMuxId,
92  const CAN_SHIM_s *const kpkCanShim) {
93  FAS_ASSERT(message.id == CANTX_BMS_STATE_ID);
95  FAS_ASSERT(pCanData != NULL_PTR);
96  FAS_ASSERT(pMuxId == NULL_PTR); /* pMuxId is not used here, therefore has to be NULL_PTR */
97  FAS_ASSERT(kpkCanShim != NULL_PTR);
98  uint64_t messageData = 0u;
99 
100  DATA_READ_DATA(kpkCanShim->pTableErrorState, kpkCanShim->pTableInsulation, kpkCanShim->pTableMsl);
101 
102  /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */
103  /* State */
104  uint64_t data = (uint64_t)BMS_GetState();
105  /* set data in CAN frame */
106  CAN_TxSetMessageDataWithSignalData(&messageData, 3u, 4u, data, message.endianness);
107 
108  /* Connected strings */
109  data = (uint64_t)BMS_GetNumberOfConnectedStrings();
110  /* set data in CAN frame */
111  CAN_TxSetMessageDataWithSignalData(&messageData, 7u, 4u, data, message.endianness);
112 
113  /* General error - implement now */
115  CAN_TxSetMessageDataWithSignalData(&messageData, 11u, 1u, data, message.endianness);
116 
117  /* General warning: TODO */
118 
119  /* Emergency shutoff */
121  CAN_TxSetMessageDataWithSignalData(&messageData, 10u, 1u, data, message.endianness);
122 
123  /* Number of deactivated strings: TODO */
124 
125  /* sys mon error */
127  CAN_TxSetMessageDataWithSignalData(&messageData, 12u, 1u, data, message.endianness);
128 
129  /* Insulation monitoring active */
131  CAN_TxSetMessageDataWithSignalData(&messageData, 13u, 1u, data, message.endianness);
132 
133  /* Error: insulation */
135  CAN_TxSetMessageDataWithSignalData(&messageData, 23u, 1u, data, message.endianness);
136 
137  /* Insulation resistance */
138  float signalData = (float)kpkCanShim->pTableInsulation->insulationResistance_kOhm;
139  signalData = signalData * 0.1f; /* convert kOhm to 10kOhm */
140  data = (uint64_t)signalData;
141  CAN_TxSetMessageDataWithSignalData(&messageData, 63u, 8u, data, message.endianness);
142 
143  /* Charging complete: TODO */
144 
145  /* Heater state: TODO */
146  /* Cooling state: TODO */
147 
148  /* Error: Precharge voltage: TODO */
149  /* Error: Precharge current: TODO */
150 
151  /* Error: MCU die temperature */
152  data = kpkCanShim->pTableErrorState->mcuDieTemperature;
153  CAN_TxSetMessageDataWithSignalData(&messageData, 18u, 1u, data, message.endianness);
154 
155  /* Error: master overtemperature: TODO */
156  /* Error: master undertemperature: TODO */
157 
158  /* Error: interlock */
159  data = kpkCanShim->pTableErrorState->interlock;
160  CAN_TxSetMessageDataWithSignalData(&messageData, 22u, 1u, data, message.endianness);
161 
162  /* Main fuse state: TODO */
163 
164  /* Error: Can timing */
165  data = kpkCanShim->pTableErrorState->canTiming;
166  CAN_TxSetMessageDataWithSignalData(&messageData, 24u, 1u, data, message.endianness);
167 
168  /* Error: Overcurrent pack charge */
169  data = kpkCanShim->pTableMsl->packChargeOvercurrent;
170  CAN_TxSetMessageDataWithSignalData(&messageData, 25u, 1u, data, message.endianness);
171 
172  /* Error: Overcurrent pack discharge */
173  data = kpkCanShim->pTableMsl->packDischargeOvercurrent;
174  CAN_TxSetMessageDataWithSignalData(&messageData, 26u, 1u, data, message.endianness);
175  /* AXIVION Enable Style Generic-NoMagicNumbers: */
176 
177  /* now copy data in the buffer that will be use to send data */
178  CAN_TxSetCanDataWithMessageData(messageData, pCanData, message.endianness);
179 
180  return 0;
181 }
182 
183 extern uint32_t CANTX_BmsStateDetails(
184  CAN_MESSAGE_PROPERTIES_s message,
185  uint8_t *pCanData,
186  uint8_t *pMuxId,
187  const CAN_SHIM_s *const kpkCanShim) {
190  FAS_ASSERT(pCanData != NULL_PTR);
191  FAS_ASSERT(pMuxId == NULL_PTR); /* pMuxId is not used here, therefore has to be NULL_PTR */
192  FAS_ASSERT(kpkCanShim != NULL_PTR);
193  uint64_t messageData = 0u;
194 
195  DATA_READ_DATA(kpkCanShim->pTableErrorState);
196  SYSM_TIMING_VIOLATION_RESPONSE_s recordedTimingViolations = {0};
197  SYSM_GetRecordedTimingViolations(&recordedTimingViolations);
198 
199  /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */
200  /* current violation engine */
202  CAN_TxSetMessageDataWithSignalData(&messageData, 0u, 1u, data, message.endianness);
203  /* current violation 1ms */
205  CAN_TxSetMessageDataWithSignalData(&messageData, 1u, 1u, data, message.endianness);
206  /* current violation 10ms */
208  CAN_TxSetMessageDataWithSignalData(&messageData, 2u, 1u, data, message.endianness);
209  /* current violation 100ms */
211  CAN_TxSetMessageDataWithSignalData(&messageData, 3u, 1u, data, message.endianness);
212  /* current violation 100ms algorithm */
214  CAN_TxSetMessageDataWithSignalData(&messageData, 4u, 1u, data, message.endianness);
215 
216  /* recorded violation engine */
217  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolationEngine);
218  CAN_TxSetMessageDataWithSignalData(&messageData, 8u, 1u, data, message.endianness);
219  /* recorded violation 1ms */
220  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation1ms);
221  CAN_TxSetMessageDataWithSignalData(&messageData, 9u, 1u, data, message.endianness);
222  /* recorded violation 10ms */
223  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation10ms);
224  CAN_TxSetMessageDataWithSignalData(&messageData, 10u, 1u, data, message.endianness);
225  /* recorded violation 100ms */
226  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation100ms);
227  CAN_TxSetMessageDataWithSignalData(&messageData, 11u, 1u, data, message.endianness);
228  /* recorded violation 100ms algorithm */
229  data = CAN_ConvertBooleanToInteger(recordedTimingViolations.recordedViolation100msAlgo);
230  CAN_TxSetMessageDataWithSignalData(&messageData, 12u, 1u, data, message.endianness);
231  /* AXIVION Enable Style Generic-NoMagicNumbers: */
232 
233  /* now copy data in the buffer that will be use to send data */
234  CAN_TxSetCanDataWithMessageData(messageData, pCanData, message.endianness);
235 
236  return 0;
237 }
238 
239 extern uint32_t CANTX_StringState(
240  CAN_MESSAGE_PROPERTIES_s message,
241  uint8_t *pCanData,
242  uint8_t *pMuxId,
243  const CAN_SHIM_s *const kpkCanShim) {
244  FAS_ASSERT(message.id == CANTX_STRING_STATE_ID);
246  FAS_ASSERT(pCanData != NULL_PTR);
247  FAS_ASSERT(pMuxId != NULL_PTR);
248  FAS_ASSERT(*pMuxId < BS_NR_OF_STRINGS);
249  FAS_ASSERT(kpkCanShim != NULL_PTR);
250  uint64_t messageData = 0u;
251  uint64_t data = 0;
252 
253  const uint8_t stringNumber = *pMuxId;
254 
255  /* First signal to transmit cell voltages: get database values */
256  if (stringNumber == 0u) {
257  /* Do not read pTableMsl and pTableErrorState as they already are read
258  * with a higher frequency from CAN_TxState callback */
259  DATA_READ_DATA(kpkCanShim->pTableRsl, kpkCanShim->pTableMol);
260  }
261 
262  /* AXIVION Disable Style Generic-NoMagicNumbers: Signal data defined in .dbc file. */
263  /* mux value */
264  data = (uint64_t)stringNumber;
265  /* set data in CAN frame */
266  CAN_TxSetMessageDataWithSignalData(&messageData, 3u, 4u, data, message.endianness);
267 
268  /* String connected */
269  data = CAN_ConvertBooleanToInteger(BMS_IsStringClosed(stringNumber));
270  CAN_TxSetMessageDataWithSignalData(&messageData, 4u, 1u, data, message.endianness);
271 
272  /* Balancing active: TODO */
273 
274  /* String fuse blown */
275  if ((kpkCanShim->pTableErrorState->fuseStateCharge[stringNumber] == 1u) ||
276  (kpkCanShim->pTableErrorState->fuseStateNormal[stringNumber] == 1u)) {
277  data = 1u;
278  } else {
279  data = 0u;
280  }
281  CAN_TxSetMessageDataWithSignalData(&messageData, 6u, 1u, data, message.endianness);
282 
283  /* Error: Deep-discharge */
284  data = kpkCanShim->pTableErrorState->deepDischargeDetected[stringNumber];
285  CAN_TxSetMessageDataWithSignalData(&messageData, 7u, 1u, data, message.endianness);
286 
287  /* Error: Overtemperature charge */
288  data = kpkCanShim->pTableMsl->overtemperatureCharge[stringNumber];
289  CAN_TxSetMessageDataWithSignalData(&messageData, 8u, 1u, data, message.endianness);
290 
291  /* Error: Undertemperature charge */
292  data = kpkCanShim->pTableMsl->undertemperatureCharge[stringNumber];
293  CAN_TxSetMessageDataWithSignalData(&messageData, 9u, 1u, data, message.endianness);
294 
295  /* Error: Overtemperature discharge */
296  data = kpkCanShim->pTableMsl->overtemperatureDischarge[stringNumber];
297  CAN_TxSetMessageDataWithSignalData(&messageData, 10u, 1u, data, message.endianness);
298 
299  /* Error: Undertemperature discharge */
300  data = kpkCanShim->pTableMsl->undertemperatureDischarge[stringNumber];
301  CAN_TxSetMessageDataWithSignalData(&messageData, 11u, 1u, data, message.endianness);
302 
303  /* Error: Overcurrent charge */
304  if ((kpkCanShim->pTableMsl->cellChargeOvercurrent[stringNumber] == 1u) ||
305  (kpkCanShim->pTableMsl->stringChargeOvercurrent[stringNumber] == 1u)) {
306  data = 1u;
307  } else {
308  data = 0u;
309  }
310  CAN_TxSetMessageDataWithSignalData(&messageData, 12u, 1u, data, message.endianness);
311 
312  /* Error: Overcurrent discharge */
313  if ((kpkCanShim->pTableMsl->cellDischargeOvercurrent[stringNumber] == 1u) ||
314  (kpkCanShim->pTableMsl->stringDischargeOvercurrent[stringNumber] == 1u)) {
315  data = 1u;
316  } else {
317  data = 0u;
318  }
319  CAN_TxSetMessageDataWithSignalData(&messageData, 13u, 1u, data, message.endianness);
320 
321  /* Error: Overvoltage */
322  data = kpkCanShim->pTableMsl->overVoltage[stringNumber];
323  CAN_TxSetMessageDataWithSignalData(&messageData, 14u, 1u, data, message.endianness);
324 
325  /* Error: Undervoltage */
326  data = kpkCanShim->pTableMsl->underVoltage[stringNumber];
327  CAN_TxSetMessageDataWithSignalData(&messageData, 15u, 1u, data, message.endianness);
328 
329  /* Info: Overtemperature charge - MOL */
330  data = kpkCanShim->pTableMol->overtemperatureCharge[stringNumber];
331  CAN_TxSetMessageDataWithSignalData(&messageData, 16u, 1u, data, message.endianness);
332 
333  /* Info: Undertemperature charge - MOL */
334  data = kpkCanShim->pTableMol->undertemperatureCharge[stringNumber];
335  CAN_TxSetMessageDataWithSignalData(&messageData, 17u, 1u, data, message.endianness);
336 
337  /* Info: Overtemperature discharge - MOL */
338  data = kpkCanShim->pTableMol->overtemperatureDischarge[stringNumber];
339  CAN_TxSetMessageDataWithSignalData(&messageData, 18u, 1u, data, message.endianness);
340 
341  /* Info: Undertemperature discharge - MOL */
342  data = kpkCanShim->pTableMol->undertemperatureCharge[stringNumber];
343  CAN_TxSetMessageDataWithSignalData(&messageData, 19u, 1u, data, message.endianness);
344 
345  /* Info: Overcurrent charge - MOL */
346  if ((kpkCanShim->pTableMol->cellChargeOvercurrent[stringNumber] == 1u) ||
347  (kpkCanShim->pTableMol->stringChargeOvercurrent[stringNumber] == 1u)) {
348  data = 1u;
349  } else {
350  data = 0u;
351  }
352  CAN_TxSetMessageDataWithSignalData(&messageData, 20u, 1u, data, message.endianness);
353 
354  /* Info: Overcurrent discharge - MOL */
355  if ((kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber] == 1u) ||
356  (kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber] == 1u)) {
357  data = 1u;
358  } else {
359  data = 0u;
360  }
361  CAN_TxSetMessageDataWithSignalData(&messageData, 21u, 1u, data, message.endianness);
362 
363  /* Info: Overvoltage - MOL */
364  data = kpkCanShim->pTableMol->overVoltage[stringNumber];
365  CAN_TxSetMessageDataWithSignalData(&messageData, 22u, 1u, data, message.endianness);
366 
367  /* Info: Undervoltage - MOL */
368  data = kpkCanShim->pTableMol->underVoltage[stringNumber];
369  CAN_TxSetMessageDataWithSignalData(&messageData, 23u, 1u, data, message.endianness);
370 
371  /* Warning: Overtemperature charge - RSL */
372  data = kpkCanShim->pTableRsl->overtemperatureCharge[stringNumber];
373  CAN_TxSetMessageDataWithSignalData(&messageData, 24u, 1u, data, message.endianness);
374 
375  /* Warning: Undertemperature charge - RSL */
376  data = kpkCanShim->pTableRsl->undertemperatureCharge[stringNumber];
377  CAN_TxSetMessageDataWithSignalData(&messageData, 25u, 1u, data, message.endianness);
378 
379  /* Warning: Overtemperature discharge - RSL */
380  data = kpkCanShim->pTableRsl->overtemperatureDischarge[stringNumber];
381  CAN_TxSetMessageDataWithSignalData(&messageData, 26u, 1u, data, message.endianness);
382 
383  /* Warning: Undertemperature discharge - RSL */
384  data = kpkCanShim->pTableRsl->undertemperatureDischarge[stringNumber];
385  CAN_TxSetMessageDataWithSignalData(&messageData, 27u, 1u, data, message.endianness);
386 
387  /* Warning: Overcurrent charge - RSL */
388  if ((kpkCanShim->pTableRsl->cellChargeOvercurrent[stringNumber] == 1u) ||
389  (kpkCanShim->pTableRsl->stringChargeOvercurrent[stringNumber] == 1u)) {
390  data = 1u;
391  } else {
392  data = 0u;
393  }
394  CAN_TxSetMessageDataWithSignalData(&messageData, 28u, 1u, data, message.endianness);
395 
396  /* Warning: Overcurrent discharge - RSL */
397  if ((kpkCanShim->pTableMol->cellDischargeOvercurrent[stringNumber] == 1u) ||
398  (kpkCanShim->pTableMol->stringDischargeOvercurrent[stringNumber] == 1u)) {
399  data = 1u;
400  } else {
401  data = 0u;
402  }
403  CAN_TxSetMessageDataWithSignalData(&messageData, 29u, 1u, data, message.endianness);
404 
405  /* Warning: Overvoltage - RSL */
406  data = kpkCanShim->pTableRsl->overVoltage[stringNumber];
407  CAN_TxSetMessageDataWithSignalData(&messageData, 30u, 1u, data, message.endianness);
408 
409  /* Warning: Undervoltage - RSL */
410  data = kpkCanShim->pTableRsl->underVoltage[stringNumber];
411  CAN_TxSetMessageDataWithSignalData(&messageData, 31u, 1u, data, message.endianness);
412 
413  /* Error: Positive string contactor: TODO */
414  /* Error: Negative string contactor: TODO */
415  /* Error: Slave hardware: TODO */
416 
417  /* Error: Daisy-chain base: communication */
418  data = kpkCanShim->pTableErrorState->spiError[stringNumber];
419  CAN_TxSetMessageDataWithSignalData(&messageData, 35u, 1u, data, message.endianness);
420 
421  /* Error: Daisy-chain redundancy: communication: TODO */
422  /* Error: Daisy-chain base: CRC */
423  data = kpkCanShim->pTableErrorState->crcError[stringNumber];
424  CAN_TxSetMessageDataWithSignalData(&messageData, 37u, 1u, data, message.endianness);
425 
426  /* Error: Daisy-chain redundancy: CRC: TODO */
427  /* Error: Daisy-chain base: Voltage out of operating range */
428  data = kpkCanShim->pTableErrorState->afeCellVoltageError[stringNumber];
429  CAN_TxSetMessageDataWithSignalData(&messageData, 39u, 1u, data, message.endianness);
430 
431  /* Error: Daisy-chain redundancy: Voltage out of operating range: TODO */
432  /* Error: Daisy-chain base: Temperature out of operating range */
433  data = kpkCanShim->pTableErrorState->afeCellTemperatureError[stringNumber];
434  CAN_TxSetMessageDataWithSignalData(&messageData, 41u, 1u, data, message.endianness);
435 
436  /* Error: Daisy-chain redundancy: Voltage out of operating range: TODO */
437 
438  /* Error: current measurement */
439  if ((kpkCanShim->pTableErrorState->currentMeasurementError[stringNumber] == 1u) ||
440  (kpkCanShim->pTableErrorState->currentMeasurementTimeout[stringNumber] == 1u)) {
441  data = 1u;
442  } else {
443  data = 0u;
444  }
445  CAN_TxSetMessageDataWithSignalData(&messageData, 43u, 1u, data, message.endianness);
446 
447  /* Error: Coulomb counting measurement */
448  data = kpkCanShim->pTableErrorState->canTimingCc[stringNumber];
449  CAN_TxSetMessageDataWithSignalData(&messageData, 44u, 1u, data, message.endianness);
450 
451  /* Error: Energy counting measurement */
452  data = kpkCanShim->pTableErrorState->canTimingEc[stringNumber];
453  CAN_TxSetMessageDataWithSignalData(&messageData, 45u, 1u, data, message.endianness);
454 
455  /* Error: Current sensor V1 measurement */
456  data = kpkCanShim->pTableErrorState->currentSensorTimeoutV1[stringNumber];
457  CAN_TxSetMessageDataWithSignalData(&messageData, 46u, 1u, data, message.endianness);
458 
459  /* Error: Current sensor V2 measurement: TODO */
460  /* Error: Current sensor V3 measurement */
461  data = kpkCanShim->pTableErrorState->currentSensorTimeoutV3[stringNumber];
462  CAN_TxSetMessageDataWithSignalData(&messageData, 48u, 1u, data, message.endianness);
463 
464  /* Error: Open wire */
465  data = kpkCanShim->pTableErrorState->open_wire[stringNumber];
466  CAN_TxSetMessageDataWithSignalData(&messageData, 49u, 1u, data, message.endianness);
467 
468  /* Error: Plausibility: Cell temperature */
469  data = kpkCanShim->pTableErrorState->plausibilityCheckCelltemperature[stringNumber];
470  CAN_TxSetMessageDataWithSignalData(&messageData, 51u, 1u, data, message.endianness);
471 
472  /* Error: Plausibility: Cell voltage */
473  data = kpkCanShim->pTableErrorState->plausibilityCheckCellVoltage[stringNumber];
474  CAN_TxSetMessageDataWithSignalData(&messageData, 52u, 1u, data, message.endianness);
475 
476  /* Error: Plausibility: String voltage */
477  data = kpkCanShim->pTableErrorState->plausibilityCheckPackvoltage[stringNumber];
478  CAN_TxSetMessageDataWithSignalData(&messageData, 53u, 1u, data, message.endianness);
479 
480  /* Error: Plausibility: Cell temperature spread */
481  data = kpkCanShim->pTableErrorState->plausibilityCheckCelltemperatureSpread[stringNumber];
482  CAN_TxSetMessageDataWithSignalData(&messageData, 54u, 1u, data, message.endianness);
483 
484  /* Error: Plausibility: Cell voltage spread */
485  data = kpkCanShim->pTableErrorState->plausibilityCheckCellVoltageSpread[stringNumber];
486  CAN_TxSetMessageDataWithSignalData(&messageData, 55u, 1u, data, message.endianness);
487  /* AXIVION Enable Style Generic-NoMagicNumbers: */
488 
489  /* Open wire number: TODO */
490 
491  /* now copy data in the buffer that will be used to send data */
492  CAN_TxSetCanDataWithMessageData(messageData, pCanData, message.endianness);
493 
494  /* Increment multiplexer for next cell */
495  (*pMuxId)++;
496 
497  /* Check mux value */
498  if (*pMuxId >= BS_NR_OF_STRINGS) {
499  *pMuxId = 0u;
500  }
501 
502  return 0;
503 }
504 
505 /*========== Externalized Static Function Implementations (Unit Test) =======*/
506 #ifdef UNITY_UNIT_TEST
507 
508 #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:1619
uint8_t BMS_GetNumberOfConnectedStrings(void)
Returns number of connected strings.
Definition: bms.c:1615
bool BMS_IsStringClosed(uint8_t stringNumber)
Returns string state (closed or open)
Definition: bms.c:1597
BMS_STATEMACH_e BMS_GetState(void)
Returns the current state.
Definition: bms.c:790
bms driver header
CAN callbacks header.
uint32_t CANTX_BmsState(CAN_MESSAGE_PROPERTIES_s message, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for state
static bool CANTX_AnySysMonTimingIssueDetected(const CAN_SHIM_s *const kpkCanShim)
uint32_t CANTX_BmsStateDetails(CAN_MESSAGE_PROPERTIES_s message, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for detail state
uint32_t CANTX_StringState(CAN_MESSAGE_PROPERTIES_s message, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for string state values
#define CAN_FOXBMS_MESSAGES_DEFAULT_DLC
Definition: can_cfg.h:96
Header for the driver for the CAN module.
#define CANTX_STRING_STATE_ID
#define CANTX_BMS_STATE_DETAILS_ID
#define CANTX_BMS_STATE_ID
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:388
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
CAN_ENDIANNESS_e endianness
Definition: can_cfg.h:181
DATA_BLOCK_RSL_FLAG_s * pTableRsl
Definition: can_cfg.h:173
DATA_BLOCK_ERRORSTATE_s * pTableErrorState
Definition: can_cfg.h:170
DATA_BLOCK_MSL_FLAG_s * pTableMsl
Definition: can_cfg.h:172
DATA_BLOCK_MOL_FLAG_s * pTableMol
Definition: can_cfg.h:174
DATA_BLOCK_INSULATION_MONITORING_s * pTableInsulation
Definition: can_cfg.h:171
uint8_t plausibilityCheckCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:368
uint8_t currentMeasurementError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:346
uint8_t plausibilityCheckCelltemperature[BS_NR_OF_STRINGS]
Definition: database_cfg.h:371
uint8_t plausibilityCheckCelltemperatureSpread[BS_NR_OF_STRINGS]
Definition: database_cfg.h:370
uint8_t plausibilityCheckPackvoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:367
uint8_t currentSensorTimeoutV1[BS_NR_OF_STRINGS]
Definition: database_cfg.h:347
uint8_t fuseStateCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:359
uint8_t crcError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:335
uint8_t currentSensorTimeoutV3[BS_NR_OF_STRINGS]
Definition: database_cfg.h:348
uint8_t deepDischargeDetected[BS_NR_OF_STRINGS]
Definition: database_cfg.h:372
uint8_t afeCellTemperatureError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:340
uint8_t canTimingEc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:364
uint8_t open_wire[BS_NR_OF_STRINGS]
Definition: database_cfg.h:360
uint8_t plausibilityCheckCellVoltageSpread[BS_NR_OF_STRINGS]
Definition: database_cfg.h:369
uint8_t currentMeasurementTimeout[BS_NR_OF_STRINGS]
Definition: database_cfg.h:345
uint8_t fuseStateNormal[BS_NR_OF_STRINGS]
Definition: database_cfg.h:358
uint8_t afeCellVoltageError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:339
uint8_t spiError[BS_NR_OF_STRINGS]
Definition: database_cfg.h:337
uint8_t canTimingCc[BS_NR_OF_STRINGS]
Definition: database_cfg.h:363
uint8_t cellChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:489
uint8_t underVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:484
uint8_t cellDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:491
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:486
uint8_t overVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:483
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:485
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:487
uint8_t stringChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:490
uint8_t stringDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:492
uint8_t stringChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:450
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:448
uint8_t cellChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:449
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:445
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:446
uint8_t stringDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:452
uint8_t underVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:444
uint8_t cellDischargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:451
uint8_t overVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:443
uint8_t packDischargeOvercurrent
Definition: database_cfg.h:442
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:447
uint8_t underVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:464
uint8_t undertemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:468
uint8_t stringChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:470
uint8_t overVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:463
uint8_t cellChargeOvercurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:469
uint8_t undertemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:467
uint8_t overtemperatureDischarge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:466
uint8_t overtemperatureCharge[BS_NR_OF_STRINGS]
Definition: database_cfg.h:465
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