Fasten your seatbelts 8)
I have been trying to debug and simplify the code, and also add in multi-byte reads. The (modified) loopback test now runs at 4.3 MB/s (that's about 45 million baud). My 888888888-byte test passes through in about 3 min 30 sec. I also added in some code to control the LEDs. I did this by removing the troublesome ringbuffer code and using UDD_ calls directly (My reasoning was, since there is 2 banks of USB fifo for buffering, why do we need more?)
I do seem to be getting occasional errors but only about once every several gigabytes, which makes it hard to debug as I don't know if it's a problem with the code or the cable or with the way I am testing it. Testing so far indicates it is a problem with transmission (SerialUSB.write())
The new loopback test with multi-byte read looks like this:
void setup() {
Serial.begin(115200);
SerialUSB.begin(0);
}
int s=0;
int t=0;
void loop() {
int l;
byte b[2048]; // 512 might be enough
if(l=SerialUSB.available()){
l=SerialUSB.read(b,l);
SerialUSB.write(b,l);
s+=l;
}
if((millis()-t) > 1000){t=millis();Serial.println(s);}
}
I've attached the three changed USB files as there are many changes.
The way I am testing on linux is as follows:
seq 99999999 >o1
stty -F /dev/ttyACM1 sane raw -iexten -echo -echoe -echok -echoctl -echoke -onlcr min 1
time cat o1 >/dev/ttyACM1 & cat /dev/ttyACM1 >o2
# ctrl-c when it is finished
cmp o1 o2
I've also tested with gtkterm (which has been 100% reliable)
Please test thoroughly! I am especially interested to see if removing the ringbuffer causes performance degradation in any situation - I haven't found anything yet which runs slower despite having less buffering. Also I am unable to test on Windows or Mac.
CDC.cpp (7.83 KB)
USBAPI.h (6.99 KB)
USBCore.cpp (22.7 KB)