36 lines
954 B
Python
36 lines
954 B
Python
import datetime
|
|
import serial
|
|
|
|
port = '/dev/cu.usbserial-1420'
|
|
baud_rate = 9600
|
|
arduino = serial.Serial(port, baudrate=baud_rate, timeout=.1)
|
|
|
|
expected = 1024
|
|
|
|
print("--------------------------------")
|
|
while True:
|
|
while True:
|
|
if (arduino.read() == b'A'):
|
|
break
|
|
|
|
count = 0
|
|
startTime = datetime.datetime.now()
|
|
while True:
|
|
r = arduino.read()
|
|
if (r == b'2'):
|
|
count += 1
|
|
else:
|
|
break;
|
|
endTime = datetime.datetime.now()
|
|
deltaTime = endTime - startTime
|
|
executionTime = deltaTime.total_seconds() * 1000
|
|
print("count for this run: ", count)
|
|
if (r != b'Z'):
|
|
print("run ended with wrong end marker")
|
|
if (count == expected):
|
|
print("\t--> correct count")
|
|
else:
|
|
print("\t--> incorrect count")
|
|
print("\t--> duration: ", round(executionTime,1), "ms")
|
|
print("--------------------------------")
|
|
expected += 2*1024 |