Hi all,
I want to sent data from Teensy 4.0 via serial (USB) to PC and read data by Pyrhon. I have code below but it is very slow. Any idea how to send for exmple 30000 float values and read in Python in 1 second? Now 30000 float values take about 6 seconds.
Many thanks
Michal
Teensy:
Python:
I want to sent data from Teensy 4.0 via serial (USB) to PC and read data by Pyrhon. I have code below but it is very slow. Any idea how to send for exmple 30000 float values and read in Python in 1 second? Now 30000 float values take about 6 seconds.
Many thanks
Michal
Teensy:
Code:
Serial.begin(2000000);
for(int j = 1;j < 30000;j++)
{
Serial.println(random(1, 500) / 100.0);
}
Python:
Code:
import serial
import time
ser = serial.Serial('COM4', 2000000, timeout=0.01)
data = []
def READ_SERIAL():
time_start = time.process_time()
data.clear()
i = 0
while i <= 30000:
line = ser.readline()
txthodnota = line.decode()
hodnota = float(txthodnota)
data.append(hodnota)
i += 1
time_end = time.process_time()
print("Time: " + str(time_end - time_start))