How to use SerialUSB.read ()

I couldn't find any example on how to use SerialUSB.read().

This is what I tested, but it doesn't work so I must have done something wrong:

void setup()
{
Serial.begin(9600);//programming port
SerialUSB.begin(9600);//native port

while (!SerialUSB)
{
Serial.println("waiting on usb native connection");
delay(2000);
}
Serial.println("USB native connection established \n");

}//end setup()

void loop()
{
if(SerialUSB.available())
{
char rc = SerialUSB.read();// read a character
Serial.println("character received \n");
}

}//end loop()

Which Arduino board are you using ?

It is the Arduino-Due. My native USB port is connected to a Ubuntu PC. At the Ubuntu side I checked that the USB is making a connection with the Arduino.

In the meanwhile, I disconnected the Arduino from the Ubuntu PC and hooked it up to a Windows PC. After removing the while(!SerialUSB), it works fine, when I echo a string from the Windows PC. So the while() in the setup was apparently not a good idea..

However, it still does not work when connected to the Ubuntu PC, although the dmesg | grep tty command clearly shows that a ttyACM0 comes up when connected. But echoing a string to rryACM0 is not received by the Arduino.
The lsusb command shows nevertheless that the Arduino is connected:

Bus 001 Device 003: ID 2341:003e Arduino SA Arduino Due