Skip to content

Commit d66bc11

Browse files
committed
Added changes
1 parent 382fff7 commit d66bc11

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/CANController.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,21 @@ int CANControllerClass::read()
167167
return _rxData[_rxIndex++];
168168
}
169169

170+
171+
size_t CANControllerClass::readBytes(char *buffer, size_t length) {
172+
int bytesAvailable = available();
173+
if (bytesAvailable <= 0) {
174+
return 0;
175+
}
176+
if (bytesAvailable < length) {
177+
length = bytesAvailable;
178+
}
179+
memcpy(buffer, _rxData, length);
180+
_rxIndex += length;
181+
return length;
182+
}
183+
184+
170185
int CANControllerClass::peek()
171186
{
172187
if (!available()) {

src/CANController.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class CANControllerClass : public Stream {
4343
virtual int loopback();
4444
virtual int sleep();
4545
virtual int wakeup();
46+
47+
// Returing the recieve buffer improves data access speed
48+
uint8_t * getRxBuf() { return _rxData; }
4649

4750
protected:
4851
CANControllerClass();

0 commit comments

Comments
 (0)