Skip to content

Commit 97e9c26

Browse files
committed
Add Serial_::availableForWrite
1 parent 2df644e commit 97e9c26

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

cores/arduino/USB/CDC.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ int Serial_::available(void)
202202
return (uint32_t)(CDC_SERIAL_BUFFER_SIZE + buffer->head - buffer->tail) % CDC_SERIAL_BUFFER_SIZE;
203203
}
204204

205+
int Serial_::availableForWrite(void)
206+
{
207+
// return the number of bytes left in the current bank,
208+
// always EP size - 1, because bank is flushed on every write
209+
return (EPX_SIZE - 1);
210+
}
211+
205212
int Serial_::peek(void)
206213
{
207214
ring_buffer *buffer = &cdc_rx_buffer;

cores/arduino/USB/USBAPI.h

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class Serial_ : public Stream
118118
void end(void);
119119

120120
virtual int available(void);
121+
virtual int availableForWrite(void);
121122
virtual void accept(void);
122123
virtual int peek(void);
123124
virtual int read(void);

0 commit comments

Comments
 (0)