From 15b661dbfb72333fd87fd28481a22e0e20a2c9a8 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 21 Feb 2020 15:35:58 +0100 Subject: [PATCH] plot_edgedetect.py converted to python3 --- fpga/tests/plot_edgedetect.py | 36 +++++++++++------------------------ 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/fpga/tests/plot_edgedetect.py b/fpga/tests/plot_edgedetect.py index 3249de6c2..d5bb34991 100755 --- a/fpga/tests/plot_edgedetect.py +++ b/fpga/tests/plot_edgedetect.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #----------------------------------------------------------------------------- # Copyright (C) 2014 iZsh # @@ -11,7 +11,7 @@ import matplotlib.pyplot as plt import sys if len(sys.argv) != 2: - print "Usage: %s " % sys.argv[0] + print("Usage: %s " % sys.argv[0]) sys.exit(1) BASENAME = sys.argv[1] @@ -21,29 +21,15 @@ nx = numpy.fromfile(BASENAME + ".time") def plot_time(dat1): plt.plot(nx, dat1) -sig = open(BASENAME + ".filtered").read() -sig = map(lambda x: ord(x), sig) - -min_vals = open(BASENAME + ".min").read() -min_vals = map(lambda x: ord(x), min_vals) - -max_vals = open(BASENAME + ".max").read() -max_vals = map(lambda x: ord(x), max_vals) - -states = open(BASENAME + ".state").read() -states = map(lambda x: ord(x) * 10 + 65, states) - -toggles = open(BASENAME+ ".toggle").read() -toggles = map(lambda x: ord(x) * 10 + 80, toggles) - -high = open(BASENAME + ".high").read() -high = map(lambda x: ord(x), high) -highz = open(BASENAME + ".highz").read() -highz = map(lambda x: ord(x), highz) -lowz = open(BASENAME + ".lowz").read() -lowz = map(lambda x: ord(x), lowz) -low = open(BASENAME + ".low").read() -low = map(lambda x: ord(x), low) +sig = bytearray(open(BASENAME + ".filtered", 'rb').read()) +min_vals = bytearray(open(BASENAME + ".min", 'rb').read()) +max_vals = bytearray(open(BASENAME + ".max", 'rb').read()) +states = bytearray(open(BASENAME + ".state", 'rb').read()) +toggles = bytearray(open(BASENAME+ ".toggle", 'rb').read()) +high = bytearray(open(BASENAME + ".high", 'rb').read()) +highz = bytearray(open(BASENAME + ".highz", 'rb').read()) +lowz = bytearray(open(BASENAME + ".lowz", 'rb').read()) +low = bytearray(open(BASENAME + ".low", 'rb').read()) plot_time(sig) plot_time(min_vals)