Skip to content

Commit

Permalink
Merge pull request RIOT-OS/applications#49 from smlng/pr/fix/plot_rssi
Browse files Browse the repository at this point in the history
spektrum-scanner: fix plot_rssi.py script
  • Loading branch information
smlng authored Oct 8, 2018
2 parents 612b733 + b1cfc48 commit d90adcb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spectrum-scanner/tools/plot_rssi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import numpy as np
import matplotlib.pylab as plt


class rssi_plot(object):

def plot_rssi(self, port):
Expand All @@ -37,7 +38,7 @@ def plot_rssi(self, port):
# Therefore, remove the last value from the Z array.
Z = Z[:, :-1]
logging.debug("Creating figure")
fig = plt.figure()
plt.figure()
pcm = plt.pcolormesh(X, Y, Z, vmin=-128, vmax=0, cmap=plt.cm.get_cmap('jet'))
plt.xlim([0, self.tlen])
plt.ylim([0, 26])
Expand Down Expand Up @@ -65,7 +66,7 @@ def plot_rssi(self, port):
tidx = int(timestamp / (self.dt * 1000000)) % (Z.shape[1])
except ValueError:
continue
logging.debug("data: tidx=%d if=%d t=%d", tidx, iface_id, timestamp)
logging.debug("data: tidx=%d if=%d cnt=%d t=%d", tidx, iface_id, count, timestamp)
raw = pkt_data.group(4)
resize = False
for ch_ed in raw.split(","):
Expand All @@ -82,18 +83,17 @@ def plot_rssi(self, port):
Z[ch, tidx] = ed
except (ValueError, IndexError):
continue
#print("ch: %d ed: %d" % (ch, ed))
if resize:
logging.debug("resize: %d %d" % (ch_min, ch_max))
plt.ylim([ch_min - .5, ch_max + .5])
if now > last_update + 1:
last_update = now
#pcm = plt.pcolormesh(X, Y, Z)
pcm.set_array(Z.ravel())
pcm.autoscale()
pcm.changed()
plt.pause(0.01)


def main(argv):
loglevels = [logging.CRITICAL, logging.ERROR, logging.WARN, logging.INFO, logging.DEBUG]
parser = argparse.ArgumentParser(argv)
Expand Down Expand Up @@ -122,5 +122,6 @@ def main(argv):
port.close()
sys.exit(2)


if __name__ == "__main__":
main(sys.argv)

0 comments on commit d90adcb

Please sign in to comment.