Displaying side channel plots with interactive mode to avoid jumping to foreground on update

Plus small fix for file closing
This commit is contained in:
thavinga 2022-03-28 16:53:07 +02:00
parent a7d34401ff
commit 9fde3bff20
3 changed files with 15 additions and 16 deletions

View File

@ -18,8 +18,7 @@ def display_iq(iq_capture, agc_gain, rssi_half_db):
plt.plot(iq_capture.real, 'b')
plt.plot(iq_capture.imag, 'r')
plt.ylim(-32767, 32767)
fig_iq_capture.show()
plt.pause(0.0001)
fig_iq_capture.canvas.flush_events()
agc_gain_lock = np.copy(agc_gain)
agc_gain_lock[agc_gain>127] = 80 # agc lock
@ -36,8 +35,7 @@ def display_iq(iq_capture, agc_gain, rssi_half_db):
plt.plot(agc_gain_value, 'b')
plt.plot(agc_gain_lock, 'r')
plt.ylim(0, 82)
fig_agc_gain.show()
plt.pause(0.0001)
fig_agc_gain.canvas.flush_events()
fig_rssi_half_db = plt.figure(2)
fig_rssi_half_db.clf()
@ -46,8 +44,7 @@ def display_iq(iq_capture, agc_gain, rssi_half_db):
plt.title("RSSI half dB (uncalibrated)")
plt.plot(rssi_half_db)
plt.ylim(100, 270)
fig_rssi_half_db.show()
plt.pause(0.0001)
fig_rssi_half_db.canvas.flush_events()
def parse_iq(iq, iq_len):
# print(len(iq), iq_len)
@ -98,6 +95,8 @@ if os.path.exists("iq.txt"):
os.remove("iq.txt")
iq_fd=open('iq.txt','a')
plt.ion()
while True:
try:
data, addr = sock.recvfrom(MAX_NUM_DMA_SYMBOL*8) # buffer size
@ -119,5 +118,5 @@ while True:
break
print('close()')
side_info_fd.close()
iq_fd.close()
sock.close()

View File

@ -27,8 +27,7 @@ def display_iq(iq0_capture, iq1_capture):
plt.plot(iq1_capture.real, 'b')
plt.plot(iq1_capture.imag, 'r')
plt.ylim(-32767, 32767)
fig_iq_capture.show()
plt.pause(0.0001)
fig_iq_capture.canvas.flush_events()
def parse_iq(iq, iq_len):
# print(len(iq), iq_len)
@ -77,6 +76,8 @@ if os.path.exists("iq_2ant.txt"):
os.remove("iq_2ant.txt")
iq_fd=open('iq_2ant.txt','a')
plt.ion()
while True:
try:
data, addr = sock.recvfrom(MAX_NUM_DMA_SYMBOL*8) # buffer size
@ -98,5 +99,5 @@ while True:
break
print('close()')
side_info_fd.close()
iq_fd.close()
sock.close()

View File

@ -22,8 +22,7 @@ def display_side_info(freq_offset, csi, equalizer, CSI_LEN, EQUALIZER_LEN):
plt.ylabel("Hz")
plt.title("freq offset")
plt.plot(display_side_info.freq_offset_store)
fig_freq_offset.show()
plt.pause(0.0001)
fig_freq_offset.canvas.flush_events()
good_row_idx = 0
if ( len(equalizer)==0 ):
@ -60,8 +59,7 @@ def display_side_info(freq_offset, csi, equalizer, CSI_LEN, EQUALIZER_LEN):
ax_phase_csi.set_xlabel("subcarrier idx")
ax_phase_csi.set_ylabel("phase")
plt.plot(np.angle(csi_for_plot))
fig_csi.show()
plt.pause(0.0001)
fig_csi.canvas.flush_events()
if ( (len(equalizer)>0) and (good_row_idx>0) ):
fig_equalizer = plt.figure(2)
@ -70,8 +68,7 @@ def display_side_info(freq_offset, csi, equalizer, CSI_LEN, EQUALIZER_LEN):
plt.ylabel("Q")
plt.title("equalizer")
plt.scatter(equalizer_for_plot.real, equalizer_for_plot.imag)
fig_freq_offset.show()
plt.pause(0.0001)
fig_freq_offset.canvas.flush_events()
def parse_side_info(side_info, num_eq, CSI_LEN, EQUALIZER_LEN, HEADER_LEN):
# print(len(side_info), num_eq, CSI_LEN, EQUALIZER_LEN, HEADER_LEN)
@ -135,6 +132,8 @@ if os.path.exists("side_info.txt"):
os.remove("side_info.txt")
side_info_fd=open('side_info.txt','a')
plt.ion()
while True:
try:
data, addr = sock.recvfrom(MAX_NUM_DMA_SYMBOL*8) # buffer size