diff --git a/cores/arduino/USB/CDC.cpp b/cores/arduino/USB/CDC.cpp
index 9c38debb6c7d6de6cebcc74c0dae12a167e71ad8..adb3ab075b055a5a67933152062a8113aca10744 100644
--- a/cores/arduino/USB/CDC.cpp
+++ b/cores/arduino/USB/CDC.cpp
@@ -351,6 +351,17 @@ bool Serial_::rts() {
 	return _usbLineInfo.lineState & 0x2;
 }
 
+int Serial_::availableForStore(void) {
+	ring_buffer *buffer = &cdc_rx_buffer;
+
+	if (buffer->full)
+		return 0;
+	else if (buffer->head >= buffer->tail)
+		return CDC_SERIAL_BUFFER_SIZE - 1 - buffer->head + buffer->tail;
+	else
+		return buffer->tail - buffer->head  - 1;
+}
+
 Serial_ SerialUSB(USBDevice);
 
 #endif
diff --git a/cores/arduino/USB/USBAPI.h b/cores/arduino/USB/USBAPI.h
index 716edbfd529900c8d390f7e07bf9b31068a86f04..8573248d9c25c0386b877b2ef84179726e3422b6 100644
--- a/cores/arduino/USB/USBAPI.h
+++ b/cores/arduino/USB/USBAPI.h
@@ -168,6 +168,8 @@ public:
 	};
 
 private:
+	int availableForStore(void);
+
 	USBDeviceClass &usb;
 	RingBuffer *_cdc_rx_buffer;
 };