2022-01-15 19:38:30 +08:00
|
|
|
length = 16384
|
2022-01-15 20:52:15 +08:00
|
|
|
ADC_PERIOD = 12.5 # ns
|
2022-01-15 19:38:30 +08:00
|
|
|
|
|
|
|
import serial
|
|
|
|
import numpy as np
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
ser = serial.Serial('/dev/ttyUSB0', 115200, timeout=None)
|
2022-01-15 20:52:15 +08:00
|
|
|
# print(ser.name) # check which port was really used
|
2022-01-15 19:38:30 +08:00
|
|
|
buffer = ser.read(length);
|
2022-01-15 20:52:15 +08:00
|
|
|
x = [float(x)*ADC_PERIOD for x in range(length)]
|
|
|
|
# print(x)
|
|
|
|
y = []
|
2022-01-15 19:38:30 +08:00
|
|
|
for i in range(length):
|
2022-01-15 20:52:15 +08:00
|
|
|
y.append(np.int8(buffer[i]))
|
|
|
|
# print(y)
|
|
|
|
plt.plot(x, y)
|
2022-01-15 19:38:30 +08:00
|
|
|
plt.show()
|
|
|
|
ser.close()
|