Skip to content

Commit c8094e7

Browse files
committed
Add 1 to available() if peek has been previously called
Fixes #405; a proper fix require to use another RingBuffer (useless since the USB data is already internally buffered)
1 parent 154166d commit c8094e7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cores/arduino/USB/CDC.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,11 @@ void Serial_::end(void)
199199
memset((void*)&_usbLineInfo, 0, sizeof(_usbLineInfo));
200200
}
201201

202+
int _serialPeek = -1;
203+
202204
int Serial_::available(void)
203205
{
204-
return usb.available(CDC_ENDPOINT_OUT);
206+
return usb.available(CDC_ENDPOINT_OUT) + (_serialPeek != -1);
205207
}
206208

207209
int Serial_::availableForWrite(void)
@@ -211,8 +213,6 @@ int Serial_::availableForWrite(void)
211213
return (EPX_SIZE - 1);
212214
}
213215

214-
int _serialPeek = -1;
215-
216216
int Serial_::peek(void)
217217
{
218218
if (_serialPeek != -1)

0 commit comments

Comments
 (0)