Arduino Zero SerialUSB.available

Hello guys,

there is a problem with SerialUSB.available() if using Arduino Zero board.
If sending multiple bytes to Zero, this method returns only 0 or 1, but should return total number of bytes stored in buffer. All received bytes are available to read with Serial.read(), Serial.readBytes(), etc.

Tested it on Eclipse with Zero and Due. Problem only occurs on Zero and only if using SerialUSB.

Test sketch

#include <Arduino.h>

void setup()
{
	SerialUSB.begin(115200);
	while(!SerialUSB);
}

void loop()
{
	int availableBytes = SerialUSB.available();
	SerialUSB.println(availableBytes, DEC);
	delay(1000);
}

Can anyone confirm this?

*edit
Problem also occurs sometimes in Arduino IDE. It seems there is a problem with receive buffer counter…
For example (Arduino IDE): I send 4 bytes. In terminal output switch from 0 to 4. Now i send another 4 bytes but terminal output still show 4.
So if available() only returns a 1 it just had received one byte and ignore another received bytes.

This is a bug of Arduino Core for SAMD. See