In [278]:
import serial
import scipy
import scipy.stats
import numpy as np
import matplotlib.pyplot as plt
import time
import binascii
import struct

In [363]:
ser = serial.Serial('/dev/ttyACM1', 9600)

In [379]:
lin = []
t_pc = []
t_start = time.time()
for i in range(0, 250):    
    lin.append(ser.readline().decode())
    t_pc.append(time.time() - t_start)

In [380]:
count = len(lin)
t_pc = np.array(t_pc) 
t_pc = t_pc * 1e6
i_ard = np.zeros((count, 1))
t_ard = np.zeros((count, 1))
for i in range(0, count):
    (a, b) = lin[i].split("m")
    i_ard[i] = int(a[2:a.index("]")])
    t_ard[i] = int(b[1:b.index("]")])
t_ard = t_ard - t_ard[0]
i_ard = i_ard - i_ard[0]

In [394]:
plt.plot(t_pc[200:], t_ard[200:], '.')
plt.ylabel("Arduino")
plt.xlabel("PC")
plt.show()

In [382]:
plt.plot(i_ard, t_ard, '.')
plt.ylabel("Arduino")
plt.xlabel("Ind")
plt.show()

In [393]:
scipy.stats.mstats.linregress(t_pc[200:], t_ard[200:])


Out[393]:
(1.0006863484963751,
 2540696.8479069481,
 0.99999265784010138,
 masked_array(data = 1.1574825983817735e-117,
              mask = False,
        fill_value = 1e+20),
 1150.2230120843249)

In [390]:
s[3:]


Out[390]:
'23]m[123]'

In [296]:
lin[i]


Out[296]:
'164800]\n'

In [ ]: