summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/python
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-07-16 14:55:28 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2013-07-16 15:03:10 -0700
commitaf206bb5fc1a255b48dbab344a2bba7581535cb0 (patch)
tree199adbce01307e132d2ab30184404ad2eb118a05 /gnuradio-runtime/python
parentf0198da0bbf6af214b0d629cb77b8539ac42e02a (diff)
controlport: Added probes for byte, short, and int data types
(ctrlport_probe2_x). Had to add some more plumbing to ControlPort to handle different data types to support the new probes. TODO: in 3.8, we will remove ctrlport_probe_c and make a single GRC file for all data types and remove blocks_ctrlport_probe2_c.xml.
Diffstat (limited to 'gnuradio-runtime/python')
-rw-r--r--gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py19
-rwxr-xr-xgnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor70
2 files changed, 49 insertions, 40 deletions
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
index b240dcb8f2..069f3d90ff 100644
--- a/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py
@@ -24,7 +24,7 @@ from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
from gnuradio.ctrlport import GNURadio
-import sys, time
+import sys, time, struct
try:
from gnuradio import qtgui
@@ -426,12 +426,17 @@ class GrDataPlotterValueTable:
numItems = self.treeWidget.topLevelItemCount()
# The input knobs variable is a dict of stats to display in the tree.
-
- # Update tree stat values with new values found in knobs.
- # Track found keys and track keys in tree that are not in input knobs.
- for i in range(0, numItems):
- item = self.treeWidget.topLevelItem(i)
-
+ self.treeWidget.clear()
+ for k, v in knobs.iteritems():
+ val = v.value
+ if(type(val) == GNURadio.complex):
+ val = val.re + val.im*1j
+
+ # If it's a byte stream, Python thinks it's a string.
+ # Unpack and convert to floats for plotting.
+ # Ignore the edge list knob if it's being exported
+ elif(type(val) == str and k.find('edge list') == -1):
+ val = struct.unpack(len(val)*'b', val)
# itemKey is the text in the first column of a QTreeWidgetItem
itemKey = str(item.text(0))
if itemKey in knobs.keys():
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor b/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor
index a8732b4c93..5f23a3d5c4 100755
--- a/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor
+++ b/gnuradio-runtime/python/gnuradio/ctrlport/gr-ctrlport-monitor
@@ -24,7 +24,7 @@ from gnuradio import gr, ctrlport
from PyQt4 import QtCore,Qt
import PyQt4.QtGui as QtGui
-import os, sys, time
+import os, sys, time, struct
import Ice
from gnuradio.ctrlport.IceRadioClient import *
@@ -109,23 +109,8 @@ class MAINWindow(QtGui.QMainWindow):
title = "{0}:{1}".format(r[3], r[5])
props = radio.properties([key])
- pmin = props[key].min.value
- pmax = props[key].max.value
- # Convert from GNURadio::complex to Python complex
- if(type(pmin) == GNURadio.complex):
- pmin = pmin.re + pmin.im*1j
- if(type(pmax) == GNURadio.complex):
- pmax = pmax.re + pmax.im*1j
-
- if pmin == []:
- pmin = None
- else:
- pmin = 1.1*abs(pmin)
- if pmax == []:
- pmax = None
- else:
- pmax = 1.1*abs(pmax)
+ pmin,pmax = get_minmax(props[key])
# Use display option mask of item to set up available plot
# types and default options.
@@ -197,22 +182,7 @@ class MAINWindow(QtGui.QMainWindow):
r = str(tree.radio).split(" ")
title = "{0}:{1}".format(r[3], r[5])
- pmin = knobprop.min.value
- pmax = knobprop.max.value
-
- if(type(pmin) == GNURadio.complex):
- pmin = pmin.re + pmin.im*1j
- if(type(pmax) == GNURadio.complex):
- pmax = pmax.re + pmax.im*1j
-
- if pmin == []:
- pmin = None
- else:
- pmin = 1.1*pmin
- if pmax == []:
- pmax = None
- else:
- pmax = 1.1*pmax
+ pmin,pmax = get_minmax(knobprop)
disp = knobprop.display
if(disp & gr.DISPTIME):
@@ -337,6 +307,13 @@ class MAINWindow(QtGui.QMainWindow):
d = knobs[n].value
if(type(d) == GNURadio.complex):
d = [d.re, d.im]
+
+ # If it's a byte stream, Python thinks it's a string.
+ # Unpack and convert to floats for plotting.
+ if(type(d) == str):
+ d = struct.unpack(len(d)*'b', d)
+ d = [float(di) for di in d]
+
data.append(d)
plot.update(data)
plot.stop()
@@ -738,6 +715,33 @@ class MForm(QtGui.QWidget):
self.parent.propertiesMenu(itemname, self.radio, self.uid)
+def get_minmax(p):
+ pmin = p.min.value
+ pmax = p.max.value
+
+ # Find min/max or real or imag for GNURadio::complex
+ if(type(pmin) == GNURadio.complex):
+ pmin = min(pmin.re, pmin.im)
+ if(type(pmax) == GNURadio.complex):
+ pmax = max(pmax.re, pmax.im)
+
+ # If it's a byte stream, Python thinks it's a string.
+ if(type(pmin) == str):
+ pmin = struct.unpack('b', pmin)[0]
+ if(type(pmax) == str):
+ pmax = struct.unpack('b', pmax)[0]
+
+ if pmin == []:
+ pmin = None
+ else:
+ pmin = 1.1*float(pmin)
+ if pmax == []:
+ pmax = None
+ else:
+ pmax = 1.1*float(pmax)
+
+ return pmin, pmax
+
class MyClient(IceRadioClient):
def __init__(self):
IceRadioClient.__init__(self, MAINWindow)