I'm working on a python conduit over USB and am running up against a weird speed limit. I'm exchanging 32 byte messages with the Arduino from my PC and am getting around 245 transactions/sec. However, with a baud rate set at 2000000, I expect it to be far faster.
I'm looking for suggestions where to look for speedup. The python code is pretty lean, and I've tried just sending hardcoded bytes (avoiding buffers and packets, etc) both ways with similar round trip times.
Is there a speed limit in the FTDI chips? Am I not really going at 2Mbaud?
The screencap is of a Jupyter notebook accessing the Arduino. Here it is in text:
In [1]: import os, time, serial
from pwnduino import Pwnduino, INPUT, OUTPUT, HIGH, LOW, list_arduino_ports, com_grep
ARDUINO_PORT = list_arduino_ports()[0] # find first arduino port, crash if none
In [2]: duino = Pwnduino(port=ARDUINO_PORT)
assert duino.is_open
opened Arduino Mega 2560 on port COM13
In [3]: time.ctime(duino.time)
Out[3]: 'Wed Dec 31 19:00:00 1969'
In [4]: duino.time = time.time()
In [5]: time.ctime(duino.time)
Out[5]: 'Sat Nov 17 11:47:20 2018'
In [6]: t0 = time.time()
for i in range(1000):
x = duino.digitalRead(13)
t = time.time() - t0
In [7]: print(1000/t)
241.7502510124071
In [8]: duino.close()
send thread killed
receive thread killed
closed Arduino Mega 2560 on port COM13...
In [9]: duino = Pwnduino(port=ARDUINO_PORT)
assert duino.is_open
opened Arduino Mega 2560 on port COM13