if i can suggest, a peek() fonction to the usb code that returns what's in the buffer without removing it could be useful.
in the meantime, here's a readline function. it's crude but damn useful for debugging. maybe it will save someone digging in libmaple :)
// todo: make a non-blocking version
#include <usb_callbacks.h>
// wait and block for a complete line
uint32 readline(void* buf, uint32 len) {
uint8 avail=SerialUSB.available();
uint8 i;
if (len > avail) {
len= avail;
}
SerialUSB.println(len);
if (avail) {
for (i=0;i<len;i++) {
if (vcomBufferRx[(recvBufOut+i)% VCOM_RX_EPSIZE] == 13) {
return SerialUSB.read(buf,i+1);
}
}
}
}