Commit 58b697f2e0d2cc11bc1f4d657c783c66941aa81f

Authored by bmarechal
1 parent 53d84cc32c
Exists in master

-

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

redpitaya/client/iq_demod_only.py
#!/usr/bin/env python2 1 1 #!/usr/bin/env python2
# -*- coding: utf-8 -*- 2 2 # -*- coding: utf-8 -*-
################################################## 3 3 ##################################################
# GNU Radio Python Flow Graph 4 4 # GNU Radio Python Flow Graph
# Title: Iq Demod Only 5 5 # Title: Iq Demod Only
# Generated: Thu Apr 20 11:09:14 2017 6 6 # Generated: Thu Apr 20 16:31:50 2017
################################################## 7 7 ##################################################
8 8
if __name__ == '__main__': 9 9 if __name__ == '__main__':
import ctypes 10 10 import ctypes
import sys 11 11 import sys
if sys.platform.startswith('linux'): 12 12 if sys.platform.startswith('linux'):
try: 13 13 try:
x11 = ctypes.cdll.LoadLibrary('libX11.so') 14 14 x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads() 15 15 x11.XInitThreads()
except: 16 16 except:
print "Warning: failed to XInitThreads()" 17 17 print "Warning: failed to XInitThreads()"
18 18
from PyQt4 import Qt 19 19 from PyQt4 import Qt
from gnuradio import eng_notation 20 20 from gnuradio import eng_notation
from gnuradio import gr 21 21 from gnuradio import gr
from gnuradio.eng_option import eng_option 22 22 from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes 23 23 from gnuradio.filter import firdes
from gnuradio.qtgui import Range, RangeWidget 24 24 from gnuradio.qtgui import Range, RangeWidget
from optparse import OptionParser 25 25 from optparse import OptionParser
import redpitaya_gnuradio 26 26 import redpitaya_gnuradio
import sys 27 27 import sys
28 28
29 29
class iq_demod_only(gr.top_block, Qt.QWidget): 30 30 class iq_demod_only(gr.top_block, Qt.QWidget):
31 31
def __init__(self): 32 32 def __init__(self):
gr.top_block.__init__(self, "Iq Demod Only") 33 33 gr.top_block.__init__(self, "Iq Demod Only")
Qt.QWidget.__init__(self) 34 34 Qt.QWidget.__init__(self)
self.setWindowTitle("Iq Demod Only") 35 35 self.setWindowTitle("Iq Demod Only")
try: 36 36 try:
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) 37 37 self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except: 38 38 except:
pass 39 39 pass
self.top_scroll_layout = Qt.QVBoxLayout() 40 40 self.top_scroll_layout = Qt.QVBoxLayout()
self.setLayout(self.top_scroll_layout) 41 41 self.setLayout(self.top_scroll_layout)
self.top_scroll = Qt.QScrollArea() 42 42 self.top_scroll = Qt.QScrollArea()
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) 43 43 self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
self.top_scroll_layout.addWidget(self.top_scroll) 44 44 self.top_scroll_layout.addWidget(self.top_scroll)
self.top_scroll.setWidgetResizable(True) 45 45 self.top_scroll.setWidgetResizable(True)
self.top_widget = Qt.QWidget() 46 46 self.top_widget = Qt.QWidget()
self.top_scroll.setWidget(self.top_widget) 47 47 self.top_scroll.setWidget(self.top_widget)
self.top_layout = Qt.QVBoxLayout(self.top_widget) 48 48 self.top_layout = Qt.QVBoxLayout(self.top_widget)
self.top_grid_layout = Qt.QGridLayout() 49 49 self.top_grid_layout = Qt.QGridLayout()
self.top_layout.addLayout(self.top_grid_layout) 50 50 self.top_layout.addLayout(self.top_grid_layout)
51 51
self.settings = Qt.QSettings("GNU Radio", "iq_demod_only") 52 52 self.settings = Qt.QSettings("GNU Radio", "iq_demod_only")
self.restoreGeometry(self.settings.value("geometry").toByteArray()) 53 53 self.restoreGeometry(self.settings.value("geometry").toByteArray())
54 54
################################################## 55 55 ##################################################
# Variables 56 56 # Variables
################################################## 57 57 ##################################################
self.port = port = 1001 58 58 self.port = port = 1001
self.f_dds = f_dds = 0 59 59 self.f_dds = f_dds = 0
self.demod_f = demod_f = 0 60 60 self.demod_f = demod_f = 0
self.dds_offset = dds_offset = 0 61 61 self.dds_offset = dds_offset = 0
self.dds_ampl = dds_ampl = 0 62 62 self.dds_ampl = dds_ampl = 0
self.addr = addr = "192.168.0.201" 63 63 self.addr = addr = "192.168.0.201"
self.adc1_offset = adc1_offset = 0 64 64 self.adc1_offset = adc1_offset = 0
65 65
################################################## 66 66 ##################################################
# Blocks 67 67 # Blocks
################################################## 68 68 ##################################################
self._f_dds_range = Range(0, 60000000, 1000, 0, 200) 69 69 self._f_dds_range = Range(0, 60000000, 1000, 0, 200)
self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'f_dds', "counter_slider", float) 70 70 self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'f_dds', "counter_slider", float)
self.top_grid_layout.addWidget(self._f_dds_win, 0, 0) 71 71 self.top_grid_layout.addWidget(self._f_dds_win, 0, 0)
self._demod_f_range = Range(0, 60000000, 1000, 0, 200) 72 72 self._demod_f_range = Range(0, 60000000, 1000, 0, 200)
self._demod_f_win = RangeWidget(self._demod_f_range, self.set_demod_f, 'demod_f', "counter_slider", float) 73 73 self._demod_f_win = RangeWidget(self._demod_f_range, self.set_demod_f, 'demod_f', "counter_slider", float)
self.top_grid_layout.addWidget(self._demod_f_win, 1, 1) 74 74 self.top_grid_layout.addWidget(self._demod_f_win, 1, 1)
self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) 75 75 self._dds_offset_range = Range(-2**13, 2**13-1, 1, 0, 200)
self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int) 76 76 self._dds_offset_win = RangeWidget(self._dds_offset_range, self.set_dds_offset, 'dds_offset', "counter_slider", int)
self.top_grid_layout.addWidget(self._dds_offset_win, 2, 0) 77 77 self.top_grid_layout.addWidget(self._dds_offset_win, 2, 0)
self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200) 78 78 self._dds_ampl_range = Range(0, 2**13-1, 1, 0, 200)
self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int) 79 79 self._dds_ampl_win = RangeWidget(self._dds_ampl_range, self.set_dds_ampl, 'dds_ampl', "counter_slider", int)
self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 0) 80 80 self.top_grid_layout.addWidget(self._dds_ampl_win, 1, 0)
self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200) 81 81 self._adc1_offset_range = Range(-2**13, 2**13-1, 1, 0, 200)
self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int) 82 82 self._adc1_offset_win = RangeWidget(self._adc1_offset_range, self.set_adc1_offset, 'adc1_offset', "counter_slider", int)
self.top_grid_layout.addWidget(self._adc1_offset_win, 0, 1) 83 83 self.top_grid_layout.addWidget(self._adc1_offset_win, 0, 1)
self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf( 84 84 self.nco_counter_send_conf_0_0 = redpitaya_gnuradio.nco_counter_send_conf(
addr=addr, 85 85 addr=addr,
port=port, 86 86 port=port,
device='/dev/demod_nco', 87 87 device='/dev/demod_nco',
freq_ref=125000000, 88 88 freq_ref=125000000,
freq_dds=demod_f, 89 89 freq_dds=demod_f,
acc_size=32, 90 90 acc_size=32,
offset=0, 91 91 offset=0,
pinc_sw=1, 92 92 pinc_sw=1,
poff_sw=1, 93 93 poff_sw=1,
) 94 94 )
95 95
self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( 96 96 self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf(
addr=addr, 97 97 addr=addr,
port=port, 98 98 port=port,
device='/dev/dds_nco', 99 99 device='/dev/dds_nco',
freq_ref=125000000, 100 100 freq_ref=125000000,
freq_dds=f_dds, 101 101 freq_dds=f_dds,
acc_size=32, 102 102 acc_size=32,
offset=0, 103 103 offset=0,
pinc_sw=1, 104 104 pinc_sw=1,
poff_sw=1, 105 105 poff_sw=1,
) 106 106 )
107 107
self.add_const_set_offset_0_1 = redpitaya_gnuradio.add_const_set_offset( 108 108 self.add_const_set_offset_0_1 = redpitaya_gnuradio.add_const_set_offset(
addr=addr, 109 109 addr=addr,
port=port, 110 110 port=port,
device='/dev/adc1_offset', 111 111 device='/dev/adc1_offset',
const=adc1_offset, 112 112 const=adc1_offset,
) 113 113 )
114 114
self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( 115 115 self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset(
addr=addr, 116 116 addr=addr,
port=port, 117 117 port=port,
device='/dev/dds_ampl', 118 118 device='/dev/dds_ampl',
const=dds_ampl, 119 119 const=dds_ampl,
) 120 120 )
121 121
self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( 122 122 self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset(
addr=addr, 123 123 addr=addr,
port=port, 124 124 port=port,
device='/dev/dds_offset', 125 125 device='/dev/dds_offset',
const=dds_offset, 126 126 const=dds_offset,
) 127 127 )
128 128
129 129
def closeEvent(self, event): 130 130 def closeEvent(self, event):
self.settings = Qt.QSettings("GNU Radio", "iq_demod_only") 131 131 self.settings = Qt.QSettings("GNU Radio", "iq_demod_only")
self.settings.setValue("geometry", self.saveGeometry()) 132 132 self.settings.setValue("geometry", self.saveGeometry())
event.accept() 133 133 event.accept()
134 134
def get_port(self): 135 135 def get_port(self):
return self.port 136 136 return self.port
137 137
def set_port(self, port): 138 138 def set_port(self, port):
self.port = port 139 139 self.port = port
140 140
def get_f_dds(self): 141 141 def get_f_dds(self):
return self.f_dds 142 142 return self.f_dds
143 143
def set_f_dds(self, f_dds): 144 144 def set_f_dds(self, f_dds):
self.f_dds = f_dds 145 145 self.f_dds = f_dds
self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) 146 146 self.nco_counter_send_conf_0.set_nco(device='/dev/dds_nco', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0, pinc_sw=1, poff_sw=1)
147 147
def get_demod_f(self): 148 148 def get_demod_f(self):
return self.demod_f 149 149 return self.demod_f
150 150
def set_demod_f(self, demod_f): 151 151 def set_demod_f(self, demod_f):
self.demod_f = demod_f 152 152 self.demod_f = demod_f
self.nco_counter_send_conf_0_0.set_nco(device='/dev/demod_nco', freq_ref=125000000, freq_dds=self.demod_f, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) 153 153 self.nco_counter_send_conf_0_0.set_nco(device='/dev/demod_nco', freq_ref=125000000, freq_dds=self.demod_f, acc_size=32, offset=0, pinc_sw=1, poff_sw=1)
154 154
def get_dds_offset(self): 155 155 def get_dds_offset(self):
return self.dds_offset 156 156 return self.dds_offset
157 157
def set_dds_offset(self, dds_offset): 158 158 def set_dds_offset(self, dds_offset):
self.dds_offset = dds_offset 159 159 self.dds_offset = dds_offset
self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.dds_offset) 160 160 self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.dds_offset)
161 161
def get_dds_ampl(self): 162 162 def get_dds_ampl(self):
return self.dds_ampl 163 163 return self.dds_ampl
164 164
def set_dds_ampl(self, dds_ampl): 165 165 def set_dds_ampl(self, dds_ampl):
self.dds_ampl = dds_ampl 166 166 self.dds_ampl = dds_ampl
self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl) 167 167 self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.dds_ampl)
168 168
def get_addr(self): 169 169 def get_addr(self):