Skip to content

Commit 4f1b0d7

Browse files
committed
Add Serial_::availableForWrite
1 parent 3254c67 commit 4f1b0d7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cores/arduino/USB/CDC.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ int Serial_::available(void)
214214
return (unsigned int)(CDC_SERIAL_BUFFER_SIZE + buffer->head - buffer->tail) % CDC_SERIAL_BUFFER_SIZE;
215215
}
216216

217+
int Serial_::availableForWrite(void)
218+
{
219+
// return the number of bytes left in the current bank,
220+
// always EP size - 1, because bank is flushed on every write
221+
return (EPX_SIZE - 1);
222+
}
223+
217224
int Serial_::peek(void)
218225
{
219226
ring_buffer *buffer = &cdc_rx_buffer;

cores/arduino/USB/USBAPI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Serial_ : public Stream
5454
void end(void);
5555

5656
virtual int available(void);
57+
virtual int availableForWrite(void);
5758
virtual void accept(void);
5859
virtual int peek(void);
5960
virtual int read(void);

0 commit comments

Comments
 (0)