Skip to content

Commit

Permalink
Test: CAN unit test pingpong v2, add more assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
LinjingZhang committed Oct 22, 2024
1 parent 064cb6c commit ba05ce7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ void processReceivedMessagesNode2()
{
if (newDataReceivedNode2) {
// Process the received data
canDataLength = CAN.packetDlc();
for (uint8_t i = 0; i < canDataLength; ++i) {
node2Data[i] = receivedData[i] + node2Increment;
}

// Send processed data back to Node1
CAN.beginPacket(CAN_ID_2);
TEST_ASSERT_TRUE(CAN.beginPacket(CAN_ID_2));
for (uint8_t i = 0; i < canDataLength; ++i) {
CAN.write(node2Data[i]);
TEST_ASSERT_EQUAL(1, CAN.write(node2Data[i]));
}
CAN.endPacket();
TEST_ASSERT_EQUAL(1, CAN.endPacket());

// Clear flag
newDataReceivedNode2 = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ extern CANXMC CAN;
void receiveEventNode2(int packetSize)
{
uint8_t count = 0;
while (CAN.available() && count < 8) {
while (CAN.available()) {
receivedData[count++] = CAN.read();
}
newDataReceivedNode2 = true;
canDataLength = packetSize;
}

// Method invoked before a test suite is run.
Expand Down

0 comments on commit ba05ce7

Please sign in to comment.