foxBMS - Unit Tests  1.4.0
The foxBMS Unit Tests API Documentation
test_can.c File Reference

Tests for the CAN driver. More...

#include "unity.h"
#include "MockHL_can.h"
#include "Mockcan_cfg.h"
#include "Mockdatabase.h"
#include "Mockdiag.h"
#include "Mockfoxmath.h"
#include "Mockftask.h"
#include "Mockimd.h"
#include "Mockio.h"
#include "Mockmcu.h"
#include "Mockos.h"
#include "Mockpex.h"
#include "Mockqueue.h"
#include "Mocktest_can_mpu_prototype_queue_create_stub.h"
#include "version_cfg.h"
#include "can.h"
#include "test_assert_helper.h"
Include dependency graph for test_can.c:

Go to the source code of this file.

Functions

static uint32_t can_dummy (uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s const *kpkCanShim)
 
void setUp (void)
 
void tearDown (void)
 
void testDataSendNullPointerAsNode (void)
 
void testDataSendNullPointerAsData (void)
 
void testDataSendNoMessagePending (void)
 
void testDataSendMessagePending (void)
 
void testEnablePeriodic (void)
 
void testIsCurrentSensorPresent (void)
 
void testIsCurrentSensorCcPresent (void)
 
void testCAN_TransmitBootMessage (void)
 
void testCAN_TransmitDieId (void)
 test CAN_TransmitDieId() More...
 

Variables

const VER_VERSION_s ver_foxbmsVersionInformation
 
static DATA_BLOCK_CELL_VOLTAGE_s can_tableCellVoltages = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE}
 
static DATA_BLOCK_CELL_TEMPERATURE_s can_tableTemperatures = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE}
 
static DATA_BLOCK_MIN_MAX_s can_tableMinimumMaximumValues = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX}
 
static DATA_BLOCK_CURRENT_SENSOR_s can_tableCurrentSensor = {.header.uniqueId = DATA_BLOCK_ID_CURRENT_SENSOR}
 
static DATA_BLOCK_OPEN_WIRE_s can_tableOpenWire = {.header.uniqueId = DATA_BLOCK_ID_OPEN_WIRE_BASE}
 
static DATA_BLOCK_STATEREQUEST_s can_tableStateRequest = {.header.uniqueId = DATA_BLOCK_ID_STATEREQUEST}
 
QueueHandle_t imd_canDataQueue = NULL_PTR
 
const CAN_SHIM_s can_kShim
 
const CAN_MSG_TX_TYPE_s can_txMessages []
 
const CAN_MSG_RX_TYPE_s can_rxMessages []
 
const uint8_t can_txLength = sizeof(can_txMessages) / sizeof(can_txMessages[0])
 
const uint8_t can_rxLength = sizeof(can_rxMessages) / sizeof(can_rxMessages[0])
 
CAN_STATE_scanTestState = NULL_PTR
 
QueueHandle_t ftsk_dataQueue = NULL_PTR
 
QueueHandle_t ftsk_imdCanDataQueue = NULL_PTR
 
QueueHandle_t ftsk_canRxQueue = NULL_PTR
 
volatile bool ftsk_allQueuesCreated = false
 

Detailed Description

Tests for the CAN driver.

SPDX-License-Identifier: BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

We kindly request you to use one or more of the following phrases to refer to foxBMS in your hardware, software, documentation or advertising materials:

  • ″This product uses parts of foxBMS®″
  • ″This product includes parts of foxBMS®″
  • ″This product is derived from foxBMS®″
Author
foxBMS Team
Date
2020-04-01 (date of creation)
Updated
2022-07-28 (date of last update)
Version
v1.4.0
Prefix
TEST

Definition in file test_can.c.

Function Documentation

◆ can_dummy()

static uint32_t can_dummy ( uint32_t  id,
uint8_t  dlc,
CAN_ENDIANNESS_e  endianness,
uint8_t *  pCanData,
uint8_t *  pMuxId,
const CAN_SHIM_s const *  kpkCanShim 
)
static

Definition at line 108 of file test_can.c.

◆ setUp()

void setUp ( void  )

Definition at line 137 of file test_can.c.

Here is the call graph for this function:

◆ tearDown()

void tearDown ( void  )

Definition at line 148 of file test_can.c.

◆ testCAN_TransmitBootMessage()

void testCAN_TransmitBootMessage ( void  )

Definition at line 240 of file test_can.c.

◆ testCAN_TransmitDieId()

void testCAN_TransmitDieId ( void  )

test CAN_TransmitDieId()

Currently not implemented. Implementing a test for this function would require implementing a harness that mocks away the systemREG1 (defined in HAL) as otherwise the test would attempt to read random memory addresses. Since the benefit of testing this function on unit level is rather low (next to no interaction with rest of code base), it should be tested in the integration test.

Definition at line 254 of file test_can.c.

◆ testDataSendMessagePending()

void testDataSendMessagePending ( void  )

Definition at line 179 of file test_can.c.

Here is the call graph for this function:

◆ testDataSendNoMessagePending()

void testDataSendNoMessagePending ( void  )

Definition at line 168 of file test_can.c.

Here is the call graph for this function:

◆ testDataSendNullPointerAsData()

void testDataSendNullPointerAsData ( void  )

Definition at line 160 of file test_can.c.

Here is the call graph for this function:

◆ testDataSendNullPointerAsNode()

void testDataSendNullPointerAsNode ( void  )

Definition at line 152 of file test_can.c.

Here is the call graph for this function:

◆ testEnablePeriodic()

void testEnablePeriodic ( void  )

Definition at line 200 of file test_can.c.

Here is the call graph for this function:

◆ testIsCurrentSensorCcPresent()

