stimmer:
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.
Sorry to revive an old topic, but,
How do you achieve that speed? (4.3MB's) ?
I dont have linux to test your sending-code but i have one made on VB.NET which is fairly simple, made a USB packet of 100KB and receive on the arduino, it takes 700ms to do so, which matches this tests:
http://dangerousprototypes.com/2013/06/03/usb-virtual-serial-benchmarks/
That say that the arduino serialUSB speed is around 110/130kbs and it matches my speed.
My receiving code is:
void setup() {
// put your setup code here, to run once:
SerialUSB.begin(1200000);
delay(2000);
//Wait for start-mark packet
while (SerialUSB.available() < 1){}
unsigned long ChronoOne = micros();
int readed = 0;
int total_bytes = 100000;
while (readed < total_bytes)
{
while (SerialUSB.available() > 1){SerialUSB.read();readed = readed + 1;}
}
ChronoOne = micros() - ChronoOne;
SerialUSB.println("T:" + String(ChronoOne)); //Total bytes received
SerialUSB.println("R:" + String(readed)); //Time it took
delay(50000);
}
void loop() {
// put your main code here, to run repeatedly:
}
Sending code on VB.NET
Dim dt1970 = DateTime.Now
Dim bArraySend2(1) As Byte
bArraySend2(0) = 1
SerialPort1.Write(bArraySend2, 0, bArraySend2.Length) 'Start Packet
Dim bArraySend(100012) As Byte
bArraySend(0) = 255
bArraySend(1) = 47
SerialPort1.Write(bArraySend, 0, bArraySend.Length)
Dim now = DateTime.Now
MsgBox("done:" & (now - dt1970).TotalMilliseconds.ToString())
I cant get any faster than this, any ideas? Using 1.5.2