File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff 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+
170185int CANControllerClass::peek ()
171186{
172187 if (!available ()) {
Original file line number Diff line number Diff 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
4750protected:
4851 CANControllerClass ();
You can’t perform that action at this time.
0 commit comments