void testIsCurrentSensorCcPresent ( void  )

Definition at line 226 of file test_can.c.

Here is the call graph for this function:

◆ testIsCurrentSensorPresent()

void testIsCurrentSensorPresent ( void  )

Definition at line 211 of file test_can.c.

Here is the call graph for this function:

Variable Documentation

◆ can_kShim

const CAN_SHIM_s can_kShim
Initial value:
= {
.pQueueImd = &imd_canDataQueue,
.pTableCellVoltage = &can_tableCellVoltages,
.pTableCellTemperature = &can_tableTemperatures,
.pTableCurrentSensor = &can_tableCurrentSensor,
.pTableOpenWire = &can_tableOpenWire,
.pTableStateRequest = &can_tableStateRequest,
}
static DATA_BLOCK_CELL_VOLTAGE_s can_tableCellVoltages
Definition: test_can.c:89
static DATA_BLOCK_MIN_MAX_s can_tableMinimumMaximumValues
Definition: test_can.c:91
static DATA_BLOCK_OPEN_WIRE_s can_tableOpenWire
Definition: test_can.c:93
static DATA_BLOCK_CELL_TEMPERATURE_s can_tableTemperatures
Definition: test_can.c:90
QueueHandle_t imd_canDataQueue
Definition: test_can.c:96
static DATA_BLOCK_STATEREQUEST_s can_tableStateRequest
Definition: test_can.c:94
static DATA_BLOCK_CURRENT_SENSOR_s can_tableCurrentSensor
Definition: test_can.c:92

variable for storing and passing on the local database table handles

Definition at line 98 of file test_can.c.

◆ can_rxLength

const uint8_t can_rxLength = sizeof(can_rxMessages) / sizeof(can_rxMessages[0])

Definition at line 127 of file test_can.c.

◆ can_rxMessages

const CAN_MSG_RX_TYPE_s can_rxMessages[]
Initial value:
= {
}
@ CAN_LITTLE_ENDIAN
Definition: can_cfg.h:299
#define CAN1_NODE
Definition: can_cfg.h:71
static uint32_t can_dummy(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s const *kpkCanShim)
Definition: test_can.c:108

registry of CAN RX messages

Definition at line 122 of file test_can.c.

◆ can_tableCellVoltages

DATA_BLOCK_CELL_VOLTAGE_s can_tableCellVoltages = {.header.uniqueId = DATA_BLOCK_ID_CELL_VOLTAGE}
static

Definition at line 89 of file test_can.c.

◆ can_tableCurrentSensor

DATA_BLOCK_CURRENT_SENSOR_s can_tableCurrentSensor = {.header.uniqueId = DATA_BLOCK_ID_CURRENT_SENSOR}
static

Definition at line 92 of file test_can.c.

◆ can_tableMinimumMaximumValues

DATA_BLOCK_MIN_MAX_s can_tableMinimumMaximumValues = {.header.uniqueId = DATA_BLOCK_ID_MIN_MAX}
static

Definition at line 91 of file test_can.c.

◆ can_tableOpenWire

DATA_BLOCK_OPEN_WIRE_s can_tableOpenWire = {.header.uniqueId = DATA_BLOCK_ID_OPEN_WIRE_BASE}
static

Definition at line 93 of file test_can.c.

◆ can_tableStateRequest

DATA_BLOCK_STATEREQUEST_s can_tableStateRequest = {.header.uniqueId = DATA_BLOCK_ID_STATEREQUEST}
static

Definition at line 94 of file test_can.c.

◆ can_tableTemperatures

DATA_BLOCK_CELL_TEMPERATURE_s can_tableTemperatures = {.header.uniqueId = DATA_BLOCK_ID_CELL_TEMPERATURE}
static

Definition at line 90 of file test_can.c.

◆ can_txLength

const uint8_t can_txLength = sizeof(can_txMessages) / sizeof(can_txMessages[0])

array length for transmission CAN0 message definition

length of CAN message arrays

Definition at line 126 of file test_can.c.

◆ can_txMessages

const CAN_MSG_TX_TYPE_s can_txMessages[]
Initial value:
= {
{CAN1_NODE, 0x001, 8, 100, 0, CAN_LITTLE_ENDIAN, &can_dummy, NULL_PTR},
}
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76

registry of CAN TX messages

Definition at line 118 of file test_can.c.

◆ canTestState

CAN_STATE_s* canTestState = NULL_PTR

Definition at line 129 of file test_can.c.

◆ ftsk_allQueuesCreated

volatile bool ftsk_allQueuesCreated = false

indicator whether the queues have successfully been initialized to be used in other parts of the software

Definition at line 134 of file test_can.c.

◆ ftsk_canRxQueue

QueueHandle_t ftsk_canRxQueue = NULL_PTR

handle of the can driver data queue

Definition at line 133 of file test_can.c.

◆ ftsk_dataQueue

QueueHandle_t ftsk_dataQueue = NULL_PTR

Definition at line 131 of file test_can.c.

◆ ftsk_imdCanDataQueue

QueueHandle_t ftsk_imdCanDataQueue = NULL_PTR

handle of the imd can data queue

Definition at line 132 of file test_can.c.

◆ imd_canDataQueue

QueueHandle_t imd_canDataQueue = NULL_PTR

Definition at line 96 of file test_can.c.

◆ ver_foxbmsVersionInformation

const VER_VERSION_s ver_foxbmsVersionInformation
Initial value:
= {
.underVersionControl = true,
.isDirty = true,
.major = 1,
.minor = 1,
.patch = 1,
.distanceFromLastRelease = 42,
.commitHash = "deadbeef",
.gitRemote = "onTheDarkSideOfTheMoon.git",
}

version information of the system

Definition at line 78 of file test_can.c.