Skip to content

Commit e4f7bf5

Browse files
sandeepmistrycmaglie
authored andcommitted
Add private availableForStore method, and use in Serial_::accept
1 parent cea1d20 commit e4f7bf5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cores/arduino/USB/CDC.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,17 @@ bool Serial_::rts() {
351351
return _usbLineInfo.lineState & 0x2;
352352
}
353353

354+
int Serial_::availableForStore(void) {
355+
ring_buffer *buffer = &cdc_rx_buffer;
356+
357+
if (buffer->full)
358+
return 0;
359+
else if (buffer->head >= buffer->tail)
360+
return CDC_SERIAL_BUFFER_SIZE - 1 - buffer->head + buffer->tail;
361+
else
362+
return buffer->tail - buffer->head - 1;
363+
}
364+
354365
Serial_ SerialUSB(USBDevice);
355366

356367
#endif

cores/arduino/USB/USBAPI.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class Serial_ : public Stream
168168
};
169169

170170
private:
171+
int availableForStore(void);
172+
171173
USBDeviceClass &usb;
172174
RingBuffer *_cdc_rx_buffer;
173175
};

0 commit comments

Comments
 (0)