Commit bd60fb12 authored by John, Fabian's avatar John, Fabian
Browse files

fixed to fast

parent 6368c71f
......@@ -59,10 +59,10 @@ except:
'root_topic': "cosa/uLoc/cir/"
},
'serial': {
'port': "Com3", #ttyUSB0 for tag
'port': "Com4", #ttyUSB0 for tag
'baud': 921600,
'lf': ser_lf.CRLF,
'cir_len': 180
'cir_len': 100
},
# ---------------------------
# take logging as it is
......@@ -151,7 +151,7 @@ while not ser.is_open:
# 16 byte Meta-Data + 180 complex int16 cir-values are send
# Meta: uint16 RmarkerInt, uint16 RmarkerFrac, float strength, float fpStrength, int32_t rxTimestamp
metaLen = 16
metaLen = 12
binary_rec_len = metaLen + cfg['serial']['cir_len']*4
while True:
try:
......@@ -170,31 +170,9 @@ while True:
c = c2
b_rec += c
if len(b_rec) >= binary_rec_len:
time_b = struct.pack('f', time.time())
time_b = struct.pack('d', time.time())
b_rec += time_b
if False:
logging.debug("Received enough")
arr_size = 180 * 2
(RmarkerInt, RmarkerFrac) = struct.unpack('HH', b_rec[0:4])
(rssiVal, fpStrength) = struct.unpack('ff', b_rec[4:12])
(rxTimestamp) = struct.unpack('i', b_rec[12:metaLen])
logging.info(str(rxTimestamp))
(cir) = struct.unpack(str(int(arr_size)) + 'h', b_rec[metaLen:metaLen+arr_size*2])
cir_offset = 700
cirR = np.array(cir[0:-2:2]).astype(float) * (math.pow(10, (rssiVal / 10)))
cirI = np.array(cir[1:-1:2]).astype(float) * (math.pow(10, (rssiVal / 10)))
lead_edge = (RmarkerInt - cir_offset) * 1e-9 + RmarkerFrac * 1e-9 / 64
t = np.array(range(len(cirR))).astype(float) * 1e-9 - lead_edge
cirC = cirR + 1j * cirI
#phase = scipy.interp1d(t, cmath.phase(cirC[0]))
cirC = cirC * np.exp(-1j * cmath.phase(cirC[0]))
plt.ion()
plt.cla()
plt.plot(t, cirC.real, t, cirC.imag)
plt.pause(.001)
logging.debug("Plotted")
ctrl = ser.readline()
if ctrl == b'START\r\r\n':
client.publish(cfg['mqtt']['root_topic'] + "raw", b_rec)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment