Skip to content

Commit

Permalink
[test] Improve fdcan test on STM32
Browse files Browse the repository at this point in the history
  • Loading branch information
rleh committed May 9, 2023
1 parent 78a9435 commit 7bede35
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions test/modm/platform/fdcan/fdcan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ FdcanTest::testBuffers()
modm::can::ExtendedIdentifier(0),
modm::can::ExtendedMask(0));

// send (RxBufferSize + 2) messages, exceeds internal peripheral queue size (3
// msgs) as well as the software queue size, but not both added together. So
// no message should get lost.
const uint_fast16_t numberOfMsgs = Fdcan1::RxBufferSize + 2;

modm::can::Message message{0x4711, 0};
// send 8 messages, exceeds internal peripheral queue size
for (uint_fast8_t i = 0; i <= 8; ++i) {
message.setLength(i);
for (uint_fast16_t i = 0; i <= numberOfMsgs; ++i) {
message.setLength(i % 8);
for (uint_fast8_t dataIndex = 0; dataIndex < i; ++dataIndex) {
message.data[dataIndex] = i;
}
Expand All @@ -93,11 +97,11 @@ FdcanTest::testBuffers()

// try to receive same messages
modm::can::Message receivedMessage;
for (uint_fast8_t i = 0; i <= 8; ++i) {
for (uint_fast16_t i = 0; i <= numberOfMsgs; ++i) {
TEST_ASSERT_TRUE(Fdcan1::getMessage(receivedMessage));

TEST_ASSERT_EQUALS(receivedMessage.getIdentifier(), 0x4711u);
TEST_ASSERT_EQUALS(receivedMessage.getLength(), i);
TEST_ASSERT_EQUALS(receivedMessage.getLength(), (i % 8));

for (uint_fast8_t dataIndex = 0; dataIndex < i; ++dataIndex) {
TEST_ASSERT_EQUALS(receivedMessage.data[dataIndex], i);
Expand Down

0 comments on commit 7bede35

Please sign in to comment.