Skip to content

Instantly share code, notes, and snippets.

@joninvski
Created May 26, 2014 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joninvski/55210f6479956ca0437c to your computer and use it in GitHub Desktop.
Save joninvski/55210f6479956ca0437c to your computer and use it in GitHub Desktop.
# To easilly transfer the generated data between the ARM and the PC do the following:
#
# In your pc:
# nc -l -p 2999 > received.json
#
# In the arm
# tail -f /tmp/data/miavita.json | nc 192.168.0.1 2999
import numpy as np
import matplotlib.pyplot as plt
# the scatter plot:
axScatter = plt.subplot(2, 1, 1)
f = open("/tmp/received.json")
delta_l = []
a_l = []
b_l = []
c_l = []
d_l = []
time_l = []
import pdb
last_ts = -1
for l in f.readlines():
try:
# seq = int(l.split('"')[2][1:-1])
timestamp = int(l.split('"')[4][1:-1])
channel_a = int(l.split('"')[6][1:-1])
channel_b = int(l.split('"')[8][1:-1])
channel_c = int(l.split('"')[10][1:-1])
channel_d = int(l.split('"')[12][1:-2])
except:
continue
if last_ts == -1:
delta_time = 0
else:
delta_time = timestamp - last_ts
last_ts = timestamp
delta_l.append(delta_time)
time_l.append(timestamp)
a_l.append(channel_a)
b_l.append(channel_b)
c_l.append(channel_c)
d_l.append(channel_d)
axScatter.scatter(time_l, a_l, s=2, color='r', label='ch1')
axScatter.scatter(time_l, b_l, s=2, color='c', label='ch2')
axScatter.scatter(time_l, c_l, s=2, color='y', label='ch3')
axScatter.scatter(time_l, d_l, s=2, color='g', label='ch4')
plt.legend()
plt.title("Channels Values")
time_plot = plt.subplot(2, 1, 2)
time_plot.plot(time_l, delta_l, c='r', label='x')
plt.title("Timestamp deltas")
plt.draw()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment