Plot view added.

This commit is contained in:
klaute 2016-09-20 20:23:55 +02:00
parent 9fa0cb2a47
commit 8a56cbb111

View file

@ -7,6 +7,7 @@ import time
import serial import serial
import copy import copy
import binascii import binascii
import matplotlib.pyplot as plt
############################################################################### ###############################################################################
@ -154,11 +155,8 @@ def cc_dataReceiverThread():
incoming = [] incoming = []
bytesToRead = ser.inWaiting() bytesToRead = ser.inWaiting()
if bytesToRead > 0: if bytesToRead > 0:
#print bytesToRead # TODO
incoming = list(ser.read(64)) incoming = list(ser.read(64))
#print incoming # TODO
# 2. process the received data # 2. process the received data
for c in incoming: for c in incoming:
c = int(binascii.hexlify(c), 16) c = int(binascii.hexlify(c), 16)
@ -348,6 +346,8 @@ if __name__ == "__main__":
config_read = False config_read = False
meas_data = []
cc_init() cc_init()
# parse the commandline arguments # parse the commandline arguments
@ -450,6 +450,8 @@ if __name__ == "__main__":
print "a0: " + str(a0) print "a0: " + str(a0)
print "a1: " + str(a1) print "a1: " + str(a1)
meas_data.append([ freq, a0, a1 ])
elif e[1] == MSG_TYPE_CONFIG: elif e[1] == MSG_TYPE_CONFIG:
print "recv: CONFIG" print "recv: CONFIG"
start_freq = e[3][0] << 24 start_freq = e[3][0] << 24
@ -484,7 +486,36 @@ if __name__ == "__main__":
if args.output_file != None: if args.output_file != None:
pass # TODO impl pass # TODO impl
if args.show_graph == True: if args.show_graph == True:
pass # TODO impl meas_freq = []
meas_ratio = []
meas_r = []
meas_p = []
for m in meas_data:
meas_freq.append(m[0])
if m[1] > m[2]:
meas_ratio.append(m[1] / m[2])
elif m[1] < m[2]:
meas_ratio.append(m[1] / m[2])
else:
meas_ratio.append(1)
# R = meas_data[0] * 5V / 1023
r = (m[1] * 5 / 1023)
meas_r.append(r)
# P = meas_data[0] * 5V ^ 2 / r
if r > 0:
meas_p.append((m[1] * 5)**2 / r)
else:
meas_p.append(0)
plt.plot(meas_freq, meas_ratio)
plt.plot(meas_freq, meas_r)
plt.plot(meas_freq, meas_p)
plt.show()
else: else:
print "err: unknown type 0x%02x" % (e[1]) print "err: unknown type 0x%02x" % (e[1])