user37545: On Arduino forums, there's a post where someone improved the USB communication and made it super-fast. I don't understand how he did this, and I'm trying to recreate this, but failing.
My test code
I made a simple program on Python for testing; here it's:
import serial
import sys
import datetime

ser = serial.Serial(
   port = 'COM9',
   baudrate = 26*115200, #biggest number acceptable by python
   parity = serial.PARITY_NONE,
   stopbits = serial.STOPBITS_ONE,
   bytesize = serial.EIGHTBITS
)

if ser.isOpen() == False :
   ser.open()
   if ser.isOpen() == False :
      print("Can't open serial port")
      sys.exit(1)    

start = datetime.datetime.now()
s = b'abc'*10000    
ser.write(s)    
total_len = len(s)    
end = datetime.datetime.now()    
speed = total_len/(end - start).total_seconds()/1e6    
print("Speed: " + str(speed) + " MB/s")

And I made a simple Arduino program to read:
char buf[500];

void setup() {
  Serial.begin(250000);    
}

void loop() {
  if (Serial.available() > 0) {
     Serial.readBytes(buf, 500);
  }
}

With this, my best result was 0.2 MB/s with my Arduino mega. However, on that post, they reached 12 Mbit/s = 1.5 MB/s!!!!! This is insane!
Atemmpting to achieve their result:
Apparently Arduino libraries are different than before, so just taking their code and putting it in my arduino\avr\cores\arduino directory doesn't work. So I started trying to edit the code myself. I'm a C++ dev, so supposedly this should be doable... but...
The problem I faced
So eventually, the problem I faced was that there are two Serial communication modes (apparently) UART and CDC. The code from the forum uses CDC, while my Arduino IDE uses UART. I tried enabling CDC using:
#define USBCON

but this lead to the error:
error: #error "Targets with both UART0 and CDC serial not supported"

At this point I don't know how to continue, as I'm not a hardware expert. But I'd like your opinion on this whole thing:

Is it possible to get these speeds? How?
If it's, why is it not in the default Arduino library?
In case there's no easy answer for the other questions, is switching from UART to CDC easy, so that I could continue my testing?


user4143: 
Is it possible to get these speeds? How?

Not without a 32-bit Arduino with a USB interface.

If it's, why is it not in the default Arduino library?

Because you can't use it on an 8-bit Arduino without a USB interface.

In case there's no easy answer for the other questions, is switching from UART to CDC easy, so that I could continue my testing?

Yes, get a 32-bit Arduino with a USB interface such as the Arduino Due that the poster of that thread used.

37545: <p>On Arduino forums, <a href="https://forum.arduino.cc/index.php?topic=391757.15" rel="nofollow noreferrer">there's a post</a> where someone improved the USB communication and made it super-fast. I don't understand how he did this, and I'm trying to recreate this, but failing.</p>
<h2>My test code</h2>
<p>I made a simple program on Python for testing; here it's:</p>
<pre><code>import serial
import sys
import datetime

ser = serial.Serial(
   port = 'COM9',
   baudrate = 26*115200, #biggest number acceptable by python
   parity = serial.PARITY_NONE,
   stopbits = serial.STOPBITS_ONE,
   bytesize = serial.EIGHTBITS
)

if ser.isOpen() == False :
   ser.open()
   if ser.isOpen() == False :
      print(&quot;Can't open serial port&quot;)
      sys.exit(1)    

start = datetime.datetime.now()
s = b'abc'*10000    
ser.write(s)    
total_len = len(s)    
end = datetime.datetime.now()    
speed = total_len/(end - start).total_seconds()/1e6    
print(&quot;Speed: &quot; + str(speed) + &quot; MB/s&quot;)
</code></pre>
<p>And I made a simple Arduino program to read:</p>
<pre><code>char buf[500];

void setup() {
  Serial.begin(250000);    
}

void loop() {
  if (Serial.available() &gt; 0) {
     Serial.readBytes(buf, 500);
  }
}
</code></pre>
<p>With this, my best result was <code>0.2 MB/s</code> with my Arduino mega. However, on <a href="https://forum.arduino.cc/index.php?topic=391757.15" rel="nofollow noreferrer">that post</a>, they reached 12 Mbit/s = 1.5 MB/s!!!!! This is insane!</p>
<h2>Atemmpting to achieve their result:</h2>
<p>Apparently Arduino libraries are different than before, so just taking their code and putting it in my <code>arduino\avr\cores\arduino</code> directory doesn't work. So I started trying to edit the code myself. I'm a C++ dev, so supposedly this should be doable... but...</p>
<h2>The problem I faced</h2>
<p>So eventually, the problem I faced was that there are two Serial communication modes (apparently) UART and CDC. The code from the forum uses CDC, while my Arduino IDE uses UART. I tried enabling CDC using:</p>
<pre><code>#define USBCON
</code></pre>
<p>but this lead to the error:</p>
<pre><code>error: #error &quot;Targets with both UART0 and CDC serial not supported&quot;
</code></pre>
<p>At this point I don't know how to continue, as I'm not a hardware expert. But I'd like your opinion on this whole thing:</p>
<ol>
<li>Is it possible to get these speeds? How?</li>
<li>If it's, why is it not in the default Arduino library?</li>
<li>In case there's no easy answer for the other questions, is switching from UART to CDC easy, so that I could continue my testing?</li>
</ol>
 4143: <blockquote>
  <p>Is it possible to get these speeds? How?</p>
</blockquote>

<p>Not without a 32-bit Arduino with a USB interface.</p>

<blockquote>
  <p>If it's, why is it not in the default Arduino library?</p>
</blockquote>

<p>Because you can't use it on an 8-bit Arduino without a USB interface.</p>

<blockquote>
  <p>In case there's no easy answer for the other questions, is switching from UART to CDC easy, so that I could continue my testing?</p>
</blockquote>

<p>Yes, get a 32-bit Arduino with a USB interface such as the Arduino Due that the poster of that thread used.</p>
