can_isotp fix? (#3678)

Co-authored-by: Andrei <andreikagit@users.noreply.github.com>
This commit is contained in:
Andreika 2021-12-09 01:12:51 +02:00 committed by GitHub
parent 5f997f9769
commit 6be915f7af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -141,8 +141,8 @@ int CanStreamerState::receiveFrame(CANRxFrame *rxmsg, uint8_t *buf, int num, can
memcpy(buf, srcBuf, numBytesToCopy);
}
srcBuf += numBytesToCopy;
waitingForNumBytes -= numBytesAvailable;
numBytesAvailable -= numBytesToCopy;
waitingForNumBytes -= numBytesToCopy;
// if there are some more bytes left, we save them for the next time
for (int i = 0; i < numBytesAvailable; i++) {
rxFifoBuf.put(srcBuf[i]);

View File

@ -110,13 +110,15 @@ public:
for (size_t i = 0; i < totalSize; i++) {
EXPECT_EQ(totalData[i], totalReceivedData[i]) << "Rcv. byte #" << i << " differs!";
}
// check the FIFO buf size
EXPECT_EQ(0, rxFifoBuf.getCount());
}
protected:
TestCanStreamer streamer;
};
TEST(testCanSerial, test1Frame) {
{
@ -146,6 +148,10 @@ TEST(testCanSerial, test2Frames) {
TestCanStreamerState state;
state.test({ "01234567" }, { "\x10"s "\x08"s "012345"s, "\x21"s "67\0\0\0\0\0"s }, 8, { 8 }); // 8 bytes -> 2 8-byte frames, 8 bytes in FIFO
}
{
TestCanStreamerState state;
state.test({ "0123456789A" }, { "\x10"s "\x0B"s "012345"s, "\x21"s "6789A\0\0"s }, 11, { 2, 5, 4 }); // 11 bytes -> 2 8-byte frames
}
/*
{
TestCanStreamerState state;