summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/CMakeLists.txt5
-rwxr-xr-xgr-uhd/apps/hf_explorer/hfx.py77
-rw-r--r--gr-uhd/apps/hf_radio/input.py4
-rw-r--r--gr-uhd/apps/hf_radio/output.py3
-rwxr-xr-xgr-uhd/apps/hf_radio/radio.py3
-rw-r--r--gr-uhd/apps/hf_radio/ssbagc.py16
-rw-r--r--gr-uhd/apps/hf_radio/ssbdemod.py36
-rwxr-xr-xgr-uhd/apps/uhd_rx_nogui54
-rw-r--r--gr-uhd/apps/uhd_siggen_base.py84
-rwxr-xr-xgr-uhd/apps/uhd_siggen_gui3
-rw-r--r--gr-uhd/doc/uhd.dox4
-rw-r--r--gr-uhd/examples/c++/tag_sink_demo.h6
-rw-r--r--gr-uhd/examples/c++/tag_source_demo.h18
-rw-r--r--gr-uhd/examples/c++/tags_demo.cc14
-rw-r--r--gr-uhd/examples/grc/uhd_dpsk_mod.grc8
-rw-r--r--gr-uhd/examples/grc/uhd_two_tone_loopback.grc544
-rw-r--r--gr-uhd/examples/grc/uhd_tx_dpsk.grc10
-rw-r--r--gr-uhd/examples/grc/uhd_wbfm_receive.grc8
-rwxr-xr-xgr-uhd/examples/python/fm_tx4.py30
-rwxr-xr-xgr-uhd/examples/python/fm_tx_2_daughterboards.py52
-rwxr-xr-xgr-uhd/examples/python/max_power.py11
-rwxr-xr-xgr-uhd/examples/python/usrp_am_mw_rcv.py53
-rwxr-xr-xgr-uhd/examples/python/usrp_nbfm_ptt.py69
-rwxr-xr-xgr-uhd/examples/python/usrp_nbfm_rcv.py30
-rwxr-xr-xgr-uhd/examples/python/usrp_spectrum_sense.py24
-rwxr-xr-xgr-uhd/examples/python/usrp_tv_rcv.py27
-rwxr-xr-xgr-uhd/examples/python/usrp_tv_rcv_nogui.py17
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv.py38
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv2_nogui.py25
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_fmdet.py40
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_nogui.py32
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_pll.py32
-rwxr-xr-xgr-uhd/examples/python/usrp_wfm_rcv_sca.py80
-rwxr-xr-xgr-uhd/examples/python/usrp_wxapt_rcv.py32
-rw-r--r--gr-uhd/include/gr_uhd_usrp_sink.h492
-rw-r--r--gr-uhd/include/gr_uhd_usrp_source.h538
-rw-r--r--gr-uhd/include/uhd/CMakeLists.txt (renamed from gr-uhd/include/CMakeLists.txt)12
-rw-r--r--gr-uhd/include/uhd/amsg_source.h (renamed from gr-uhd/include/gr_uhd_amsg_source.h)51
-rw-r--r--gr-uhd/include/uhd/api.h (renamed from gr-uhd/include/gr_uhd_api.h)0
-rw-r--r--gr-uhd/include/uhd/usrp_sink.h516
-rw-r--r--gr-uhd/include/uhd/usrp_source.h567
-rw-r--r--gr-uhd/lib/CMakeLists.txt18
-rw-r--r--gr-uhd/lib/amsg_source_impl.cc86
-rw-r--r--gr-uhd/lib/amsg_source_impl.h48
-rw-r--r--gr-uhd/lib/gr_uhd_amsg_source.cc95
-rw-r--r--gr-uhd/lib/gr_uhd_common.h26
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_sink.cc503
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc563
-rw-r--r--gr-uhd/lib/usrp_sink_impl.cc575
-rw-r--r--gr-uhd/lib/usrp_sink_impl.h137
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc628
-rw-r--r--gr-uhd/lib/usrp_source_impl.h144
-rw-r--r--gr-uhd/swig/uhd_swig.i21
53 files changed, 3600 insertions, 2909 deletions
diff --git a/gr-uhd/CMakeLists.txt b/gr-uhd/CMakeLists.txt
index 38624b8712..b0407cb8c8 100644
--- a/gr-uhd/CMakeLists.txt
+++ b/gr-uhd/CMakeLists.txt
@@ -32,6 +32,9 @@ GR_REGISTER_COMPONENT("gr-uhd" ENABLE_GR_UHD
Boost_FOUND
UHD_FOUND
ENABLE_GR_CORE
+ ENABLE_GR_FILTER
+ ENABLE_GR_BLOCKS
+ ENABLE_GR_ANALOG
)
GR_SET_GLOBAL(GR_UHD_INCLUDE_DIRS
@@ -89,7 +92,7 @@ CPACK_COMPONENT("uhd_swig"
########################################################################
# Add subdirectories
########################################################################
-add_subdirectory(include)
+add_subdirectory(include/uhd)
add_subdirectory(lib)
add_subdirectory(doc)
add_subdirectory(examples/c++)
diff --git a/gr-uhd/apps/hf_explorer/hfx.py b/gr-uhd/apps/hf_explorer/hfx.py
index 1f08bd8ba6..9e00805134 100755
--- a/gr-uhd/apps/hf_explorer/hfx.py
+++ b/gr-uhd/apps/hf_explorer/hfx.py
@@ -81,6 +81,9 @@ import os, wx, sys, math
import wx.lib.evtmgr as em
from gnuradio.wxgui import powermate, fftsink2
from gnuradio import gr, audio, eng_notation
+from gnuradio import analog
+from gnuradio import filter
+from gnuradio import blocks
from gnuradio.eng_option import eng_option
from gnuradio import uhd
from optparse import OptionParser
@@ -256,10 +259,10 @@ class MyFrame(wx.Frame):
self.tune_offset = 2200 # 2200 works for 3.5-4Mhz band
# convert rf data in interleaved short int form to complex
- s2ss = gr.stream_to_streams(gr.sizeof_short,2)
- s2f1 = gr.short_to_float()
- s2f2 = gr.short_to_float()
- src_f2c = gr.float_to_complex()
+ s2ss = blocks.stream_to_streams(gr.sizeof_short,2)
+ s2f1 = blocks.short_to_float()
+ s2f2 = blocks.short_to_float()
+ src_f2c = blocks.float_to_complex()
self.tb.connect(self.src,s2ss)
self.tb.connect((s2ss,0),s2f1)
self.tb.connect((s2ss,1),s2f2)
@@ -272,23 +275,23 @@ class MyFrame(wx.Frame):
self.tb.connect (self.src, radio_file)
# 2nd DDC
- xlate_taps = gr.firdes.low_pass ( \
- 1.0, input_rate, 16e3, 4e3, gr.firdes.WIN_HAMMING )
- self.xlate = gr.freq_xlating_fir_filter_ccf ( \
+ xlate_taps = filter.firdes.low_pass ( \
+ 1.0, input_rate, 16e3, 4e3, filter.firdes.WIN_HAMMING )
+ self.xlate = filter.freq_xlating_fir_filter_ccf ( \
fir_decim, xlate_taps, self.tune_offset, input_rate )
# Complex Audio filter
- audio_coeffs = gr.firdes.complex_band_pass (
+ audio_coeffs = filter.firdes.complex_band_pass (
1.0, # gain
self.af_sample_rate, # sample rate
-3000, # low cutoff
0, # high cutoff
100, # transition
- gr.firdes.WIN_HAMMING) # window
+ filter.firdes.WIN_HAMMING) # window
self.slider_fcutoff_hi.SetValue(0)
self.slider_fcutoff_lo.SetValue(-3000)
- self.audio_filter = gr.fir_filter_ccc(1, audio_coeffs)
+ self.audio_filter = filter.fir_filter_ccc(1, audio_coeffs)
# Main +/- 16Khz spectrum display
self.fft = fftsink2.fft_sink_c(self.panel_2, fft_size=512,
@@ -302,46 +305,46 @@ class MyFrame(wx.Frame):
sample_rate=self.af_sample_rate,
average=True, size=(640,240))
- c2f = gr.complex_to_float()
+ c2f = blocks.complex_to_float()
# AM branch
- self.sel_am = gr.multiply_const_cc(0)
+ self.sel_am = blocks.multiply_const_cc(0)
# the following frequencies turn out to be in radians/sample
- # gr.pll_refout_cc(alpha,beta,min_freq,max_freq)
+ # analog.pll_refout_cc(alpha,beta,min_freq,max_freq)
# suggested alpha = X, beta = .25 * X * X
- pll = gr.pll_refout_cc(.5,.0625,(2.*math.pi*7.5e3/self.af_sample_rate),
- (2.*math.pi*6.5e3/self.af_sample_rate))
- self.pll_carrier_scale = gr.multiply_const_cc(complex(10,0))
- am_det = gr.multiply_cc()
+ pll = analog.pll_refout_cc(.5,.0625,(2.*math.pi*7.5e3/self.af_sample_rate),
+ (2.*math.pi*6.5e3/self.af_sample_rate))
+ self.pll_carrier_scale = blocks.multiply_const_cc(complex(10,0))
+ am_det = blocks.multiply_cc()
# these are for converting +7.5kHz to -7.5kHz
- # for some reason gr.conjugate_cc() adds noise ??
- c2f2 = gr.complex_to_float()
- c2f3 = gr.complex_to_float()
- f2c = gr.float_to_complex()
- phaser1 = gr.multiply_const_ff(1)
- phaser2 = gr.multiply_const_ff(-1)
+ # for some reason blocks.conjugate_cc() adds noise ??
+ c2f2 = blocks.complex_to_float()
+ c2f3 = blocks.complex_to_float()
+ f2c = blocks.float_to_complex()
+ phaser1 = blocks.multiply_const_ff(1)
+ phaser2 = blocks.multiply_const_ff(-1)
# filter for pll generated carrier
- pll_carrier_coeffs = gr.firdes.complex_band_pass (
+ pll_carrier_coeffs = filter.firdes.complex_band_pass (
2.0, # gain
self.af_sample_rate, # sample rate
7400, # low cutoff
7600, # high cutoff
100, # transition
- gr.firdes.WIN_HAMMING) # window
+ filter.firdes.WIN_HAMMING) # window
- self.pll_carrier_filter = gr.fir_filter_ccc (1, pll_carrier_coeffs)
+ self.pll_carrier_filter = filter.fir_filter_ccc (1, pll_carrier_coeffs)
- self.sel_sb = gr.multiply_const_ff(1)
- combine = gr.add_ff()
+ self.sel_sb = blocks.multiply_const_ff(1)
+ combine = blocks.add_ff()
#AGC
- sqr1 = gr.multiply_ff()
- intr = gr.iir_filter_ffd ( [.004, 0], [0, .999] )
- offset = gr.add_const_ff(1)
- agc = gr.divide_ff()
+ sqr1 = blocks.multiply_ff()
+ intr = filter.iir_filter_ffd( [.004, 0], [0, .999] )
+ offset = blocks.add_const_ff(1)
+ agc = blocks.divide_ff()
- self.scale = gr.multiply_const_ff(0.00001)
+ self.scale = blocks.multiply_const_ff(0.00001)
dst = audio.sink(long(self.af_sample_rate),
options.audio_output)
@@ -373,8 +376,8 @@ class MyFrame(wx.Frame):
if SAVE_AUDIO_TO_FILE:
f_out = gr.file_sink(gr.sizeof_short,options.audio_file)
- sc1 = gr.multiply_const_ff(64000)
- f2s1 = gr.float_to_short()
+ sc1 = blocks.multiply_const_ff(64000)
+ f2s1 = blocks.float_to_short()
self.tb.connect(agc,sc1,f2s1,f_out)
self.tb.start()
@@ -610,13 +613,13 @@ class MyFrame(wx.Frame):
# Calculate taps and apply
def filter(self):
- audio_coeffs = gr.firdes.complex_band_pass (
+ audio_coeffs = filter.firdes.complex_band_pass (
1.0, # gain
self.af_sample_rate, # sample rate
self.slider_fcutoff_lo.GetValue(), # low cutoff
self.slider_fcutoff_hi.GetValue(), # high cutoff
100, # transition
- gr.firdes.WIN_HAMMING) # window
+ filter.firdes.WIN_HAMMING) # window
self.audio_filter.set_taps(audio_coeffs)
def set_lsb(self, event):
diff --git a/gr-uhd/apps/hf_radio/input.py b/gr-uhd/apps/hf_radio/input.py
index 78e800bb6c..fd2ac47a5c 100644
--- a/gr-uhd/apps/hf_radio/input.py
+++ b/gr-uhd/apps/hf_radio/input.py
@@ -47,8 +47,8 @@ class uhd_input(gr.hier_block2):
"""
Set the center frequency.
- @param target_freq: frequency in Hz
- @type: bool
+ Args:
+ target_freq: frequency in Hz
"""
r = self.src.set_center_freq(target_freq, 0)
diff --git a/gr-uhd/apps/hf_radio/output.py b/gr-uhd/apps/hf_radio/output.py
index 70add5b84a..3e80c8d315 100644
--- a/gr-uhd/apps/hf_radio/output.py
+++ b/gr-uhd/apps/hf_radio/output.py
@@ -24,6 +24,7 @@
# M. Revnell 2005-Dec
from gnuradio import gr, gru
+from gnuradio import blocks
from gnuradio import audio
class output( gr.hier_block2 ):
@@ -32,7 +33,7 @@ class output( gr.hier_block2 ):
gr.io_signature(1,1,gr.sizeof_float),
gr.io_signature(0,0,0))
- self.vol = gr.multiply_const_ff( 0.1 )
+ self.vol = blocks.multiply_const_ff( 0.1 )
self.out = audio.sink( int(rate), device )
self.connect( self, self.vol, self.out )
diff --git a/gr-uhd/apps/hf_radio/radio.py b/gr-uhd/apps/hf_radio/radio.py
index 93d985067d..bbe2bfddb6 100755
--- a/gr-uhd/apps/hf_radio/radio.py
+++ b/gr-uhd/apps/hf_radio/radio.py
@@ -33,6 +33,7 @@ import time
from gnuradio import gr, gru, eng_notation, optfir
from gnuradio import audio
+from gnuradio import blocks
from gnuradio import uhd
from gnuradio import blks2
from gnuradio.wxgui import fftsink2
@@ -305,7 +306,7 @@ def main():
global radio_obj, sig_probe
radio_obj = radio( 0 )
- sig_probe = gr.probe_signal_f()
+ sig_probe = blocks.probe_signal_f()
radio_obj.block.connect(radio_obj.block.agc.offs, sig_probe)
thread2 = Thread( target = rssi_function )
diff --git a/gr-uhd/apps/hf_radio/ssbagc.py b/gr-uhd/apps/hf_radio/ssbagc.py
index 6a2e0a7cd4..48cc009101 100644
--- a/gr-uhd/apps/hf_radio/ssbagc.py
+++ b/gr-uhd/apps/hf_radio/ssbagc.py
@@ -43,6 +43,8 @@
# M. Revnell 2006-Jan
from gnuradio import gr
+from gnuradio import blocks
+from gnuradio import filter
class agc( gr.hier_block2 ):
def __init__( self ):
@@ -50,13 +52,13 @@ class agc( gr.hier_block2 ):
gr.io_signature(1,1,gr.sizeof_float),
gr.io_signature(1,1,gr.sizeof_float))
- self.split = gr.multiply_const_ff( 1 )
- self.sqr = gr.multiply_ff( )
- self.int0 = gr.iir_filter_ffd( [.004, 0], [0, .999] )
- self.offs = gr.add_const_ff( -30 )
- self.gain = gr.multiply_const_ff( 70 )
- self.log = gr.nlog10_ff( 10, 1 )
- self.agc = gr.divide_ff( )
+ self.split = blocks.multiply_const_ff( 1 )
+ self.sqr = blocks.multiply_ff( )
+ self.int0 = filter.iir_filter_ffd( [.004, 0], [0, .999] )
+ self.offs = blocks.add_const_ff( -30 )
+ self.gain = blocks.multiply_const_ff( 70 )
+ self.log = blocks.nlog10_ff( 10, 1 )
+ self.agc = blocks.divide_ff( )
self.connect(self, self.split)
self.connect(self.split, (self.agc, 0))
diff --git a/gr-uhd/apps/hf_radio/ssbdemod.py b/gr-uhd/apps/hf_radio/ssbdemod.py
index 3c533f617f..d364f5e0ec 100644
--- a/gr-uhd/apps/hf_radio/ssbdemod.py
+++ b/gr-uhd/apps/hf_radio/ssbdemod.py
@@ -32,6 +32,8 @@
# M. Revnell Jan 06
from gnuradio import gr
+from gnuradio import blocks
+from gnuradio import filter
class ssb_demod( gr.hier_block2 ):
def __init__( self, if_rate, af_rate ):
@@ -46,29 +48,29 @@ class ssb_demod( gr.hier_block2 ):
self.xlate_taps = ([complex(v) for v in file('ssb_taps').readlines()])
- self.audio_taps = gr.firdes.low_pass(
+ self.audio_taps = filter.firdes.low_pass(
1.0,
self.af_rate,
3e3,
600,
- gr.firdes.WIN_HAMMING )
+ filter.firdes.WIN_HAMMING )
- self.xlate = gr.freq_xlating_fir_filter_ccc(
+ self.xlate = filter.freq_xlating_fir_filter_ccc(
self.if_decim,
self.xlate_taps,
0,
self.if_rate )
- self.split = gr.complex_to_float()
+ self.split = blocks.complex_to_float()
- self.lpf = gr.fir_filter_fff(
+ self.lpf = filter.fir_filter_fff(
1, self.audio_taps )
- self.sum = gr.add_ff( )
- self.am_sel = gr.multiply_const_ff( 0 )
- self.sb_sel = gr.multiply_const_ff( 1 )
- self.mixer = gr.add_ff()
- self.am_det = gr.complex_to_mag()
+ self.sum = blocks.add_ff( )
+ self.am_sel = blocks.multiply_const_ff( 0 )
+ self.sb_sel = blocks.multiply_const_ff( 1 )
+ self.mixer = blocks.add_ff()
+ self.am_det = blocks.complex_to_mag()
self.connect(self, self.xlate)
self.connect(self.xlate, self.split)
@@ -93,22 +95,22 @@ class ssb_demod( gr.hier_block2 ):
self.am_sel.set_k( 0.0 )
def set_am( self ):
- taps = gr.firdes.low_pass( 1.0,
- self.if_rate,
- 5e3,
- 2e3,
- gr.firdes.WIN_HAMMING )
+ taps = filter.firdes.low_pass( 1.0,
+ self.if_rate,
+ 5e3,
+ 2e3,
+ filter.firdes.WIN_HAMMING )
self.xlate.set_taps( taps )
self.sb_sel.set_k( 0.0 )
self.am_sel.set_k( 1.0 )
def set_bw( self, bw ):
- self.audio_taps = gr.firdes.low_pass(
+ self.audio_taps = filter.firdes.low_pass(
1.0,
self.af_rate,
bw,
600,
- gr.firdes.WIN_HAMMING )
+ filter.firdes.WIN_HAMMING )
self.lpf.set_taps( self.audio_taps )
def tune( self, freq ):
diff --git a/gr-uhd/apps/uhd_rx_nogui b/gr-uhd/apps/uhd_rx_nogui
index f0cfdd8bed..ea43a43be6 100755
--- a/gr-uhd/apps/uhd_rx_nogui
+++ b/gr-uhd/apps/uhd_rx_nogui
@@ -20,7 +20,9 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, gru, uhd, optfir, audio, blks2
+from gnuradio import gr, gru, uhd, audio
+from gnuradio import filter
+from gnuradio import analog
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser
@@ -69,9 +71,9 @@ blocks.
# (device_rate, channel_rate, audio_rate, channel_pass, channel_stop, demod)
demod_params = {
- 'AM' : (256e3, 16e3, 16e3, 5000, 8000, blks2.demod_10k0a3e_cf),
- 'FM' : (256e3, 32e3, 8e3, 8000, 9000, blks2.demod_20k0f3e_cf),
- 'WFM' : (320e3, 320e3, 32e3, 80000, 115000, blks2.demod_200kf3e_cf)
+ 'AM' : (256e3, 16e3, 16e3, 5000, 8000, analog.demod_10k0a3e_cf),
+ 'FM' : (256e3, 32e3, 8e3, 8000, 9000, analog.demod_20k0f3e_cf),
+ 'WFM' : (320e3, 320e3, 32e3, 80000, 115000, analog.demod_200kf3e_cf)
}
class uhd_src(gr.hier_block2):
@@ -104,7 +106,7 @@ class uhd_src(gr.hier_block2):
# Resampler to get to exactly samp_rate no matter what dev_rate is
self._rrate = samp_rate / dev_rate
- self._resamp = blks2.pfb_arb_resampler_ccf(self._rrate)
+ self._resamp = filter.pfb.arb_resampler_ccf(self._rrate)
# If no gain specified, set to midrange
gain_range = self._src.get_gain_range()
@@ -142,27 +144,27 @@ class app_top_block(gr.top_block):
channel_decim = int(if_rate // channel_rate)
audio_decim = int(channel_rate // audio_rate)
- CHAN_taps = optfir.low_pass(1.0, # Filter gain
- if_rate, # Sample rate
- channel_pass, # One sided modulation bandwidth
- channel_stop, # One sided channel bandwidth
- 0.1, # Passband ripple
- 60) # Stopband attenuation
+ CHAN_taps = filter.optfir.low_pass(1.0, # Filter gain
+ if_rate, # Sample rate
+ channel_pass, # One sided modulation bandwidth
+ channel_stop, # One sided channel bandwidth
+ 0.1, # Passband ripple
+ 60) # Stopband attenuation
- CHAN = gr.freq_xlating_fir_filter_ccf(channel_decim, # Decimation rate
- CHAN_taps, # Filter taps
- 0.0, # Offset frequency
- if_rate) # Sample rate
+ CHAN = filter.freq_xlating_fir_filter_ccf(channel_decim, # Decimation rate
+ CHAN_taps, # Filter taps
+ 0.0, # Offset frequency
+ if_rate) # Sample rate
- RFSQL = gr.pwr_squelch_cc(options.rf_squelch, # Power threshold
- 125.0/channel_rate, # Time constant
- int(channel_rate/20), # 50ms rise/fall
- False) # Zero, not gate output
+ RFSQL = analog.pwr_squelch_cc(options.rf_squelch, # Power threshold
+ 125.0/channel_rate, # Time constant
+ int(channel_rate/20), # 50ms rise/fall
+ False) # Zero, not gate output
- AGC = gr.agc_cc(1.0/channel_rate, # Time constant
- 1.0, # Reference power
- 1.0, # Initial gain
- 1.0) # Maximum gain
+ AGC = analog.agc_cc(1.0/channel_rate, # Time constant
+ 1.0, # Reference power
+ 1.0, # Initial gain
+ 1.0) # Maximum gain
DEMOD = demod(channel_rate, audio_decim)
@@ -173,8 +175,8 @@ class app_top_block(gr.top_block):
# Optionally add CTCSS and RSAMP if needed
tail = DEMOD
if options.ctcss != None and options.ctcss > 60.0:
- CTCSS = gr.ctcss_squelch_ff(audio_rate, # Sample rate
- options.ctcss) # Squelch tone
+ CTCSS = analog.ctcss_squelch_ff(audio_rate, # Sample rate
+ options.ctcss) # Squelch tone
self.connect(DEMOD, CTCSS)
tail = CTCSS
@@ -182,7 +184,7 @@ class app_top_block(gr.top_block):
out_lcm = gru.lcm(audio_rate, options.output_rate)
out_interp = int(out_lcm // audio_rate)
out_decim = int(out_lcm // options.output_rate)
- RSAMP = blks2.rational_resampler_fff(out_interp, out_decim)
+ RSAMP = filter.rational_resampler_fff(out_interp, out_decim)
self.connect(tail, RSAMP)
tail = RSAMP
diff --git a/gr-uhd/apps/uhd_siggen_base.py b/gr-uhd/apps/uhd_siggen_base.py
index 8c69da1ccb..6b51bfcb50 100644
--- a/gr-uhd/apps/uhd_siggen_base.py
+++ b/gr-uhd/apps/uhd_siggen_base.py
@@ -39,6 +39,8 @@ TYPE_KEY = 'type'
def setter(ps, key, val): ps[key] = val
from gnuradio import gr, gru, uhd, eng_notation
+from gnuradio import analog
+from gnuradio import blocks
from gnuradio.gr.pubsub import pubsub
from gnuradio.eng_option import eng_option
from optparse import OptionParser
@@ -47,10 +49,10 @@ import math
n2s = eng_notation.num_to_str
-waveforms = { gr.GR_SIN_WAVE : "Complex Sinusoid",
- gr.GR_CONST_WAVE : "Constant",
- gr.GR_GAUSSIAN : "Gaussian Noise",
- gr.GR_UNIFORM : "Uniform Noise",
+waveforms = { analog.GR_SIN_WAVE : "Complex Sinusoid",
+ analog.GR_CONST_WAVE : "Constant",
+ analog.GR_GAUSSIAN : "Gaussian Noise",
+ analog.GR_UNIFORM : "Uniform Noise",
"2tone" : "Two Tone",
"sweep" : "Sweep" }
@@ -151,7 +153,9 @@ class top_block(gr.top_block, pubsub):
def _set_tx_amplitude(self, ampl):
"""
Sets the transmit amplitude sent to the USRP
- @param ampl the amplitude or None for automatic
+
+ Args:
+ ampl: the amplitude or None for automatic
"""
ampl_range = self[AMPL_RANGE_KEY]
if ampl is None:
@@ -162,7 +166,7 @@ class top_block(gr.top_block, pubsub):
self._u.set_samp_rate(sr)
sr = self._u.get_samp_rate()
- if self[TYPE_KEY] in (gr.GR_SIN_WAVE, gr.GR_CONST_WAVE):
+ if self[TYPE_KEY] in (analog.GR_SIN_WAVE, analog.GR_CONST_WAVE):
self._src.set_sampling_freq(self[SAMP_RATE_KEY])
elif self[TYPE_KEY] == "2tone":
self._src1.set_sampling_freq(self[SAMP_RATE_KEY])
@@ -215,7 +219,7 @@ class top_block(gr.top_block, pubsub):
return tr
def set_waveform_freq(self, freq):
- if self[TYPE_KEY] == gr.GR_SIN_WAVE:
+ if self[TYPE_KEY] == analog.GR_SIN_WAVE:
self._src.set_frequency(freq)
elif self[TYPE_KEY] == "2tone":
self._src1.set_frequency(freq)
@@ -237,29 +241,29 @@ class top_block(gr.top_block, pubsub):
def set_waveform(self, type):
self.lock()
self.disconnect_all()
- if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
- self._src = gr.sig_source_c(self[SAMP_RATE_KEY], # Sample rate
- type, # Waveform type
- self[WAVEFORM_FREQ_KEY], # Waveform frequency
- self[AMPLITUDE_KEY], # Waveform amplitude
- self[WAVEFORM_OFFSET_KEY]) # Waveform offset
- elif type == gr.GR_GAUSSIAN or type == gr.GR_UNIFORM:
- self._src = gr.noise_source_c(type, self[AMPLITUDE_KEY])
+ if type == analog.GR_SIN_WAVE or type == analog.GR_CONST_WAVE:
+ self._src = analog.sig_source_c(self[SAMP_RATE_KEY], # Sample rate
+ type, # Waveform type
+ self[WAVEFORM_FREQ_KEY], # Waveform frequency
+ self[AMPLITUDE_KEY], # Waveform amplitude
+ self[WAVEFORM_OFFSET_KEY]) # Waveform offset
+ elif type == analog.GR_GAUSSIAN or type == analog.GR_UNIFORM:
+ self._src = analog.noise_source_c(type, self[AMPLITUDE_KEY])
elif type == "2tone":
- self._src1 = gr.sig_source_c(self[SAMP_RATE_KEY],
- gr.GR_SIN_WAVE,
- self[WAVEFORM_FREQ_KEY],
- self[AMPLITUDE_KEY]/2.0,
- 0)
+ self._src1 = analog.sig_source_c(self[SAMP_RATE_KEY],
+ analog.GR_SIN_WAVE,
+ self[WAVEFORM_FREQ_KEY],
+ self[AMPLITUDE_KEY]/2.0,
+ 0)
if(self[WAVEFORM2_FREQ_KEY] is None):
self[WAVEFORM2_FREQ_KEY] = -self[WAVEFORM_FREQ_KEY]
- self._src2 = gr.sig_source_c(self[SAMP_RATE_KEY],
- gr.GR_SIN_WAVE,
- self[WAVEFORM2_FREQ_KEY],
- self[AMPLITUDE_KEY]/2.0,
- 0)
- self._src = gr.add_cc()
+ self._src2 = analog.sig_source_c(self[SAMP_RATE_KEY],
+ analog.GR_SIN_WAVE,
+ self[WAVEFORM2_FREQ_KEY],
+ self[AMPLITUDE_KEY]/2.0,
+ 0)
+ self._src = blocks.add_cc()
self.connect(self._src1,(self._src,0))
self.connect(self._src2,(self._src,1))
elif type == "sweep":
@@ -270,13 +274,13 @@ class top_block(gr.top_block, pubsub):
if self[WAVEFORM2_FREQ_KEY] is None:
self[WAVEFORM2_FREQ_KEY] = 0.1
- self._src1 = gr.sig_source_f(self[SAMP_RATE_KEY],
- gr.GR_TRI_WAVE,
- self[WAVEFORM2_FREQ_KEY],
- 1.0,
- -0.5)
- self._src2 = gr.frequency_modulator_fc(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[SAMP_RATE_KEY])
- self._src = gr.multiply_const_cc(self[AMPLITUDE_KEY])
+ self._src1 = analog.sig_source_f(self[SAMP_RATE_KEY],
+ analog.GR_TRI_WAVE,
+ self[WAVEFORM2_FREQ_KEY],
+ 1.0,
+ -0.5)
+ self._src2 = analog.frequency_modulator_fc(self[WAVEFORM_FREQ_KEY]*2*math.pi/self[SAMP_RATE_KEY])
+ self._src = blocks.multiply_const_cc(self[AMPLITUDE_KEY])
self.connect(self._src1,self._src2,self._src)
else:
raise RuntimeError("Unknown waveform type")
@@ -286,7 +290,7 @@ class top_block(gr.top_block, pubsub):
if self._verbose:
print "Set baseband modulation to:", waveforms[type]
- if type == gr.GR_SIN_WAVE:
+ if type == analog.GR_SIN_WAVE:
print "Modulation frequency: %sHz" % (n2s(self[WAVEFORM_FREQ_KEY]),)
print "Initial phase:", self[WAVEFORM_OFFSET_KEY]
elif type == "2tone":
@@ -304,7 +308,7 @@ class top_block(gr.top_block, pubsub):
print "Amplitude out of range:", amplitude
return False
- if self[TYPE_KEY] in (gr.GR_SIN_WAVE, gr.GR_CONST_WAVE, gr.GR_GAUSSIAN, gr.GR_UNIFORM):
+ if self[TYPE_KEY] in (analog.GR_SIN_WAVE, analog.GR_CONST_WAVE, analog.GR_GAUSSIAN, analog.GR_UNIFORM):
self._src.set_amplitude(amplitude)
elif self[TYPE_KEY] == "2tone":
self._src1.set_amplitude(amplitude/2.0)
@@ -339,16 +343,16 @@ def get_options():
help="Set baseband waveform frequency to FREQ [default=%default]")
parser.add_option("-y", "--waveform2-freq", type="eng_float", default=None,
help="Set 2nd waveform frequency to FREQ [default=%default]")
- parser.add_option("--sine", dest="type", action="store_const", const=gr.GR_SIN_WAVE,
+ parser.add_option("--sine", dest="type", action="store_const", const=analog.GR_SIN_WAVE,
help="Generate a carrier modulated by a complex sine wave",
- default=gr.GR_SIN_WAVE)
- parser.add_option("--const", dest="type", action="store_const", const=gr.GR_CONST_WAVE,
+ default=analog.GR_SIN_WAVE)
+ parser.add_option("--const", dest="type", action="store_const", const=analog.GR_CONST_WAVE,
help="Generate a constant carrier")
parser.add_option("--offset", type="eng_float", default=0,
help="Set waveform phase offset to OFFSET [default=%default]")
- parser.add_option("--gaussian", dest="type", action="store_const", const=gr.GR_GAUSSIAN,
+ parser.add_option("--gaussian", dest="type", action="store_const", const=analog.GR_GAUSSIAN,
help="Generate Gaussian random output")
- parser.add_option("--uniform", dest="type", action="store_const", const=gr.GR_UNIFORM,
+ parser.add_option("--uniform", dest="type", action="store_const", const=analog.GR_UNIFORM,
help="Generate Uniform random output")
parser.add_option("--2tone", dest="type", action="store_const", const="2tone",
help="Generate Two Tone signal for IMD testing")
diff --git a/gr-uhd/apps/uhd_siggen_gui b/gr-uhd/apps/uhd_siggen_gui
index 70929b1825..80fcf8e673 100755
--- a/gr-uhd/apps/uhd_siggen_gui
+++ b/gr-uhd/apps/uhd_siggen_gui
@@ -22,6 +22,7 @@
import wx
from gnuradio import gr, uhd
+from gnuradio import analog
from gnuradio.gr.pubsub import pubsub
from gnuradio.wxgui import gui, forms
from gnuradio.uhd import uhd_siggen_base as uhd_siggen
@@ -58,7 +59,7 @@ class app_gui(pubsub):
self.vbox.AddStretchSpacer()
#callback to show/hide forms
def set_type(type):
- sine_bb_hbox.ShowItems(type == gr.GR_SIN_WAVE)
+ sine_bb_hbox.ShowItems(type == analog.GR_SIN_WAVE)
sweep_bb_hbox.ShowItems(type == 'sweep')
tone_bb_hbox.ShowItems(type == '2tone')
self.vbox.Layout()
diff --git a/gr-uhd/doc/uhd.dox b/gr-uhd/doc/uhd.dox
index f03705fe18..4cd30a86b6 100644
--- a/gr-uhd/doc/uhd.dox
+++ b/gr-uhd/doc/uhd.dox
@@ -92,10 +92,10 @@ resampler to take care of the difference.
actual_rate = self.u.get_samp_rate()
resample = desired_rate / actual_rate
- # Use the blks2 version and pass only the resample factor.
+ # Use the filter.pfb version and pass only the resample factor.
# This block builds a half-band filter for you
- self.resampler = blks2.pfb_arb_resampler_ccf(resample)
+ self.resampler = filter.pfb.arb_resampler_ccf(resample)
\endcode
*/
diff --git a/gr-uhd/examples/c++/tag_sink_demo.h b/gr-uhd/examples/c++/tag_sink_demo.h
index 5417bd3242..676005e06c 100644
--- a/gr-uhd/examples/c++/tag_sink_demo.h
+++ b/gr-uhd/examples/c++/tag_sink_demo.h
@@ -47,7 +47,7 @@ public:
//grab all "rx time" tags in this work call
const uint64_t samp0_count = this->nitems_read(0);
std::vector<gr_tag_t> rx_time_tags;
- get_tags_in_range(rx_time_tags, 0, samp0_count, samp0_count + ninput_items, pmt::pmt_string_to_symbol("rx_time"));
+ get_tags_in_range(rx_time_tags, 0, samp0_count, samp0_count + ninput_items, pmt::string_to_symbol("rx_time"));
//print all tags
BOOST_FOREACH(const gr_tag_t &rx_time_tag, rx_time_tags){
@@ -55,8 +55,8 @@ public:
const pmt::pmt_t &value = rx_time_tag.value;
std::cout << boost::format("Full seconds %u, Frac seconds %f, abs sample offset %u")
- % pmt::pmt_to_uint64(pmt::pmt_tuple_ref(value, 0))
- % pmt::pmt_to_double(pmt::pmt_tuple_ref(value, 1))
+ % pmt::to_uint64(pmt::tuple_ref(value, 0))
+ % pmt::to_double(pmt::tuple_ref(value, 1))
% offset
<< std::endl;
}
diff --git a/gr-uhd/examples/c++/tag_source_demo.h b/gr-uhd/examples/c++/tag_source_demo.h
index 7d48502b24..6efe4667e5 100644
--- a/gr-uhd/examples/c++/tag_source_demo.h
+++ b/gr-uhd/examples/c++/tag_source_demo.h
@@ -53,26 +53,26 @@ public:
}
void make_time_tag(const uint64_t tag_count){;
- const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_time");
- const pmt::pmt_t value = pmt::pmt_make_tuple(
- pmt::pmt_from_uint64(_time_secs),
- pmt::pmt_from_double(_time_fracs)
+ const pmt::pmt_t key = pmt::string_to_symbol("tx_time");
+ const pmt::pmt_t value = pmt::make_tuple(
+ pmt::from_uint64(_time_secs),
+ pmt::from_double(_time_fracs)
);
- const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name());
+ const pmt::pmt_t srcid = pmt::string_to_symbol(this->name());
this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid);
}
void make_sob_tag(const uint64_t tag_count){
- const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_sob");
+ const pmt::pmt_t key = pmt::string_to_symbol("tx_sob");
const pmt::pmt_t value = pmt::PMT_T;
- const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name());
+ const pmt::pmt_t srcid = pmt::string_to_symbol(this->name());
this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid);
}
void make_eob_tag(const uint64_t tag_count){;
- const pmt::pmt_t key = pmt::pmt_string_to_symbol("tx_eob");
+ const pmt::pmt_t key = pmt::string_to_symbol("tx_eob");
const pmt::pmt_t value = pmt::PMT_T;
- const pmt::pmt_t srcid = pmt::pmt_string_to_symbol(this->name());
+ const pmt::pmt_t srcid = pmt::string_to_symbol(this->name());
this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid);
}
diff --git a/gr-uhd/examples/c++/tags_demo.cc b/gr-uhd/examples/c++/tags_demo.cc
index cc4c932726..890cc12dea 100644
--- a/gr-uhd/examples/c++/tags_demo.cc
+++ b/gr-uhd/examples/c++/tags_demo.cc
@@ -20,8 +20,8 @@
*/
#include <gr_top_block.h>
-#include <gr_uhd_usrp_source.h>
-#include <gr_uhd_usrp_sink.h>
+#include <uhd/usrp_source.h>
+#include <uhd/usrp_sink.h>
#include <tag_source_demo.h>
#include <tag_sink_demo.h>
#include <boost/make_shared.hpp>
@@ -79,9 +79,8 @@ int main(int argc, char *argv[]){
//------------------------------------------------------------------
//-- make the usrp source test blocks
//------------------------------------------------------------------
- boost::shared_ptr<uhd_usrp_source> usrp_source = uhd_make_usrp_source(
- device_addr, uhd::stream_args_t("fc32")
- );
+ gr::uhd::usrp_source::sptr usrp_source = gr::uhd::usrp_source::make
+ (device_addr, uhd::stream_args_t("fc32"));
usrp_source->set_samp_rate(samp_rate);
usrp_source->set_center_freq(center_freq);
@@ -95,9 +94,8 @@ int main(int argc, char *argv[]){
//------------------------------------------------------------------
//-- make the usrp sink test blocks
//------------------------------------------------------------------
- boost::shared_ptr<uhd_usrp_sink> usrp_sink = uhd_make_usrp_sink(
- device_addr, uhd::stream_args_t("fc32")
- );
+ gr::uhd::usrp_sink::sptr usrp_sink = gr::uhd::usrp_sink::make
+ (device_addr, uhd::stream_args_t("fc32"));
usrp_sink->set_samp_rate(samp_rate);
usrp_sink->set_center_freq(center_freq);
const uhd::time_spec_t time_now = usrp_sink->get_time_now();
diff --git a/gr-uhd/examples/grc/uhd_dpsk_mod.grc b/gr-uhd/examples/grc/uhd_dpsk_mod.grc
index 18ae9c3db7..9caafbb6ac 100644
--- a/gr-uhd/examples/grc/uhd_dpsk_mod.grc
+++ b/gr-uhd/examples/grc/uhd_dpsk_mod.grc
@@ -281,10 +281,10 @@
</param>
</block>
<block>
- <key>gr_multiply_const_vxx</key>
+ <key>blocks_multiply_const_vxx</key>
<param>
<key>id</key>
- <value>gr_multiply_const_vxx_0</value>
+ <value>blocks_multiply_const_vxx_0</value>
</param>
<param>
<key>_enabled</key>
@@ -2218,7 +2218,7 @@
<sink_key>0</sink_key>
</connection>
<connection>
- <source_block_id>gr_multiply_const_vxx_0</source_block_id>
+ <source_block_id>blocks_multiply_const_vxx_0</source_block_id>
<sink_block_id>uhd_usrp_sink_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
@@ -2231,7 +2231,7 @@
</connection>
<connection>
<source_block_id>digital_dxpsk_mod_0</source_block_id>
- <sink_block_id>gr_multiply_const_vxx_0</sink_block_id>
+ <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
diff --git a/gr-uhd/examples/grc/uhd_two_tone_loopback.grc b/gr-uhd/examples/grc/uhd_two_tone_loopback.grc
index 8bcbc07927..1884dd3ebf 100644
--- a/gr-uhd/examples/grc/uhd_two_tone_loopback.grc
+++ b/gr-uhd/examples/grc/uhd_two_tone_loopback.grc
@@ -1,6 +1,65 @@
<?xml version='1.0' encoding='ASCII'?>
<flow_graph>
- <timestamp>Sat Oct 8 15:27:04 2011</timestamp>
+ <timestamp>Sat Nov 10 14:55:26 2012</timestamp>
+ <block>
+ <key>options</key>
+ <param>
+ <key>id</key>
+ <value>uhd_two_tone_loopback</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>title</key>
+ <value>UHD Loopback - 2 Tone</value>
+ </param>
+ <param>
+ <key>author</key>
+ <value>Example</value>
+ </param>
+ <param>
+ <key>description</key>
+ <value>Loopback test</value>
+ </param>
+ <param>
+ <key>window_size</key>
+ <value>1280, 1024</value>
+ </param>
+ <param>
+ <key>generate_options</key>
+ <value>wx_gui</value>
+ </param>
+ <param>
+ <key>category</key>
+ <value>Custom</value>
+ </param>
+ <param>
+ <key>run_options</key>
+ <value>prompt</value>
+ </param>
+ <param>
+ <key>run</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>max_nouts</key>
+ <value>0</value>
+ </param>
+ <param>
+ <key>realtime_scheduling</key>
+ <value></value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(10, 10)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
<block>
<key>parameter</key>
<param>
@@ -177,53 +236,10 @@
</param>
</block>
<block>
- <key>gr_sig_source_x</key>
- <param>
- <key>id</key>
- <value>gr_sig_source_x</value>
- </param>
- <param>
- <key>_enabled</key>
- <value>True</value>
- </param>
- <param>
- <key>type</key>
- <value>complex</value>
- </param>
- <param>
- <key>samp_rate</key>
- <value>samp_rate</value>
- </param>
- <param>
- <key>waveform</key>
- <value>gr.GR_COS_WAVE</value>
- </param>
- <param>
- <key>freq</key>
- <value>tone1</value>
- </param>
- <param>
- <key>amp</key>
- <value>tone_ampl</value>
- </param>
- <param>
- <key>offset</key>
- <value>0</value>
- </param>
- <param>
- <key>_coordinate</key>
- <value>(258, 136)</value>
- </param>
- <param>
- <key>_rotation</key>
- <value>0</value>
- </param>
- </block>
- <block>
- <key>gr_sig_source_x</key>
+ <key>uhd_usrp_sink</key>
<param>
<key>id</key>
- <value>gr_sig_source_x0</value>
+ <value>uhd_usrp_sink_0</value>
</param>
<param>
<key>_enabled</key>
@@ -231,160 +247,122 @@
</param>
<param>
<key>type</key>
- <value>complex</value>
- </param>
- <param>
- <key>samp_rate</key>
- <value>samp_rate</value>
- </param>
- <param>
- <key>waveform</key>
- <value>gr.GR_COS_WAVE</value>
- </param>
- <param>
- <key>freq</key>
- <value>tone2</value>
+ <value>fc32</value>
</param>
<param>
- <key>amp</key>
- <value>tone_ampl</value>
- </param>
- <param>
- <key>offset</key>
- <value>0</value>
- </param>
- <param>
- <key>_coordinate</key>
- <value>(259, 248)</value>
- </param>
- <param>
- <key>_rotation</key>
- <value>0</value>
- </param>
- </block>
- <block>
- <key>gr_noise_source_x</key>
- <param>
- <key>id</key>
- <value>gr_noise_source_x</value>
- </param>
- <param>
- <key>_enabled</key>
- <value>True</value>
+ <key>otw</key>
+ <value></value>
</param>
<param>
- <key>type</key>
- <value>complex</value>
+ <key>stream_args</key>
+ <value></value>
</param>
<param>
- <key>noise_type</key>
- <value>gr.GR_GAUSSIAN</value>
+ <key>dev_addr</key>
+ <value>address0</value>
</param>
<param>
- <key>amp</key>
- <value>noise_ampl</value>
+ <key>sync</key>
+ <value></value>
</param>
<param>
- <key>seed</key>
- <value>42</value>
+ <key>clock_rate</key>
+ <value>0.0</value>
</param>
<param>
- <key>_coordinate</key>
- <value>(279, 364)</value>
+ <key>num_mboards</key>
+ <value>1</value>
</param>
<param>
- <key>_rotation</key>
- <value>0</value>
+ <key>clock_source0</key>
+ <value></value>
</param>
- </block>
- <block>
- <key>uhd_usrp_sink</key>
<param>
- <key>id</key>
- <value>uhd_usrp_sink_0</value>
+ <key>time_source0</key>
+ <value></value>
</param>
<param>
- <key>_enabled</key>
- <value>True</value>
+ <key>sd_spec0</key>
+ <value></value>
</param>
<param>
- <key>type</key>
- <value>complex</value>
+ <key>clock_source1</key>
+ <value></value>
</param>
<param>
- <key>dev_addr</key>
- <value>address0</value>
+ <key>time_source1</key>
+ <value></value>
</param>
<param>
- <key>sync</key>
+ <key>sd_spec1</key>
<value></value>
</param>
<param>
- <key>clock_rate</key>
- <value>0.0</value>
+ <key>clock_source2</key>
+ <value></value>
</param>
<param>
- <key>num_mboards</key>
- <value>1</value>
+ <key>time_source2</key>
+ <value></value>
</param>
<param>
- <key>ref_source0</key>
+ <key>sd_spec2</key>
<value></value>
</param>
<param>
- <key>sd_spec0</key>
+ <key>clock_source3</key>
<value></value>
</param>
<param>
- <key>ref_source1</key>
+ <key>time_source3</key>
<value></value>
</param>
<param>
- <key>sd_spec1</key>
+ <key>sd_spec3</key>
<value></value>
</param>
<param>
- <key>ref_source2</key>
+ <key>clock_source4</key>
<value></value>
</param>
<param>
- <key>sd_spec2</key>
+ <key>time_source4</key>
<value></value>
</param>
<param>
- <key>ref_source3</key>
+ <key>sd_spec4</key>
<value></value>
</param>
<param>
- <key>sd_spec3</key>
+ <key>clock_source5</key>
<value></value>
</param>
<param>
- <key>ref_source4</key>
+ <key>time_source5</key>
<value></value>
</param>
<param>
- <key>sd_spec4</key>
+ <key>sd_spec5</key>
<value></value>
</param>
<param>
- <key>ref_source5</key>
+ <key>clock_source6</key>
<value></value>
</param>
<param>
- <key>sd_spec5</key>
+ <key>time_source6</key>
<value></value>
</param>
<param>
- <key>ref_source6</key>
+ <key>sd_spec6</key>
<value></value>
</param>
<param>
- <key>sd_spec6</key>
+ <key>clock_source7</key>
<value></value>
</param>
<param>
- <key>ref_source7</key>
+ <key>time_source7</key>
<value></value>
</param>
<param>
@@ -1242,7 +1220,15 @@
</param>
<param>
<key>type</key>
- <value>complex</value>
+ <value>fc32</value>
+ </param>
+ <param>
+ <key>otw</key>
+ <value></value>
+ </param>
+ <param>
+ <key>stream_args</key>
+ <value></value>
</param>
<param>
<key>dev_addr</key>
@@ -1261,7 +1247,11 @@
<value>1</value>
</param>
<param>
- <key>ref_source0</key>
+ <key>clock_source0</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source0</key>
<value></value>
</param>
<param>
@@ -1269,7 +1259,11 @@
<value></value>
</param>
<param>
- <key>ref_source1</key>
+ <key>clock_source1</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source1</key>
<value></value>
</param>
<param>
@@ -1277,7 +1271,11 @@
<value></value>
</param>
<param>
- <key>ref_source2</key>
+ <key>clock_source2</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source2</key>
<value></value>
</param>
<param>
@@ -1285,7 +1283,11 @@
<value></value>
</param>
<param>
- <key>ref_source3</key>
+ <key>clock_source3</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source3</key>
<value></value>
</param>
<param>
@@ -1293,7 +1295,11 @@
<value></value>
</param>
<param>
- <key>ref_source4</key>
+ <key>clock_source4</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source4</key>
<value></value>
</param>
<param>
@@ -1301,7 +1307,11 @@
<value></value>
</param>
<param>
- <key>ref_source5</key>
+ <key>clock_source5</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source5</key>
<value></value>
</param>
<param>
@@ -1309,7 +1319,11 @@
<value></value>
</param>
<param>
- <key>ref_source6</key>
+ <key>clock_source6</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source6</key>
<value></value>
</param>
<param>
@@ -1317,7 +1331,11 @@
<value></value>
</param>
<param>
- <key>ref_source7</key>
+ <key>clock_source7</key>
+ <value></value>
+ </param>
+ <param>
+ <key>time_source7</key>
<value></value>
</param>
<param>
@@ -1964,10 +1982,10 @@
</param>
</block>
<block>
- <key>gr_add_xx</key>
+ <key>wxgui_fftsink2</key>
<param>
<key>id</key>
- <value>gr_add_xx</value>
+ <value>wxgui_fftsink2</value>
</param>
<param>
<key>_enabled</key>
@@ -1978,71 +1996,76 @@
<value>complex</value>
</param>
<param>
- <key>num_inputs</key>
- <value>3</value>
+ <key>title</key>
+ <value>FFT Plot</value>
</param>
<param>
- <key>vlen</key>
- <value>1</value>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
</param>
<param>
- <key>_coordinate</key>
- <value>(529, 172)</value>
+ <key>baseband_freq</key>
+ <value>0</value>
</param>
<param>
- <key>_rotation</key>
- <value>0</value>
+ <key>y_per_div</key>
+ <value>10</value>
</param>
- </block>
- <block>
- <key>options</key>
<param>
- <key>id</key>
- <value>uhd_two_tone_loopback</value>
+ <key>y_divs</key>
+ <value>10</value>
</param>
<param>
- <key>_enabled</key>
- <value>True</value>
+ <key>ref_level</key>
+ <value>0</value>
</param>
<param>
- <key>title</key>
- <value>UHD Loopback - 2 Tone</value>
+ <key>ref_scale</key>
+ <value>2.0</value>
</param>
<param>
- <key>author</key>
- <value>Example</value>
+ <key>fft_size</key>
+ <value>512*2</value>
</param>
<param>
- <key>description</key>
- <value>Loopback test</value>
+ <key>fft_rate</key>
+ <value>15</value>
</param>
<param>
- <key>window_size</key>
- <value>1280, 1024</value>
+ <key>peak_hold</key>
+ <value>False</value>
</param>
<param>
- <key>generate_options</key>
- <value>wx_gui</value>
+ <key>average</key>
+ <value>False</value>
</param>
<param>
- <key>category</key>
- <value>Custom</value>
+ <key>avg_alpha</key>
+ <value>0</value>
</param>
<param>
- <key>run_options</key>
- <value>prompt</value>
+ <key>win</key>
+ <value>window.blackmanharris</value>
</param>
<param>
- <key>run</key>
- <value>True</value>
+ <key>win_size</key>
+ <value></value>
</param>
<param>
- <key>realtime_scheduling</key>
+ <key>grid_pos</key>
+ <value>1, 2, 2, 4</value>
+ </param>
+ <param>
+ <key>notebook</key>
<value></value>
</param>
<param>
+ <key>freqvar</key>
+ <value>None</value>
+ </param>
+ <param>
<key>_coordinate</key>
- <value>(10, 10)</value>
+ <value>(1114, 264)</value>
</param>
<param>
<key>_rotation</key>
@@ -2050,86 +2073,120 @@
</param>
</block>
<block>
- <key>wxgui_fftsink2</key>
+ <key>parameter</key>
<param>
<key>id</key>
- <value>wxgui_fftsink2</value>
+ <value>samp_rate</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
+ <key>label</key>
+ <value>Sample Rate</value>
+ </param>
+ <param>
+ <key>value</key>
+ <value>500e3</value>
+ </param>
+ <param>
<key>type</key>
- <value>complex</value>
+ <value>eng_float</value>
</param>
<param>
- <key>title</key>
- <value>FFT Plot</value>
+ <key>short_id</key>
+ <value>s</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(539, 11)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>analog_sig_source_x</key>
+ <param>
+ <key>id</key>
+ <value>analog_sig_source_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
+ </param>
+ <param>
+ <key>type</key>
+ <value>complex</value>
</param>
<param>
<key>samp_rate</key>
<value>samp_rate</value>
</param>
<param>
- <key>baseband_freq</key>
- <value>0</value>
+ <key>waveform</key>
+ <value>analog.GR_COS_WAVE</value>
</param>
<param>
- <key>y_per_div</key>
- <value>10</value>
+ <key>freq</key>
+ <value>tone1</value>
</param>
<param>
- <key>y_divs</key>
- <value>10</value>
+ <key>amp</key>
+ <value>tone_ampl</value>
</param>
<param>
- <key>ref_level</key>
+ <key>offset</key>
<value>0</value>
</param>
<param>
- <key>ref_scale</key>
- <value>2.0</value>
+ <key>_coordinate</key>
+ <value>(264, 136)</value>
</param>
<param>
- <key>fft_size</key>
- <value>512*2</value>
+ <key>_rotation</key>
+ <value>0</value>
</param>
+ </block>
+ <block>
+ <key>analog_sig_source_x</key>
<param>
- <key>fft_rate</key>
- <value>15</value>
+ <key>id</key>
+ <value>analog_sig_source_x_1</value>
</param>
<param>
- <key>peak_hold</key>
- <value>False</value>
+ <key>_enabled</key>
+ <value>True</value>
</param>
<param>
- <key>average</key>
- <value>False</value>
+ <key>type</key>
+ <value>complex</value>
</param>
<param>
- <key>avg_alpha</key>
- <value>0</value>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
</param>
<param>
- <key>win</key>
- <value>window.blackmanharris</value>
+ <key>waveform</key>
+ <value>analog.GR_COS_WAVE</value>
</param>
<param>
- <key>win_size</key>
- <value></value>
+ <key>freq</key>
+ <value>tone2</value>
</param>
<param>
- <key>grid_pos</key>
- <value>1, 2, 2, 4</value>
+ <key>amp</key>
+ <value>tone_ampl</value>
</param>
<param>
- <key>notebook</key>
- <value></value>
+ <key>offset</key>
+ <value>0</value>
</param>
<param>
<key>_coordinate</key>
- <value>(1114, 264)</value>
+ <value>(265, 247)</value>
</param>
<param>
<key>_rotation</key>
@@ -2137,34 +2194,65 @@
</param>
</block>
<block>
- <key>parameter</key>
+ <key>blocks_add_xx</key>
<param>
<key>id</key>
- <value>samp_rate</value>
+ <value>blocks_add_xx</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
- <key>label</key>
- <value>Sample Rate</value>
+ <key>type</key>
+ <value>complex</value>
</param>
<param>
- <key>value</key>
- <value>500e3</value>
+ <key>num_inputs</key>
+ <value>3</value>
+ </param>
+ <param>
+ <key>vlen</key>
+ <value>1</value>
+ </param>
+ <param>
+ <key>_coordinate</key>
+ <value>(529, 172)</value>
+ </param>
+ <param>
+ <key>_rotation</key>
+ <value>0</value>
+ </param>
+ </block>
+ <block>
+ <key>analog_noise_source_x</key>
+ <param>
+ <key>id</key>
+ <value>analog_noise_source_x_0</value>
+ </param>
+ <param>
+ <key>_enabled</key>
+ <value>True</value>
</param>
<param>
<key>type</key>
- <value>eng_float</value>
+ <value>complex</value>
</param>
<param>
- <key>short_id</key>
- <value>s</value>
+ <key>noise_type</key>
+ <value>analog.GR_GAUSSIAN</value>
+ </param>
+ <param>
+ <key>amp</key>
+ <value>noise_ampl</value>
+ </param>
+ <param>
+ <key>seed</key>
+ <value>-42</value>
</param>
<param>
<key>_coordinate</key>
- <value>(539, 11)</value>
+ <value>(288, 359)</value>
</param>
<param>
<key>_rotation</key>
@@ -2172,33 +2260,33 @@
</param>
</block>
<connection>
- <source_block_id>gr_noise_source_x</source_block_id>
- <sink_block_id>gr_add_xx</sink_block_id>
+ <source_block_id>blocks_add_xx</source_block_id>
+ <sink_block_id>uhd_usrp_sink_0</sink_block_id>
<source_key>0</source_key>
- <sink_key>2</sink_key>
+ <sink_key>0</sink_key>
</connection>
<connection>
- <source_block_id>gr_sig_source_x0</source_block_id>
- <sink_block_id>gr_add_xx</sink_block_id>
+ <source_block_id>uhd_usrp_source_0</source_block_id>
+ <sink_block_id>wxgui_fftsink2</sink_block_id>
<source_key>0</source_key>
- <sink_key>1</sink_key>
+ <sink_key>0</sink_key>
</connection>
<connection>
- <source_block_id>gr_sig_source_x</source_block_id>
- <sink_block_id>gr_add_xx</sink_block_id>
+ <source_block_id>analog_sig_source_x_0</source_block_id>
+ <sink_block_id>blocks_add_xx</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
- <source_block_id>gr_add_xx</source_block_id>
- <sink_block_id>uhd_usrp_sink_0</sink_block_id>
+ <source_block_id>analog_sig_source_x_1</source_block_id>
+ <sink_block_id>blocks_add_xx</sink_block_id>
<source_key>0</source_key>
- <sink_key>0</sink_key>
+ <sink_key>1</sink_key>
</connection>
<connection>
- <source_block_id>uhd_usrp_source_0</source_block_id>
- <sink_block_id>wxgui_fftsink2</sink_block_id>
+ <source_block_id>analog_noise_source_x_0</source_block_id>
+ <sink_block_id>blocks_add_xx</sink_block_id>
<source_key>0</source_key>
- <sink_key>0</sink_key>
+ <sink_key>2</sink_key>
</connection>
</flow_graph>
diff --git a/gr-uhd/examples/grc/uhd_tx_dpsk.grc b/gr-uhd/examples/grc/uhd_tx_dpsk.grc
index 281ba84295..38318bef4b 100644
--- a/gr-uhd/examples/grc/uhd_tx_dpsk.grc
+++ b/gr-uhd/examples/grc/uhd_tx_dpsk.grc
@@ -1035,10 +1035,10 @@
</param>
</block>
<block>
- <key>gr_multiply_const_vxx</key>
+ <key>blocks_multiply_const_vxx</key>
<param>
<key>id</key>
- <value>gr_multiply_const_vxx_0</value>
+ <value>blocks_multiply_const_vxx_0</value>
</param>
<param>
<key>_enabled</key>
@@ -1214,20 +1214,20 @@
<sink_key>0</sink_key>
</connection>
<connection>
- <source_block_id>gr_multiply_const_vxx_0</source_block_id>
+ <source_block_id>blocks_multiply_const_vxx_0</source_block_id>
<sink_block_id>wxgui_fftsink2_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
- <source_block_id>gr_multiply_const_vxx_0</source_block_id>
+ <source_block_id>blocks_multiply_const_vxx_0</source_block_id>
<sink_block_id>uhd_usrp_sink_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>digital_dxpsk_mod_0</source_block_id>
- <sink_block_id>gr_multiply_const_vxx_0</sink_block_id>
+ <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
diff --git a/gr-uhd/examples/grc/uhd_wbfm_receive.grc b/gr-uhd/examples/grc/uhd_wbfm_receive.grc
index 7f14123f2e..943e82cf31 100644
--- a/gr-uhd/examples/grc/uhd_wbfm_receive.grc
+++ b/gr-uhd/examples/grc/uhd_wbfm_receive.grc
@@ -347,10 +347,10 @@
</param>
</block>
<block>
- <key>gr_multiply_const_vxx</key>
+ <key>blocks_multiply_const_vxx</key>
<param>
<key>id</key>
- <value>gr_multiply_const_vxx</value>
+ <value>blocks_multiply_const_vxx</value>
</param>
<param>
<key>_enabled</key>
@@ -1373,14 +1373,14 @@
</param>
</block>
<connection>
- <source_block_id>gr_multiply_const_vxx</source_block_id>
+ <source_block_id>blocks_multiply_const_vxx</source_block_id>
<sink_block_id>audio_sink</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>blks2_wfm_rcv</source_block_id>
- <sink_block_id>gr_multiply_const_vxx</sink_block_id>
+ <sink_block_id>blocks_multiply_const_vxx</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
diff --git a/gr-uhd/examples/python/fm_tx4.py b/gr-uhd/examples/python/fm_tx4.py
index f412ffb5dc..e4cf3ded24 100755
--- a/gr-uhd/examples/python/fm_tx4.py
+++ b/gr-uhd/examples/python/fm_tx4.py
@@ -34,7 +34,8 @@ audio_to_file.py
from gnuradio import gr, eng_notation
from gnuradio import uhd
-from gnuradio import blks2
+from gnuradio import analog
+from gnuradio import blocks
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import math
@@ -62,19 +63,19 @@ class pipeline(gr.hier_block2):
sys.exit(1)
print audio_rate, if_rate
- fmtx = blks2.nbfm_tx (audio_rate, if_rate, max_dev=5e3, tau=75e-6)
+ fmtx = analog.nbfm_tx(audio_rate, if_rate, max_dev=5e3, tau=75e-6)
# Local oscillator
- lo = gr.sig_source_c (if_rate, # sample rate
- gr.GR_SIN_WAVE, # waveform type
- lo_freq, #frequency
- 1.0, # amplitude
- 0) # DC Offset
- mixer = gr.multiply_cc ()
+ lo = analog.sig_source_c(if_rate, # sample rate
+ analog.GR_SIN_WAVE, # waveform type
+ lo_freq, # frequency
+ 1.0, # amplitude
+ 0) # DC Offset
+ mixer = blocks.multiply_cc()
- self.connect (src, fmtx, (mixer, 0))
- self.connect (lo, (mixer, 1))
- self.connect (mixer, self)
+ self.connect(src, fmtx, (mixer, 0))
+ self.connect(lo, (mixer, 1))
+ self.connect(mixer, self)
class fm_tx_block(stdgui2.std_top_block):
def __init__(self, frame, panel, vbox, argv):
@@ -141,7 +142,7 @@ class fm_tx_block(stdgui2.std_top_block):
self.set_gain(options.gain)
self.set_freq(options.freq)
- self.sum = gr.add_cc ()
+ self.sum = blocks.add_cc ()
# Instantiate N NBFM channels
step = 25e3
@@ -153,7 +154,7 @@ class fm_tx_block(stdgui2.std_top_block):
self.audio_rate, self.usrp_rate)
self.connect(t, (self.sum, i))
- self.gain = gr.multiply_const_cc (1.0 / options.nchannels)
+ self.gain = blocks.multiply_const_cc (1.0 / options.nchannels)
# connect it all
self.connect (self.sum, self.gain)
@@ -179,7 +180,8 @@ class fm_tx_block(stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
Tuning is a two step process. First we ask the front-end to
diff --git a/gr-uhd/examples/python/fm_tx_2_daughterboards.py b/gr-uhd/examples/python/fm_tx_2_daughterboards.py
index b5763e8e19..b4958b8596 100755
--- a/gr-uhd/examples/python/fm_tx_2_daughterboards.py
+++ b/gr-uhd/examples/python/fm_tx_2_daughterboards.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -30,7 +30,10 @@ Side A is 600 Hz tone.
Side B is 350 + 440 Hz tones.
"""
-from gnuradio import gr, uhd, blks2
+from gnuradio import gr, uhd
+from gnuradio import filter
+from gnuradio import analog
+from gnuradio import blocks
from gnuradio.eng_notation import num_to_str, str_to_num
from gnuradio.eng_option import eng_option
from optparse import OptionParser
@@ -47,11 +50,11 @@ class example_signal_0(gr.hier_block2):
gr.io_signature(0, 0, 0), # Input signature
gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
- src = gr.sig_source_c (sample_rate, # sample rate
- gr.GR_SIN_WAVE, # waveform type
- 600, # frequency
- 1.0, # amplitude
- 0) # DC Offset
+ src = analog.sig_source_c(sample_rate, # sample rate
+ analog.GR_SIN_WAVE, # waveform type
+ 600, # frequency
+ 1.0, # amplitude
+ 0) # DC Offset
self.connect(src, self)
@@ -65,18 +68,18 @@ class example_signal_1(gr.hier_block2):
gr.io_signature(0, 0, 0), # Input signature
gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
- src0 = gr.sig_source_c (sample_rate, # sample rate
- gr.GR_SIN_WAVE, # waveform type
- 350, # frequency
- 1.0, # amplitude
- 0) # DC Offset
-
- src1 = gr.sig_source_c (sample_rate, # sample rate
- gr.GR_SIN_WAVE, # waveform type
- 440, # frequency
- 1.0, # amplitude
- 0) # DC Offset
- sum = gr.add_cc()
+ src0 = analog.sig_source_c(sample_rate, # sample rate
+ analog.GR_SIN_WAVE, # waveform type
+ 350, # frequency
+ 1.0, # amplitude
+ 0) # DC Offset
+
+ src1 = analog.sig_source_c(sample_rate, # sample rate
+ analog.GR_SIN_WAVE, # waveform type
+ 440, # frequency
+ 1.0, # amplitude
+ 0) # DC Offset
+ sum = blocks.add_cc()
self.connect(src0, (sum, 0))
self.connect(src1, (sum, 1))
self.connect(sum, self)
@@ -86,7 +89,7 @@ class my_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
- usage="%prog: [options] tx-freq0 tx-freq1"
+ usage = "%prog: [options] tx-freq0 tx-freq1"
parser = OptionParser (option_class=eng_option, usage=usage)
parser.add_option("-a", "--args", type="string", default="",
help="UHD device address args [default=%default]")
@@ -152,13 +155,13 @@ class my_top_block(gr.top_block):
sig0 = example_signal_0(self.usrp_rate)
sig1 = example_signal_1(self.usrp_rate)
- intl = gr.interleave(gr.sizeof_gr_complex)
+ intl = blocks.interleave(gr.sizeof_gr_complex)
self.connect(sig0, (intl, 0))
self.connect(sig1, (intl, 1))
# Correct for any difference in requested and actual rates
rrate = self.usrp_rate / dev_rate
- resamp = blks2.pfb_arb_resampler_ccf(rrate)
+ resamp = filter.pfb.arb_resampler_ccf(rrate)
# and wire them up
self.connect(intl, resamp, self.u)
@@ -184,8 +187,9 @@ class my_top_block(gr.top_block):
"""
Set the center frequency we're interested in.
- @param side: 0 = side A, 1 = side B
- @param target_freq: frequency in Hz
+ Args:
+ side: 0 = side A, 1 = side B
+ target_freq: frequency in Hz
@rtype: bool
"""
diff --git a/gr-uhd/examples/python/max_power.py b/gr-uhd/examples/python/max_power.py
index 5d23f16afc..79fe120641 100755
--- a/gr-uhd/examples/python/max_power.py
+++ b/gr-uhd/examples/python/max_power.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2004,2007,2011 Free Software Foundation, Inc.
+# Copyright 2004,2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -26,6 +26,7 @@ Setup USRP for maximum power consumption.
from gnuradio import gr
+from gnuradio import analog
from gnuradio import uhd
from gnuradio.eng_option import eng_option
from optparse import OptionParser
@@ -63,9 +64,9 @@ class build_block(gr.top_block):
self.u_tx = uhd.usrp_sink(device_addr=args, stream_args=stream_args)
self.u_tx.set_samp_rate(MAX_RATE)
- self.tx_src0 = gr.sig_source_c(self.u_tx.get_samp_rate(),
- gr.GR_CONST_WAVE,
- 0, 1.0, 0)
+ self.tx_src0 = analog.sig_source_c(self.u_tx.get_samp_rate(),
+ analog.GR_CONST_WAVE,
+ 0, 1.0, 0)
# Get dboard gain range and select maximum
tx_gain_range = self.u_tx.get_gain_range()
@@ -94,7 +95,7 @@ class build_block(gr.top_block):
self.u_rx = uhd.usrp_source(device_addr=args,
io_type=uhd.io_type.COMPLEX_FLOAT32,
num_channels=rx_nchan)
- self.rx_dst0 = gr.null_sink (gr.sizeof_gr_complex)
+ self.rx_dst0 = gr.null_sink(gr.sizeof_gr_complex)
self.u_rx.set_samp_rate(MAX_RATE)
diff --git a/gr-uhd/examples/python/usrp_am_mw_rcv.py b/gr-uhd/examples/python/usrp_am_mw_rcv.py
index 02863b32fd..eebbd7c041 100755
--- a/gr-uhd/examples/python/usrp_am_mw_rcv.py
+++ b/gr-uhd/examples/python/usrp_am_mw_rcv.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,10 +20,12 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, eng_notation, optfir
+from gnuradio import gr, eng_notation
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio import audio
from gnuradio import uhd
-from gnuradio import blks2
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form
@@ -96,36 +98,36 @@ class wfm_rx_block (stdgui2.std_top_block):
# Resample signal to exactly self.usrp_rate
# FIXME: make one of the follow-on filters an arb resampler
rrate = usrp_rate / dev_rate
- self.resamp = blks2.pfb_arb_resampler_ccf(rrate)
+ self.resamp = filter.pfb.arb_resampler_ccf(rrate)
- chan_filt_coeffs = gr.firdes.low_pass_2 (1, # gain
- usrp_rate, # sampling rate
- 8e3, # passband cutoff
- 4e3, # transition bw
- 60) # stopband attenuation
+ chan_filt_coeffs = filter.firdes.low_pass_2(1, # gain
+ usrp_rate, # sampling rate
+ 8e3, # passband cutoff
+ 4e3, # transition bw
+ 60) # stopband attenuation
if self.use_IF:
# Turn If to baseband and filter.
- self.chan_filt = gr.freq_xlating_fir_filter_ccf (chanfilt_decim,
- chan_filt_coeffs,
- self.IF_freq,
- usrp_rate)
+ self.chan_filt = filter.freq_xlating_fir_filter_ccf(chanfilt_decim,
+ chan_filt_coeffs,
+ self.IF_freq,
+ usrp_rate)
else:
- self.chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs)
+ self.chan_filt = filter.fir_filter_ccf(chanfilt_decim, chan_filt_coeffs)
- self.agc = gr.agc_cc(0.1, 1, 1, 100000)
- self.am_demod = gr.complex_to_mag()
- self.volume_control = gr.multiply_const_ff(self.vol)
+ self.agc = analog.agc_cc(0.1, 1, 1, 100000)
+ self.am_demod = blocks.complex_to_mag()
+ self.volume_control = blocks.multiply_const_ff(self.vol)
- audio_filt_coeffs = gr.firdes.low_pass_2 (1, # gain
- demod_rate, # sampling rate
- 8e3, # passband cutoff
- 2e3, # transition bw
- 60) # stopband attenuation
- self.audio_filt=gr.fir_filter_fff(audio_decim, audio_filt_coeffs)
+ audio_filt_coeffs = filter.firdes.low_pass_2(1, # gain
+ demod_rate, # sampling rate
+ 8e3, # passband cutoff
+ 2e3, # transition bw
+ 60) # stopband attenuation
+ self.audio_filt = filter.fir_filter_fff(audio_decim, audio_filt_coeffs)
# sound card as final sink
- self.audio_sink = audio.sink (int (audio_rate),
+ self.audio_sink = audio.sink(int (audio_rate),
options.audio_output,
False) # ok_to_block
@@ -276,7 +278,8 @@ class wfm_rx_block (stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
r = self.u.set_center_freq(target_freq + self.IF_freq, 0)
diff --git a/gr-uhd/examples/python/usrp_nbfm_ptt.py b/gr-uhd/examples/python/usrp_nbfm_ptt.py
index 791b8cb990..76e1f47c3c 100755
--- a/gr-uhd/examples/python/usrp_nbfm_ptt.py
+++ b/gr-uhd/examples/python/usrp_nbfm_ptt.py
@@ -25,7 +25,10 @@ import sys
import wx
from optparse import OptionParser
-from gnuradio import gr, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import analog
+from gnuradio import blocks
+from gnuradio import filter
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import stdgui2, fftsink2, scopesink2, slider, form
@@ -300,32 +303,32 @@ class transmit_path(gr.hier_block2):
self.normal_gain = 32000
self.audio = audio.source(int(self.audio_rate), audio_input)
- self.audio_amp = gr.multiply_const_ff(self.audio_gain)
+ self.audio_amp = blocks.multiply_const_ff(self.audio_gain)
- lpf = gr.firdes.low_pass (1, # gain
- self.audio_rate, # sampling rate
- 3800, # low pass cutoff freq
- 300, # width of trans. band
- gr.firdes.WIN_HANN) # filter type
+ lpf = filter.firdes.low_pass(1, # gain
+ self.audio_rate, # sampling rate
+ 3800, # low pass cutoff freq
+ 300, # width of trans. band
+ filter.firdes.WIN_HANN) # filter type
- hpf = gr.firdes.high_pass (1, # gain
- self.audio_rate, # sampling rate
- 325, # low pass cutoff freq
- 50, # width of trans. band
- gr.firdes.WIN_HANN) # filter type
+ hpf = filter.firdes.high_pass(1, # gain
+ self.audio_rate, # sampling rate
+ 325, # low pass cutoff freq
+ 50, # width of trans. band
+ filter.firdes.WIN_HANN) # filter type
audio_taps = convolve(array(lpf),array(hpf))
- self.audio_filt = gr.fir_filter_fff(1,audio_taps)
+ self.audio_filt = filter.fir_filter_fff(1,audio_taps)
- self.pl = blks2.ctcss_gen_f(self.audio_rate,123.0)
- self.add_pl = gr.add_ff()
+ self.pl = analog.ctcss_gen_f(self.audio_rate,123.0)
+ self.add_pl = blocks.add_ff()
self.connect(self.pl,(self.add_pl,1))
- self.fmtx = blks2.nbfm_tx(self.audio_rate, self.if_rate)
- self.amp = gr.multiply_const_cc (self.normal_gain)
+ self.fmtx = analog.nbfm_tx(self.audio_rate, self.if_rate)
+ self.amp = blocks.multiply_const_cc (self.normal_gain)
rrate = dev_rate / self.if_rate
- self.resamp = blks2.pfb_arb_resampler_ccf(rrate)
+ self.resamp = filter.pfb.arb_resampler_ccf(rrate)
self.connect(self.audio, self.audio_amp, self.audio_filt,
(self.add_pl,0), self.fmtx, self.amp,
@@ -344,7 +347,8 @@ class transmit_path(gr.hier_block2):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
r = self.u.set_center_freq(target_freq)
@@ -387,30 +391,30 @@ class receive_path(gr.hier_block2):
# Create filter to get actual channel we want
nfilts = 32
- chan_coeffs = gr.firdes.low_pass (nfilts, # gain
- nfilts*dev_rate, # sampling rate
- 13e3, # low pass cutoff freq
- 4e3, # width of trans. band
- gr.firdes.WIN_HANN) # filter type
+ chan_coeffs = filter.firdes.low_pass(nfilts, # gain
+ nfilts*dev_rate, # sampling rate
+ 13e3, # low pass cutoff freq
+ 4e3, # width of trans. band
+ filter.firdes.WIN_HANN) # filter type
rrate = self.quad_rate / dev_rate
- self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
# instantiate the guts of the single channel receiver
- self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate)
+ self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)
# standard squelch block
- self.squelch = blks2.standard_squelch(self.audio_rate)
+ self.squelch = analog.standard_squelch(self.audio_rate)
# audio gain / mute block
- self._audio_gain = gr.multiply_const_ff(1.0)
+ self._audio_gain = blocks.multiply_const_ff(1.0)
# sound card as final sink
- audio_sink = audio.sink (int(self.audio_rate), audio_output)
+ audio_sink = audio.sink(int(self.audio_rate), audio_output)
# now wire it all together
- self.connect (self.u, self.resamp, self.fmrx, self.squelch,
- self._audio_gain, audio_sink)
+ self.connect(self.u, self.resamp, self.fmrx, self.squelch,
+ self._audio_gain, audio_sink)
if gain is None:
# if no gain was specified, use the mid-point in dB
@@ -464,7 +468,8 @@ class receive_path(gr.hier_block2):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
r = self.u.set_center_freq(target_freq)
diff --git a/gr-uhd/examples/python/usrp_nbfm_rcv.py b/gr-uhd/examples/python/usrp_nbfm_rcv.py
index be890f02d8..e3dc7eac6b 100755
--- a/gr-uhd/examples/python/usrp_nbfm_rcv.py
+++ b/gr-uhd/examples/python/usrp_nbfm_rcv.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005,2007,2011 Free Software Foundation, Inc.
+# Copyright 2005,2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,10 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form
@@ -285,24 +288,24 @@ class receive_path(gr.hier_block2):
# Create filter to get actual channel we want
nfilts = 32
- chan_coeffs = gr.firdes.low_pass (nfilts, # gain
- nfilts*dev_rate, # sampling rate
- 8e3, # low pass cutoff freq
- 2e3, # width of trans. band
- gr.firdes.WIN_HANN) # filter type
+ chan_coeffs = filter.firdes.low_pass(nfilts, # gain
+ nfilts*dev_rate, # sampling rate
+ 8e3, # low pass cutoff freq
+ 2e3, # width of trans. band
+ filter.firdes.WIN_HANN) # filter type
rrate = self.quad_rate / dev_rate
- self.resamp = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ self.resamp = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
if USE_SIMPLE_SQUELCH:
- self.squelch = gr.simple_squelch_cc(20)
+ self.squelch = analog.simple_squelch_cc(20)
else:
- self.squelch = blks2.standard_squelch(self.audio_rate)
+ self.squelch = analog.standard_squelch(self.audio_rate)
# instantiate the guts of the single channel receiver
- self.fmrx = blks2.nbfm_rx(self.audio_rate, self.quad_rate)
+ self.fmrx = analog.nbfm_rx(self.audio_rate, self.quad_rate)
# audio gain / mute block
- self._audio_gain = gr.multiply_const_ff(1.0)
+ self._audio_gain = blocks.multiply_const_ff(1.0)
# sound card as final sink
audio_sink = audio.sink (int(self.audio_rate), audio_output)
@@ -357,7 +360,8 @@ class receive_path(gr.hier_block2):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
diff --git a/gr-uhd/examples/python/usrp_spectrum_sense.py b/gr-uhd/examples/python/usrp_spectrum_sense.py
index 32980adbfa..077365a916 100755
--- a/gr-uhd/examples/python/usrp_spectrum_sense.py
+++ b/gr-uhd/examples/python/usrp_spectrum_sense.py
@@ -20,8 +20,11 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, eng_notation, window
+from gnuradio import gr, eng_notation
+from gnuradio import blocks
from gnuradio import audio
+from gnuradio import filter
+from gnuradio import fft
from gnuradio import uhd
from gnuradio.eng_option import eng_option
from optparse import OptionParser
@@ -151,19 +154,19 @@ class my_top_block(gr.top_block):
self.u.set_samp_rate(usrp_rate)
dev_rate = self.u.get_samp_rate()
- s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
+ s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size)
- mywindow = window.blackmanharris(self.fft_size)
- fft = gr.fft_vcc(self.fft_size, True, mywindow)
+ mywindow = filter.window.blackmanharris(self.fft_size)
+ ffter = fft.fft_vcc(self.fft_size, True, mywindow)
power = 0
for tap in mywindow:
power += tap*tap
- c2mag = gr.complex_to_mag_squared(self.fft_size)
+ c2mag = blocks.complex_to_mag_squared(self.fft_size)
# FIXME the log10 primitive is dog slow
- log = gr.nlog10_ff(10, self.fft_size,
- -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
+ log = blocks.nlog10_ff(10, self.fft_size,
+ -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size))
# Set the freq_step to 75% of the actual data throughput.
# This allows us to discard the bins on both ends of the spectrum.
@@ -185,8 +188,8 @@ class my_top_block(gr.top_block):
dwell_delay)
# FIXME leave out the log10 until we speed it up
- #self.connect(self.u, s2v, fft, c2mag, log, stats)
- self.connect(self.u, s2v, fft, c2mag, stats)
+ #self.connect(self.u, s2v, ffter, c2mag, log, stats)
+ self.connect(self.u, s2v, ffter, c2mag, stats)
if options.gain is None:
# if no gain was specified, use the mid-point in dB
@@ -213,7 +216,8 @@ class my_top_block(gr.top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
r = self.u.set_center_freq(target_freq)
diff --git a/gr-uhd/examples/python/usrp_tv_rcv.py b/gr-uhd/examples/python/usrp_tv_rcv.py
index b49a5ea71a..3e612f6a02 100755
--- a/gr-uhd/examples/python/usrp_tv_rcv.py
+++ b/gr-uhd/examples/python/usrp_tv_rcv.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -47,6 +47,8 @@ except:
print "FYI: gr-video-sdl is not installed"
print "realtime SDL video output window will not be available"
from gnuradio import uhd
+from gnuradio import analog
+from gnuradio import blocks
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form
@@ -123,7 +125,7 @@ class tv_rx_block (stdgui2.std_top_block):
if not ((filename is None) or (filename=="usrp")):
# file is data source
self.filesource = gr.file_source(gr.sizeof_short,filename,options.repeat)
- self.istoc = gr.interleaved_short_to_complex()
+ self.istoc = blocks.interleaved_short_to_complex()
self.connect(self.filesource,self.istoc)
self.src=self.istoc
@@ -153,7 +155,7 @@ class tv_rx_block (stdgui2.std_top_block):
self.gain = options.gain
- f2uc=gr.float_to_uchar()
+ f2uc = blocks.float_to_uchar()
# sdl window as final sink
if not (options.pal or options.ntsc):
@@ -194,10 +196,10 @@ class tv_rx_block (stdgui2.std_top_block):
file_sink=gr.file_sink(gr.sizeof_char, options.out_filename)
self.dst =file_sink
- self.agc=gr.agc_cc(1e-7,1.0,1.0) #1e-7
- self.am_demod = gr.complex_to_mag ()
- self.set_blacklevel=gr.add_const_ff(0.0)
- self.invert_and_scale = gr.multiply_const_ff (0.0) #-self.contrast *128.0*255.0/(200.0)
+ self.agc = analog.agc_cc(1e-7,1.0,1.0) #1e-7
+ self.am_demod = blocks.complex_to_mag ()
+ self.set_blacklevel = blocks.add_const_ff(0.0)
+ self.invert_and_scale = blocks.multiply_const_ff (0.0) #-self.contrast *128.0*255.0/(200.0)
# now wire it all together
#sample_rate=options.width*options.height*options.framerate
@@ -223,7 +225,7 @@ class tv_rx_block (stdgui2.std_top_block):
elif process_type=='do_nullsink':
#self.connect (self.src, self.am_demod,self.invert_and_scale,f2uc,video_sink)
- c2r=gr.complex_to_real()
+ c2r=blocks.complex_to_real()
nullsink=gr.null_sink(gr.sizeof_float)
self.connect (self.src, c2r,nullsink) #video_sink)
elif process_type=='do_tv_sync_corr':
@@ -237,14 +239,14 @@ class tv_rx_block (stdgui2.std_top_block):
#Note: this block is not yet in cvs
tv_corr=gr.tv_correlator_ff(frame_size,nframes, search_window,
video_alpha, corr_alpha,debug)
- shift=gr.add_const_ff(-0.7)
+ shift = blocks.add_const_ff(-0.7)
self.connect (self.src, self.agc, self.am_demod, tv_corr,
self.invert_and_scale, self.set_blacklevel,
f2uc, self.dst)
else: # process_type=='do_test_image':
- src_vertical_bars = gr.sig_source_f (usrp_rate, gr.GR_SIN_WAVE,
- 10.0 *usrp_rate/320, 255,128)
+ src_vertical_bars = analog.sig_source_f(usrp_rate, analog.GR_SIN_WAVE,
+ 10.0 *usrp_rate/320, 255,128)
self.connect(src_vertical_bars, f2uc, self.dst)
self._build_gui(vbox, usrp_rate, usrp_rate, usrp_rate)
@@ -403,7 +405,8 @@ class tv_rx_block (stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
Tuning is a two step process. First we ask the front-end to
diff --git a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py
index cfb36222cb..5eef4a00f6 100755
--- a/gr-uhd/examples/python/usrp_tv_rcv_nogui.py
+++ b/gr-uhd/examples/python/usrp_tv_rcv_nogui.py
@@ -35,6 +35,8 @@ development but not yet in cvs.
"""
from gnuradio import gr, eng_notation
+from gnuradio import analog
+from gnuradio import blocks
from gnuradio import audio
from gnuradio import uhd
from gnuradio.eng_option import eng_option
@@ -121,7 +123,7 @@ class my_top_block(gr.top_block):
self.filesource = gr.file_source(gr.sizeof_short,
options.in_filename,
options.repeat)
- self.istoc = gr.interleaved_short_to_complex()
+ self.istoc = blocks.interleaved_short_to_complex()
self.connect(self.filesource,self.istoc)
self.src=self.istoc
else:
@@ -158,11 +160,11 @@ class my_top_block(gr.top_block):
raise SystemExit, 1
- self.agc = gr.agc_cc(1e-7,1.0,1.0) #1e-7
- self.am_demod = gr.complex_to_mag ()
- self.set_blacklevel = gr.add_const_ff(options.brightness +255.0)
- self.invert_and_scale = gr.multiply_const_ff (-options.contrast *128.0*255.0/(200.0))
- self.f2uc = gr.float_to_uchar()
+ self.agc = analog.agc_cc(1e-7,1.0,1.0) #1e-7
+ self.am_demod = blocks.complex_to_mag ()
+ self.set_blacklevel = blocks.add_const_ff(options.brightness +255.0)
+ self.invert_and_scale = blocks.multiply_const_ff(-options.contrast *128.0*255.0/(200.0))
+ self.f2uc = blocks.float_to_uchar()
# sdl window as final sink
if not (options.pal or options.ntsc):
@@ -180,8 +182,7 @@ class my_top_block(gr.top_block):
if filename=="sdl":
#Here comes the tv screen, you have to build and install
- #gr-video-sdl for this (subproject of gnuradio, only in cvs
- #for now)
+ #gr-video-sdl for this (subproject of gnuradio)
try:
video_sink = video_sdl.sink_uc(frames_per_sec, width, height, 0,
show_width,height)
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv.py b/gr-uhd/examples/python/usrp_wfm_rcv.py
index 8ec08260ad..c11c18980c 100755
--- a/gr-uhd/examples/python/usrp_wfm_rcv.py
+++ b/gr-uhd/examples/python/usrp_wfm_rcv.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2009,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2009,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,10 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, optfir, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form
@@ -88,27 +91,27 @@ class wfm_rx_block (stdgui2.std_top_block):
dev_rate = self.u.get_samp_rate()
nfilts = 32
- chan_coeffs = optfir.low_pass (nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 80e3, # passband cutoff
- 115e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
+ chan_coeffs = filter.optfir.low_pass(nfilts, # gain
+ nfilts*usrp_rate, # sampling rate
+ 80e3, # passband cutoff
+ 115e3, # stopband cutoff
+ 0.1, # passband ripple
+ 60) # stopband attenuation
rrate = usrp_rate / dev_rate
- self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
- self.guts = blks2.wfm_rcv (demod_rate, audio_decim)
+ self.guts = analog.wfm_rcv(demod_rate, audio_decim)
- self.volume_control = gr.multiply_const_ff(self.vol)
+ self.volume_control = blocks.multiply_const_ff(self.vol)
# sound card as final sink
- self.audio_sink = audio.sink (int (audio_rate),
- options.audio_output,
- False) # ok_to_block
+ self.audio_sink = audio.sink(int (audio_rate),
+ options.audio_output,
+ False) # ok_to_block
# now wire it all together
- self.connect (self.u, self.chan_filt, self.guts,
- self.volume_control, self.audio_sink)
+ self.connect(self.u, self.chan_filt, self.guts,
+ self.volume_control, self.audio_sink)
self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)
@@ -252,7 +255,8 @@ class wfm_rx_block (stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py
index 83f1726c42..c5b42cbf08 100755
--- a/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py
+++ b/gr-uhd/examples/python/usrp_wfm_rcv2_nogui.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,10 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, optfir, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys
@@ -94,12 +97,12 @@ class wfm_rx_block (gr.top_block):
# taps for channel filter
nfilts = 32
- chan_coeffs = optfir.low_pass (nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 80e3, # passband cutoff
- 115e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
+ chan_coeffs = filter.optfir.low_pass(nfilts, # gain
+ nfilts*usrp_rate, # sampling rate
+ 80e3, # passband cutoff
+ 115e3, # stopband cutoff
+ 0.1, # passband ripple
+ 60) # stopband attenuation
rrate = usrp_rate / dev_rate
# set front end PLL to middle frequency
@@ -111,9 +114,9 @@ class wfm_rx_block (gr.top_block):
options.gain = float(g.start()+g.stop())/2.0
for n in range(2):
- chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
- guts = blks2.wfm_rcv (demod_rate, audio_decim)
- volume_control = gr.multiply_const_ff(self.vol)
+ chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ guts = analog.wfm_rcv(demod_rate, audio_decim)
+ volume_control = blocks.multiply_const_ff(self.vol)
#self.connect((self.di, n), chan_filt)
self.connect((self.u, n), chan_filt)
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py b/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py
index 967a3bd8fc..599f0bc460 100755
--- a/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py
+++ b/gr-uhd/examples/python/usrp_wfm_rcv_fmdet.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,10 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, optfir, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form, scopesink2
@@ -90,31 +93,31 @@ class wfm_rx_block (stdgui2.std_top_block):
dev_rate = self.u.get_samp_rate()
nfilts = 32
- chan_coeffs = gr.firdes.low_pass_2(10*nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 90e3, # passband cutoff
- 30e3, # transition bw
- 70) # stopband attenuation
+ chan_coeffs = filter.firdes.low_pass_2(10*nfilts, # gain
+ nfilts*usrp_rate, # sampling rate
+ 90e3, # passband cutoff
+ 30e3, # transition bw
+ 70) # stopband attenuation
rrate = usrp_rate / dev_rate
- self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
- self.guts = blks2.wfm_rcv_fmdet (demod_rate, audio_decim)
+ self.guts = analog.wfm_rcv_fmdet (demod_rate, audio_decim)
chan_rate = audio_rate / (demod_rate/audio_decim)
- self.rchan_filt = blks2.pfb_arb_resampler_fff(chan_rate)
- self.lchan_filt = blks2.pfb_arb_resampler_fff(chan_rate)
+ self.rchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
+ self.lchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
# FIXME rework {add,multiply}_const_* to handle multiple streams
- self.volume_control_l = gr.multiply_const_ff(self.vol)
- self.volume_control_r = gr.multiply_const_ff(self.vol)
+ self.volume_control_l = blocks.multiply_const_ff(self.vol)
+ self.volume_control_r = blocks.multiply_const_ff(self.vol)
# sound card as final sink
- self.audio_sink = audio.sink (int (audio_rate),
- options.audio_output,
- False) # ok_to_block
+ self.audio_sink = audio.sink(int (audio_rate),
+ options.audio_output,
+ False) # ok_to_block
# now wire it all together
- self.connect (self.u, self.chan_filt, self.guts)
+ self.connect(self.u, self.chan_filt, self.guts)
self.connect((self.guts, 0), self.lchan_filt,
self.volume_control_l, (self.audio_sink,0))
self.connect((self.guts, 1), self.rchan_filt,
@@ -314,7 +317,8 @@ class wfm_rx_block (stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py b/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py
index 9a7558dc77..134df3b39e 100755
--- a/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py
+++ b/gr-uhd/examples/python/usrp_wfm_rcv_nogui.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,10 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, optfir, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser
@@ -82,18 +85,18 @@ class wfm_rx_block (gr.top_block):
dev_rate = self.u.get_samp_rate()
nfilts = 32
- chan_coeffs = optfir.low_pass (nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 80e3, # passband cutoff
- 115e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
+ chan_coeffs = filter.optfir.low_pass(nfilts, # gain
+ nfilts*usrp_rate, # sampling rate
+ 80e3, # passband cutoff
+ 115e3, # stopband cutoff
+ 0.1, # passband ripple
+ 60) # stopband attenuation
rrate = usrp_rate / dev_rate
- self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
- self.guts = blks2.wfm_rcv (demod_rate, audio_decim)
+ self.guts = analog.wfm_rcv(demod_rate, audio_decim)
- self.volume_control = gr.multiply_const_ff(1)
+ self.volume_control = blocks.multiply_const_ff(1)
# sound card as final sink
self.audio_sink = audio.sink(int(audio_rate),
@@ -101,8 +104,8 @@ class wfm_rx_block (gr.top_block):
False) # ok_to_block
# now wire it all together
- self.connect (self.u, self.chan_filt, self.guts,
- self.volume_control, self.audio_sink)
+ self.connect(self.u, self.chan_filt, self.guts,
+ self.volume_control, self.audio_sink)
if options.gain is None:
# if no gain was specified, use the mid-point in dB
@@ -137,7 +140,8 @@ class wfm_rx_block (gr.top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_pll.py b/gr-uhd/examples/python/usrp_wfm_rcv_pll.py
index 874cab4a8e..4b33cdcbb3 100755
--- a/gr-uhd/examples/python/usrp_wfm_rcv_pll.py
+++ b/gr-uhd/examples/python/usrp_wfm_rcv_pll.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,10 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, optfir, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
@@ -90,24 +93,24 @@ class wfm_rx_block (stdgui2.std_top_block):
dev_rate = self.u.get_samp_rate()
nfilts = 32
- chan_coeffs = gr.firdes.low_pass_2 (nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 90e3, # passband cutoff
- 30e3, # stopband cutoff
- 70) # stopband attenuation
+ chan_coeffs = filter.firdes.low_pass_2(nfilts, # gain
+ nfilts*usrp_rate, # sampling rate
+ 90e3, # passband cutoff
+ 30e3, # stopband cutoff
+ 70) # stopband attenuation
rrate = usrp_rate / dev_rate
- self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
- self.guts = blks2.wfm_rcv_pll (demod_rate, audio_decim)
+ self.guts = analog.wfm_rcv_pll(demod_rate, audio_decim)
chan_rate = audio_rate / (demod_rate/audio_decim)
- self.rchan_filt = blks2.pfb_arb_resampler_fff(chan_rate)
- self.lchan_filt = blks2.pfb_arb_resampler_fff(chan_rate)
+ self.rchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
+ self.lchan_filt = filter.pfb.arb_resampler_fff(chan_rate)
# FIXME rework {add,multiply}_const_* to handle multiple streams
- self.volume_control_l = gr.multiply_const_ff(self.vol)
- self.volume_control_r = gr.multiply_const_ff(self.vol)
+ self.volume_control_l = blocks.multiply_const_ff(self.vol)
+ self.volume_control_r = blocks.multiply_const_ff(self.vol)
# sound card as final sink
self.audio_sink = audio.sink (int (audio_rate),
@@ -311,7 +314,8 @@ class wfm_rx_block (stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
diff --git a/gr-uhd/examples/python/usrp_wfm_rcv_sca.py b/gr-uhd/examples/python/usrp_wfm_rcv_sca.py
index 4c6aec23f6..5cbbcd1d8a 100755
--- a/gr-uhd/examples/python/usrp_wfm_rcv_sca.py
+++ b/gr-uhd/examples/python/usrp_wfm_rcv_sca.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2006,2007,2011 Free Software Foundation, Inc.
+# Copyright 2006,2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -50,7 +50,10 @@ OFDM.
"""
-from gnuradio import gr, optfir, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form
@@ -121,19 +124,19 @@ class wfm_rx_sca_block (stdgui2.std_top_block):
dev_rate = self.u.get_samp_rate()
nfilts = 32
- chan_coeffs = optfir.low_pass (nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 100e3, # passband cutoff
- 140e3, # stopband cutoff
- 0.1, # passband ripple
- 60) # stopband attenuation
+ chan_coeffs = filter.optfir.low_pass(nfilts, # gain
+ nfilts*usrp_rate, # sampling rate
+ 100e3, # passband cutoff
+ 140e3, # stopband cutoff
+ 0.1, # passband ripple
+ 60) # stopband attenuation
rrate = usrp_rate / dev_rate
- self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
-
+ self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+
#Create demodulator block for Main FM Channel
max_dev = 75e3
fm_demod_gain = demod_rate/(2*math.pi*max_dev)
- self.fm_demod = gr.quadrature_demod_cf (fm_demod_gain)
+ self.fm_demod = analog.quadrature_demod_cf(fm_demod_gain)
# Note - deemphasis is not applied to the Main FM Channel as
# main audio is not decoded
@@ -143,20 +146,20 @@ class wfm_rx_sca_block (stdgui2.std_top_block):
max_sca_dev = 6e3
# Create filter to get SCA channel we want
- sca_chan_coeffs = gr.firdes.low_pass (1.0, # gain
- demod_rate, # sampling rate
- max_sca_dev, # cutoff freq
- max_sca_dev/3, # trans. band
- gr.firdes.WIN_HANN) # filter type
+ sca_chan_coeffs = filter.firdes.low_pass(1.0, # gain
+ demod_rate, # sampling rate
+ max_sca_dev, # cutoff freq
+ max_sca_dev/3, # trans. band
+ filter.firdes.WIN_HANN) # filter type
- self.ddc = gr.freq_xlating_fir_filter_fcf(sca_chanfilt_decim, # decim rate
- sca_chan_coeffs, # taps
- 0, # freq translation amount (Gets set by the UI)
- demod_rate) # input sample rate
+ self.ddc = filter.freq_xlating_fir_filter_fcf(sca_chanfilt_decim, # decim rate
+ sca_chan_coeffs, # taps
+ 0, # freq translation amount (Gets set by the UI)
+ demod_rate) # input sample rate
#Create demodulator block for SCA Channel
sca_demod_gain = sca_demod_rate/(2*math.pi*max_sca_dev)
- self.fm_demod_sca = gr.quadrature_demod_cf (sca_demod_gain)
+ self.fm_demod_sca = analog.quadrature_demod_cf(sca_demod_gain)
# SCA analog audio is bandwidth limited to 5 KHz
@@ -166,31 +169,31 @@ class wfm_rx_sca_block (stdgui2.std_top_block):
sca_tau = 150e-6
# compute FIR filter taps for SCA audio filter
- audio_coeffs = gr.firdes.low_pass (1.0, # gain
- sca_demod_rate, # sampling rate
- max_sca_audio_freq, # cutoff freq
- max_sca_audio_freq/2.5, # trans. band
- gr.firdes.WIN_HAMMING)
+ audio_coeffs = filter.firdes.low_pass(1.0, # gain
+ sca_demod_rate, # sampling rate
+ max_sca_audio_freq, # cutoff freq
+ max_sca_audio_freq/2.5, # trans. band
+ filter.firdes.WIN_HAMMING)
# input: float; output: float
- self.audio_filter = gr.fir_filter_fff (audio_decim, audio_coeffs)
+ self.audio_filter = filter.fir_filter_fff(audio_decim, audio_coeffs)
# Create deemphasis block that is applied after SCA demodulation
- self.deemph = blks2.fm_deemph (audio_rate, sca_tau)
+ self.deemph = analog.fm_deemph(audio_rate, sca_tau)
- self.volume_control = gr.multiply_const_ff(self.vol)
+ self.volume_control = blocks.multiply_const_ff(self.vol)
# sound card as final sink
- self.audio_sink = audio.sink (int (audio_rate),
- options.audio_output,
- False) # ok_to_block
+ self.audio_sink = audio.sink(int (audio_rate),
+ options.audio_output,
+ False) # ok_to_block
# now wire it all together
- self.connect (self.u, self.chan_filt, self.fm_demod,
- self.ddc, self.fm_demod_sca)
- self.connect (self.fm_demod_sca, self.audio_filter,
- self.deemph, self.volume_control,
- self.audio_sink)
+ self.connect(self.u, self.chan_filt, self.fm_demod,
+ self.ddc, self.fm_demod_sca)
+ self.connect(self.fm_demod_sca, self.audio_filter,
+ self.deemph, self.volume_control,
+ self.audio_sink)
self._build_gui(vbox, usrp_rate, demod_rate, sca_demod_rate, audio_rate)
@@ -357,7 +360,8 @@ class wfm_rx_sca_block (stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
Tuning is a two step process. First we ask the front-end to
diff --git a/gr-uhd/examples/python/usrp_wxapt_rcv.py b/gr-uhd/examples/python/usrp_wxapt_rcv.py
index aaf297089e..305149b682 100755
--- a/gr-uhd/examples/python/usrp_wxapt_rcv.py
+++ b/gr-uhd/examples/python/usrp_wxapt_rcv.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2005-2007,2011 Free Software Foundation, Inc.
+# Copyright 2005-2007,2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -20,7 +20,10 @@
# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, audio, blks2, uhd
+from gnuradio import gr, audio, uhd
+from gnuradio import blocks
+from gnuradio import filter
+from gnuradio import analog
from gnuradio.eng_option import eng_option
from gnuradio.wxgui import slider, powermate
from gnuradio.wxgui import stdgui2, fftsink2, form
@@ -88,24 +91,24 @@ class wxapt_rx_block (stdgui2.std_top_block):
dev_rate = self.u.get_samp_rate()
nfilts = 32
- chan_coeffs = gr.firdes.low_pass_2 (nfilts, # gain
- nfilts*usrp_rate, # sampling rate
- 40e3, # passband cutoff
- 20e3, # transition bw
- 60) # stopband attenuation
+ chan_coeffs = filter.firdes.low_pass_2(nfilts, # gain
+ nfilts*usrp_rate, # sampling rate
+ 40e3, # passband cutoff
+ 20e3, # transition bw
+ 60) # stopband attenuation
rrate = usrp_rate / dev_rate
- self.chan_filt = blks2.pfb_arb_resampler_ccf(rrate, chan_coeffs, nfilts)
+ self.chan_filt = filter.pfb.arb_resampler_ccf(rrate, chan_coeffs, nfilts)
- self.guts = blks2.wfm_rcv (demod_rate, audio_decim)
+ self.guts = analog.wfm_rcv(demod_rate, audio_decim)
- self.volume_control = gr.multiply_const_ff(self.vol)
+ self.volume_control = blocks.multiply_const_ff(self.vol)
# sound card as final sink
- self.audio_sink = audio.sink (int (audio_rate), options.audio_output)
+ self.audio_sink = audio.sink(int (audio_rate), options.audio_output)
# now wire it all together
- self.connect (self.u, self.chan_filt, self.guts,
- self.volume_control, self.audio_sink)
+ self.connect(self.u, self.chan_filt, self.guts,
+ self.volume_control, self.audio_sink)
self._build_gui(vbox, usrp_rate, demod_rate, audio_rate)
@@ -247,7 +250,8 @@ class wxapt_rx_block (stdgui2.std_top_block):
"""
Set the center frequency we're interested in.
- @param target_freq: frequency in Hz
+ Args:
+ target_freq: frequency in Hz
@rypte: bool
"""
diff --git a/gr-uhd/include/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h
deleted file mode 100644
index eaf60fb777..0000000000
--- a/gr-uhd/include/gr_uhd_usrp_sink.h
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright 2010-2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_UHD_USRP_SINK_H
-#define INCLUDED_GR_UHD_USRP_SINK_H
-
-#include <gr_uhd_api.h>
-#include <gr_sync_block.h>
-#include <uhd/usrp/multi_usrp.hpp>
-
-#ifndef INCLUDED_UHD_STREAM_HPP
-namespace uhd{
- struct GR_UHD_API stream_args_t{
- stream_args_t(
- const std::string &cpu = "",
- const std::string &otw = ""
- ){
- cpu_format = cpu;
- otw_format = otw;
- }
- std::string cpu_format;
- std::string otw_format;
- device_addr_t args;
- std::vector<size_t> channels;
- };
-}
-# define INCLUDED_UHD_STREAM_HPP
-#else
-# define GR_UHD_USE_STREAM_API
-#endif
-
-class uhd_usrp_sink;
-
-/*!
- * \brief Make a new USRP sink block.
- * \ingroup uhd_blk
- *
- * The USRP sink block reads a stream and transmits the samples.
- * The sink block also provides API calls for transmitter settings.
- *
- * TX Stream tagging:
- *
- * The following tag keys will be consumed by the work function:
- * - pmt::pmt_string_to_symbol("tx_sob")
- * - pmt::pmt_string_to_symbol("tx_eob")
- * - pmt::pmt_string_to_symbol("tx_time")
- *
- * The sob and eob (start and end of burst) tag values are pmt booleans.
- * When present, burst tags should be set to true (pmt::PMT_T).
- *
- * The timstamp tag value is a pmt tuple of the following:
- * (uint64 seconds, and double fractional seconds).
- *
- * See the UHD manual for more detailed documentation:
- * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
- *
- * \param device_addr the address to identify the hardware
- * \param io_type the desired input data type
- * \param num_channels number of stream from the device
- * \return a new USRP sink block object
- */
-GR_UHD_API boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels
-);
-
-/*!
- * \brief Make a new USRP sink block.
- *
- * The USRP sink block reads a stream and transmits the samples.
- * The sink block also provides API calls for transmitter settings.
- *
- * TX Stream tagging:
- *
- * The following tag keys will be consumed by the work function:
- * - pmt::pmt_string_to_symbol("tx_sob")
- * - pmt::pmt_string_to_symbol("tx_eob")
- * - pmt::pmt_string_to_symbol("tx_time")
- *
- * The sob and eob (start and end of burst) tag values are pmt booleans.
- * When present, burst tags should be set to true (pmt::PMT_T).
- *
- * The timstamp tag value is a pmt tuple of the following:
- * (uint64 seconds, and double fractional seconds).
- *
- * See the UHD manual for more detailed documentation:
- * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
- *
- * \param device_addr the address to identify the hardware
- * \param stream_args the IO format and channel specification
- * \return a new USRP sink block object
- */
-GR_UHD_API boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
- const uhd::device_addr_t &device_addr,
- const uhd::stream_args_t &stream_args
-);
-
-class GR_UHD_API uhd_usrp_sink : virtual public gr_sync_block{
-public:
-
- /*!
- * Set the start time for outgoing samples.
- * To control when samples are transmitted,
- * set this value before starting the flow graph.
- * The value is cleared after each run.
- * When not specified, the start time will be:
- * - Immediately for the one channel case
- * - in the near future for multi-channel
- *
- * \param time the absolute time for transmission to begin
- */
- virtual void set_start_time(const uhd::time_spec_t &time) = 0;
-
- /*!
- * Returns identifying information about this USRP's configuration.
- * Returns motherboard ID, name, and serial.
- * Returns daughterboard TX ID, subdev name and spec, serial, and antenna.
- * \param chan channel index 0 to N-1
- * \return TX info
- */
- virtual uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0;
-
- /*!
- * Set the frontend specification.
- * \param spec the subdev spec markup string
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0;
-
-
- /*!
- * Get the TX frontend specification.
- * \param mboard the motherboard index 0 to M-1
- * \return the frontend specification in use
- */
- virtual std::string get_subdev_spec (size_t mboard = 0) = 0;
-
- /*!
- * Set the sample rate for the usrp device.
- * \param rate a new rate in Sps
- */
- virtual void set_samp_rate(double rate) = 0;
-
- /*!
- * Get the sample rate for the usrp device.
- * This is the actual sample rate and may differ from the rate set.
- * \return the actual rate in Sps
- */
- virtual double get_samp_rate(void) = 0;
-
- /*!
- * Get the possible sample rates for the usrp device.
- * \return a range of rates in Sps
- */
- virtual uhd::meta_range_t get_samp_rates(void) = 0;
-
- /*!
- * Tune the usrp device to the desired center frequency.
- * \param tune_request the tune request instructions
- * \param chan the channel index 0 to N-1
- * \return a tune result with the actual frequencies
- */
- virtual uhd::tune_result_t set_center_freq(
- const uhd::tune_request_t tune_request, size_t chan = 0
- ) = 0;
-
- /*!
- * Tune the usrp device to the desired center frequency.
- * This is a wrapper around set center freq so that in this case,
- * the user can pass a single frequency in the call through swig.
- * \param freq the desired frequency in Hz
- * \param chan the channel index 0 to N-1
- * \return a tune result with the actual frequencies
- */
- uhd::tune_result_t set_center_freq(double freq, size_t chan = 0){
- return set_center_freq(uhd::tune_request_t(freq), chan);
- }
-
- /*!
- * Get the center frequency.
- * \param chan the channel index 0 to N-1
- * \return the frequency in Hz
- */
- virtual double get_center_freq(size_t chan = 0) = 0;
-
- /*!
- * Get the tunable frequency range.
- * \param chan the channel index 0 to N-1
- * \return the frequency range in Hz
- */
- virtual uhd::freq_range_t get_freq_range(size_t chan = 0) = 0;
-
- /*!
- * Set the gain for the dboard.
- * \param gain the gain in dB
- * \param chan the channel index 0 to N-1
- */
- virtual void set_gain(double gain, size_t chan = 0) = 0;
-
- /*!
- * Set the named gain on the dboard.
- * \param gain the gain in dB
- * \param name the name of the gain stage
- * \param chan the channel index 0 to N-1
- */
- virtual void set_gain(double gain, const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Get the actual dboard gain setting.
- * \param chan the channel index 0 to N-1
- * \return the actual gain in dB
- */
- virtual double get_gain(size_t chan = 0) = 0;
-
- /*!
- * Get the actual dboard gain setting of named stage.
- * \param name the name of the gain stage
- * \param chan the channel index 0 to N-1
- * \return the actual gain in dB
- */
- virtual double get_gain(const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Get the actual dboard gain setting of named stage.
- * \param chan the channel index 0 to N-1
- * \return the actual gain in dB
- */
- virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
-
- /*!
- * Get the settable gain range.
- * \param chan the channel index 0 to N-1
- * \return the gain range in dB
- */
- virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
-
- /*!
- * Get the settable gain range.
- * \param name the name of the gain stage
- * \param chan the channel index 0 to N-1
- * \return the gain range in dB
- */
- virtual uhd::gain_range_t get_gain_range(const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Set the antenna to use.
- * \param ant the antenna string
- * \param chan the channel index 0 to N-1
- */
- virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0;
-
- /*!
- * Get the antenna in use.
- * \param chan the channel index 0 to N-1
- * \return the antenna string
- */
- virtual std::string get_antenna(size_t chan = 0) = 0;
-
- /*!
- * Get a list of possible antennas.
- * \param chan the channel index 0 to N-1
- * \return a vector of antenna strings
- */
- virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
-
- /*!
- * Set the bandpass filter on the RF frontend.
- * \param chan the channel index 0 to N-1
- * \param bandwidth the filter bandwidth in Hz
- */
- virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
-
- /*!
- * Set a constant DC offset value.
- * The value is complex to control both I and Q.
- * \param offset the dc offset (1.0 is full-scale)
- * \param chan the channel index 0 to N-1
- */
- virtual void set_dc_offset(const std::complex<double> &offset, size_t chan = 0) = 0;
-
- /*!
- * Set the RX frontend IQ imbalance correction.
- * Use this to adjust the magnitude and phase of I and Q.
- *
- * \param correction the complex correction (1.0 is full-scale)
- * \param chan the channel index 0 to N-1
- */
- virtual void set_iq_balance(const std::complex<double> &correction, size_t chan = 0) = 0;
-
- /*!
- * Get an RF frontend sensor value.
- * \param name the name of the sensor
- * \param chan the channel index 0 to N-1
- * \return a sensor value object
- */
- virtual uhd::sensor_value_t get_sensor(const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Get a list of possible RF frontend sensor names.
- * \param chan the channel index 0 to N-1
- * \return a vector of sensor names
- */
- virtual std::vector<std::string> get_sensor_names(size_t chan = 0) = 0;
-
- //! DEPRECATED use get_sensor
- uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0){
- return this->get_sensor(name, chan);
- }
-
- //! DEPRECATED use get_sensor_names
- std::vector<std::string> get_dboard_sensor_names(size_t chan = 0){
- return this->get_sensor_names(chan);
- }
-
- /*!
- * Get a motherboard sensor value.
- * \param name the name of the sensor
- * \param mboard the motherboard index 0 to M-1
- * \return a sensor value object
- */
- virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
-
- /*!
- * Get a list of possible motherboard sensor names.
- * \param mboard the motherboard index 0 to M-1
- * \return a vector of sensor names
- */
- virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
-
- /*!
- * Set the clock configuration.
- * DEPRECATED for set_time/clock_source.
- * \param clock_config the new configuration
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0;
-
- /*!
- * Set the time source for the usrp device.
- * This sets the method of time synchronization,
- * typically a pulse per second or an encoded time.
- * Typical options for source: external, MIMO.
- * \param source a string representing the time source
- * \param mboard which motherboard to set the config
- */
- virtual void set_time_source(const std::string &source, const size_t mboard = 0) = 0;
-
- /*!
- * Get the currently set time source.
- * \param mboard which motherboard to get the config
- * \return the string representing the time source
- */
- virtual std::string get_time_source(const size_t mboard) = 0;
-
- /*!
- * Get a list of possible time sources.
- * \param mboard which motherboard to get the list
- * \return a vector of strings for possible settings
- */
- virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
-
- /*!
- * Set the clock source for the usrp device.
- * This sets the source for a 10 Mhz reference clock.
- * Typical options for source: internal, external, MIMO.
- * \param source a string representing the clock source
- * \param mboard which motherboard to set the config
- */
- virtual void set_clock_source(const std::string &source, const size_t mboard = 0) = 0;
-
- /*!
- * Get the currently set clock source.
- * \param mboard which motherboard to get the config
- * \return the string representing the clock source
- */
- virtual std::string get_clock_source(const size_t mboard) = 0;
-
- /*!
- * Get a list of possible clock sources.
- * \param mboard which motherboard to get the list
- * \return a vector of strings for possible settings
- */
- virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
-
- /*!
- * Get the master clock rate.
- * \param mboard the motherboard index 0 to M-1
- * \return the clock rate in Hz
- */
- virtual double get_clock_rate(size_t mboard = 0) = 0;
-
- /*!
- * Set the master clock rate.
- * \param rate the new rate in Hz
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
-
- /*!
- * Get the current time registers.
- * \param mboard the motherboard index 0 to M-1
- * \return the current usrp time
- */
- virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
-
- /*!
- * Get the time when the last pps pulse occured.
- * \param mboard the motherboard index 0 to M-1
- * \return the current usrp time
- */
- virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
-
- /*!
- * Sets the time registers immediately.
- * \param time_spec the new time
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
-
- /*!
- * Set the time registers at the next pps.
- * \param time_spec the new time
- */
- virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
-
- /*!
- * Sync the time registers with an unknown pps edge.
- * \param time_spec the new time
- */
- virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
-
- /*!
- * Set the time at which the control commands will take effect.
- *
- * A timed command will back-pressure all subsequent timed commands,
- * assuming that the subsequent commands occur within the time-window.
- * If the time spec is late, the command will be activated upon arrival.
- *
- * \param time_spec the time at which the next command will activate
- * \param mboard which motherboard to set the config
- */
- virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
-
- /*!
- * Clear the command time so future commands are sent ASAP.
- *
- * \param mboard which motherboard to set the config
- */
- virtual void clear_command_time(size_t mboard = 0) = 0;
-
- /*!
- * Get access to the underlying uhd dboard iface object.
- * \return the dboard_iface object
- */
- virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0;
-
- /*!
- * Get access to the underlying uhd device object.
- * \return the multi usrp device object
- */
- virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0;
-
- /*!
- * Perform write on the user configuration register bus. These only exist if
- * the user has implemented custom setting registers in the device FPGA.
- * \param addr 8-bit register address
- * \param data 32-bit register value
- * \param mboard which motherboard to set the user register
- */
- virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = 0) = 0;
-};
-
-#endif /* INCLUDED_GR_UHD_USRP_SINK_H */
diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h
deleted file mode 100644
index 1243ddcc2f..0000000000
--- a/gr-uhd/include/gr_uhd_usrp_source.h
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
- * Copyright 2010-2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_GR_UHD_USRP_SOURCE_H
-#define INCLUDED_GR_UHD_USRP_SOURCE_H
-
-#include <gr_uhd_api.h>
-#include <gr_sync_block.h>
-#include <uhd/usrp/multi_usrp.hpp>
-
-#ifndef INCLUDED_UHD_STREAM_HPP
-namespace uhd{
- struct GR_UHD_API stream_args_t{
- stream_args_t(
- const std::string &cpu = "",
- const std::string &otw = ""
- ){
- cpu_format = cpu;
- otw_format = otw;
- }
- std::string cpu_format;
- std::string otw_format;
- device_addr_t args;
- std::vector<size_t> channels;
- };
-}
-# define INCLUDED_UHD_STREAM_HPP
-#else
-# define GR_UHD_USE_STREAM_API
-#endif
-
-class uhd_usrp_source;
-
-/*!
- * \brief Make a new USRP source block.
- * \ingroup uhd_blk
- *
- * The USRP source block receives samples and writes to a stream.
- * The source block also provides API calls for receiver settings.
- *
- * RX Stream tagging:
- *
- * The following tag keys will be produced by the work function:
- * - pmt::pmt_string_to_symbol("rx_time")
- * - pmt::pmt_string_to_symbol("rx_rate")
- * - pmt::pmt_string_to_symbol("rx_freq")
- *
- * The timstamp tag value is a pmt tuple of the following:
- * (uint64 seconds, and double fractional seconds).
- * A timestamp tag is produced at start() and after overflows.
- *
- * The sample rate and center frequency tags are doubles,
- * representing the sample rate in Sps and frequency in Hz.
- * These tags are produced upon the user changing parameters.
- *
- * See the UHD manual for more detailed documentation:
- * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
- *
- * \param device_addr the address to identify the hardware
- * \param io_type the desired output data type
- * \param num_channels number of stream from the device
- * \return a new USRP source block object
- */
-GR_UHD_API boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels
-);
-
-/*!
- * \brief Make a new USRP source block.
- *
- * The USRP source block receives samples and writes to a stream.
- * The source block also provides API calls for receiver settings.
- *
- * RX Stream tagging:
- *
- * The following tag keys will be produced by the work function:
- * - pmt::pmt_string_to_symbol("rx_time")
- *
- * The timstamp tag value is a pmt tuple of the following:
- * (uint64 seconds, and double fractional seconds).
- * A timestamp tag is produced at start() and after overflows.
- *
- * See the UHD manual for more detailed documentation:
- * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
- *
- * \param device_addr the address to identify the hardware
- * \param stream_args the IO format and channel specification
- * \return a new USRP source block object
- */
-GR_UHD_API boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source(
- const uhd::device_addr_t &device_addr,
- const uhd::stream_args_t &stream_args
-);
-
-class GR_UHD_API uhd_usrp_source : virtual public gr_sync_block{
-public:
-
- /*!
- * Set the start time for incoming samples.
- * To control when samples are received,
- * set this value before starting the flow graph.
- * The value is cleared after each run.
- * When not specified, the start time will be:
- * - Immediately for the one channel case
- * - in the near future for multi-channel
- *
- * \param time the absolute time for reception to begin
- */
- virtual void set_start_time(const uhd::time_spec_t &time) = 0;
-
- /*!
- * *Advanced use only:*
- * Issue a stream command to all channels in this source block.
- *
- * This method is intended to override the default "always on" behavior.
- * After starting the flow graph, the user should call stop() on this block,
- * then issue any desired arbitrary stream_cmd_t structs to the device.
- * The USRP will be able to enqueue several stream commands in the FPGA.
- *
- * \param cmd the stream command to issue to all source channels
- */
- virtual void issue_stream_cmd(const uhd::stream_cmd_t &cmd) = 0;
-
- /*!
- * Returns identifying information about this USRP's configuration.
- * Returns motherboard ID, name, and serial.
- * Returns daughterboard RX ID, subdev name and spec, serial, and antenna.
- * \param chan channel index 0 to N-1
- * \return RX info
- */
- virtual uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0;
-
- /*!
- * Set the frontend specification.
- * \param spec the subdev spec markup string
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0;
-
- /*!
- * Get the RX frontend specification.
- * \param mboard the motherboard index 0 to M-1
- * \return the frontend specification in use
- */
- virtual std::string get_subdev_spec(size_t mboard = 0) = 0;
-
- /*!
- * Set the sample rate for the usrp device.
- * \param rate a new rate in Sps
- */
- virtual void set_samp_rate(double rate) = 0;
-
- /*!
- * Get the sample rate for the usrp device.
- * This is the actual sample rate and may differ from the rate set.
- * \return the actual rate in Sps
- */
- virtual double get_samp_rate(void) = 0;
-
- /*!
- * Get the possible sample rates for the usrp device.
- * \return a range of rates in Sps
- */
- virtual uhd::meta_range_t get_samp_rates(void) = 0;
-
- /*!
- * Tune the usrp device to the desired center frequency.
- * \param tune_request the tune request instructions
- * \param chan the channel index 0 to N-1
- * \return a tune result with the actual frequencies
- */
- virtual uhd::tune_result_t set_center_freq(
- const uhd::tune_request_t tune_request, size_t chan = 0
- ) = 0;
-
- /*!
- * Tune the usrp device to the desired center frequency.
- * This is a wrapper around set center freq so that in this case,
- * the user can pass a single frequency in the call through swig.
- * \param freq the desired frequency in Hz
- * \param chan the channel index 0 to N-1
- * \return a tune result with the actual frequencies
- */
- uhd::tune_result_t set_center_freq(double freq, size_t chan = 0){
- return set_center_freq(uhd::tune_request_t(freq), chan);
- }
-
- /*!
- * Get the center frequency.
- * \param chan the channel index 0 to N-1
- * \return the frequency in Hz
- */
- virtual double get_center_freq(size_t chan = 0) = 0;
-
- /*!
- * Get the tunable frequency range.
- * \param chan the channel index 0 to N-1
- * \return the frequency range in Hz
- */
- virtual uhd::freq_range_t get_freq_range(size_t chan = 0) = 0;
-
- /*!
- * Set the gain for the dboard.
- * \param gain the gain in dB
- * \param chan the channel index 0 to N-1
- */
- virtual void set_gain(double gain, size_t chan = 0) = 0;
-
- /*!
- * Set the named gain on the dboard.
- * \param gain the gain in dB
- * \param name the name of the gain stage
- * \param chan the channel index 0 to N-1
- */
- virtual void set_gain(double gain, const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Get the actual dboard gain setting.
- * \param chan the channel index 0 to N-1
- * \return the actual gain in dB
- */
- virtual double get_gain(size_t chan = 0) = 0;
-
- /*!
- * Get the actual dboard gain setting of named stage.
- * \param name the name of the gain stage
- * \param chan the channel index 0 to N-1
- * \return the actual gain in dB
- */
- virtual double get_gain(const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Get the actual dboard gain setting of named stage.
- * \param chan the channel index 0 to N-1
- * \return the actual gain in dB
- */
- virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
-
- /*!
- * Get the settable gain range.
- * \param chan the channel index 0 to N-1
- * \return the gain range in dB
- */
- virtual uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
-
- /*!
- * Get the settable gain range.
- * \param name the name of the gain stage
- * \param chan the channel index 0 to N-1
- * \return the gain range in dB
- */
- virtual uhd::gain_range_t get_gain_range(const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Set the antenna to use.
- * \param ant the antenna string
- * \param chan the channel index 0 to N-1
- */
- virtual void set_antenna(const std::string &ant, size_t chan = 0) = 0;
-
- /*!
- * Get the antenna in use.
- * \param chan the channel index 0 to N-1
- * \return the antenna string
- */
- virtual std::string get_antenna(size_t chan = 0) = 0;
-
- /*!
- * Get a list of possible antennas.
- * \param chan the channel index 0 to N-1
- * \return a vector of antenna strings
- */
- virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
-
- /*!
- * Set the bandpass filter on the RF frontend.
- * \param bandwidth the filter bandwidth in Hz
- * \param chan the channel index 0 to N-1
- */
- virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
-
- /*!
- * Enable/disable the automatic DC offset correction.
- * The automatic correction subtracts out the long-run average.
- *
- * When disabled, the averaging option operation is halted.
- * Once halted, the average value will be held constant
- * until the user re-enables the automatic correction
- * or overrides the value by manually setting the offset.
- *
- * \param enb true to enable automatic DC offset correction
- * \param chan the channel index 0 to N-1
- */
- virtual void set_auto_dc_offset(const bool enb, size_t chan = 0) = 0;
-
- /*!
- * Set a constant DC offset value.
- * The value is complex to control both I and Q.
- * Only set this when automatic correction is disabled.
- * \param offset the dc offset (1.0 is full-scale)
- * \param chan the channel index 0 to N-1
- */
- virtual void set_dc_offset(const std::complex<double> &offset, size_t chan = 0) = 0;
-
- /*!
- * Set the RX frontend IQ imbalance correction.
- * Use this to adjust the magnitude and phase of I and Q.
- *
- * \param correction the complex correction value
- * \param chan the channel index 0 to N-1
- */
- virtual void set_iq_balance(const std::complex<double> &correction, size_t chan = 0) = 0;
-
- /*!
- * Get a RF frontend sensor value.
- * \param name the name of the sensor
- * \param chan the channel index 0 to N-1
- * \return a sensor value object
- */
- virtual uhd::sensor_value_t get_sensor(const std::string &name, size_t chan = 0) = 0;
-
- /*!
- * Get a list of possible RF frontend sensor names.
- * \param chan the channel index 0 to N-1
- * \return a vector of sensor names
- */
- virtual std::vector<std::string> get_sensor_names(size_t chan = 0) = 0;
-
- //! DEPRECATED use get_sensor
- uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0){
- return this->get_sensor(name, chan);
- }
-
- //! DEPRECATED use get_sensor_names
- std::vector<std::string> get_dboard_sensor_names(size_t chan = 0){
- return this->get_sensor_names(chan);
- }
-
- /*!
- * Get a motherboard sensor value.
- * \param name the name of the sensor
- * \param mboard the motherboard index 0 to M-1
- * \return a sensor value object
- */
- virtual uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0;
-
- /*!
- * Get a list of possible motherboard sensor names.
- * \param mboard the motherboard index 0 to M-1
- * \return a vector of sensor names
- */
- virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
-
- /*!
- * Set the clock configuration.
- * DEPRECATED for set_time/clock_source.
- * \param clock_config the new configuration
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard = 0) = 0;
-
- /*!
- * Set the time source for the usrp device.
- * This sets the method of time synchronization,
- * typically a pulse per second or an encoded time.
- * Typical options for source: external, MIMO.
- * \param source a string representing the time source
- * \param mboard which motherboard to set the config
- */
- virtual void set_time_source(const std::string &source, const size_t mboard = 0) = 0;
-
- /*!
- * Get the currently set time source.
- * \param mboard which motherboard to get the config
- * \return the string representing the time source
- */
- virtual std::string get_time_source(const size_t mboard) = 0;
-
- /*!
- * Get a list of possible time sources.
- * \param mboard which motherboard to get the list
- * \return a vector of strings for possible settings
- */
- virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
-
- /*!
- * Set the clock source for the usrp device.
- * This sets the source for a 10 Mhz reference clock.
- * Typical options for source: internal, external, MIMO.
- * \param source a string representing the clock source
- * \param mboard which motherboard to set the config
- */
- virtual void set_clock_source(const std::string &source, const size_t mboard = 0) = 0;
-
- /*!
- * Get the currently set clock source.
- * \param mboard which motherboard to get the config
- * \return the string representing the clock source
- */
- virtual std::string get_clock_source(const size_t mboard) = 0;
-
- /*!
- * Get a list of possible clock sources.
- * \param mboard which motherboard to get the list
- * \return a vector of strings for possible settings
- */
- virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
-
- /*!
- * Get the master clock rate.
- * \param mboard the motherboard index 0 to M-1
- * \return the clock rate in Hz
- */
- virtual double get_clock_rate(size_t mboard = 0) = 0;
-
- /*!
- * Set the master clock rate.
- * \param rate the new rate in Hz
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
-
- /*!
- * Get the current time registers.
- * \param mboard the motherboard index 0 to M-1
- * \return the current usrp time
- */
- virtual uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
-
- /*!
- * Get the time when the last pps pulse occured.
- * \param mboard the motherboard index 0 to M-1
- * \return the current usrp time
- */
- virtual uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
-
- /*!
- * Sets the time registers immediately.
- * \param time_spec the new time
- * \param mboard the motherboard index 0 to M-1
- */
- virtual void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
-
- /*!
- * Set the time registers at the next pps.
- * \param time_spec the new time
- */
- virtual void set_time_next_pps(const uhd::time_spec_t &time_spec) = 0;
-
- /*!
- * Sync the time registers with an unknown pps edge.
- * \param time_spec the new time
- */
- virtual void set_time_unknown_pps(const uhd::time_spec_t &time_spec) = 0;
-
- /*!
- * Set the time at which the control commands will take effect.
- *
- * A timed command will back-pressure all subsequent timed commands,
- * assuming that the subsequent commands occur within the time-window.
- * If the time spec is late, the command will be activated upon arrival.
- *
- * \param time_spec the time at which the next command will activate
- * \param mboard which motherboard to set the config
- */
- virtual void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
-
- /*!
- * Clear the command time so future commands are sent ASAP.
- *
- * \param mboard which motherboard to set the config
- */
- virtual void clear_command_time(size_t mboard = 0) = 0;
-
- /*!
- * Get access to the underlying uhd dboard iface object.
- * \return the dboard_iface object
- */
- virtual uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0;
-
- /*!
- * Get access to the underlying uhd device object.
- * \return the multi usrp device object
- */
- virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0;
-
- /*!
- * Perform write on the user configuration register bus. These only exist if
- * the user has implemented custom setting registers in the device FPGA.
- * \param addr 8-bit register address
- * \param data 32-bit register value
- * \param mboard which motherboard to set the user register
- */
- virtual void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard = 0) = 0;
-
- /*!
- * Convenience function for finite data acquisition.
- * This is not to be used with the scheduler; rather,
- * one can request samples from the USRP in python.
- * //TODO assumes fc32
- * \param nsamps the number of samples
- * \return a vector of complex float samples
- */
- virtual std::vector<std::complex<float> > finite_acquisition(const size_t nsamps) = 0;
-
- /*!
- * Convenience function for finite data acquisition.
- * This is the multi-channel version of finite_acquisition;
- * This is not to be used with the scheduler; rather,
- * one can request samples from the USRP in python.
- * //TODO assumes fc32
- * \param nsamps the number of samples per channel
- * \return a vector of buffers, where each buffer represents a channel
- */
- virtual std::vector<std::vector<std::complex<float> > > finite_acquisition_v(const size_t nsamps) = 0;
-};
-
-#endif /* INCLUDED_GR_UHD_USRP_SOURCE_H */
diff --git a/gr-uhd/include/CMakeLists.txt b/gr-uhd/include/uhd/CMakeLists.txt
index 27d3d1d369..066487c6ca 100644
--- a/gr-uhd/include/CMakeLists.txt
+++ b/gr-uhd/include/uhd/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2013 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -21,10 +21,10 @@
# Install header files
########################################################################
install(FILES
- gr_uhd_api.h
- gr_uhd_usrp_source.h
- gr_uhd_usrp_sink.h
- gr_uhd_amsg_source.h
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio
+ api.h
+ usrp_source.h
+ usrp_sink.h
+ amsg_source.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/gr_uhd
COMPONENT "uhd_devel"
)
diff --git a/gr-uhd/include/gr_uhd_amsg_source.h b/gr-uhd/include/uhd/amsg_source.h
index f2f21c99f5..819f6edad2 100644
--- a/gr-uhd/include/gr_uhd_amsg_source.h
+++ b/gr-uhd/include/uhd/amsg_source.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2011 Free Software Foundation, Inc.
+ * Copyright 2011,2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,29 +23,37 @@
#ifndef INCLUDED_GR_UHD_AMSG_SOURCE_H
#define INCLUDED_GR_UHD_AMSG_SOURCE_H
-#include <gr_uhd_api.h>
+#include <uhd/api.h>
#include <uhd/usrp/multi_usrp.hpp>
#include <gr_msg_queue.h>
-class uhd_amsg_source;
+namespace gr {
+ namespace uhd {
-/*!
- * \brief Make a new USRP asynchronous message-based source block.
- * \ingroup uhd_blk
- */
-GR_UHD_API boost::shared_ptr<uhd_amsg_source> uhd_make_amsg_source(
- const uhd::device_addr_t &device_addr,
- gr_msg_queue_sptr msgq
-);
-
-class GR_UHD_API uhd_amsg_source{
-public:
- /*!
- * Convert a raw asynchronous message to an asynchronous metatdata object.
- * \return The asynchronous metadata object.
- */
- static uhd::async_metadata_t msg_to_async_metadata_t(const gr_message_sptr msg);
-
-};
+ class uhd_amsg_source;
+
+ class GR_UHD_API amsg_source
+ {
+ public:
+ // gr::uhd::amsg_source::sptr
+ typedef boost::shared_ptr<amsg_source> sptr;
+
+ /*!
+ * \brief Make a new USRP asynchronous message-based source block.
+ * \ingroup uhd_blk
+ */
+ static sptr make(const ::uhd::device_addr_t &device_addr,
+ gr_msg_queue_sptr msgq);
+
+ /*!
+ * Convert a raw asynchronous message to an asynchronous metatdata object.
+ * \return The asynchronous metadata object.
+ */
+ static ::uhd::async_metadata_t
+ msg_to_async_metadata_t(const gr_message_sptr msg);
+ };
+
+ } /* namespace uhd */
+} /* namespace gr */
#endif /* INCLUDED_GR_UHD_AMSG_SOURCE_H */
diff --git a/gr-uhd/include/gr_uhd_api.h b/gr-uhd/include/uhd/api.h
index 106acd8c76..106acd8c76 100644
--- a/gr-uhd/include/gr_uhd_api.h
+++ b/gr-uhd/include/uhd/api.h
diff --git a/gr-uhd/include/uhd/usrp_sink.h b/gr-uhd/include/uhd/usrp_sink.h
new file mode 100644
index 0000000000..c54689241b
--- /dev/null
+++ b/gr-uhd/include/uhd/usrp_sink.h
@@ -0,0 +1,516 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_UHD_USRP_SINK_H
+#define INCLUDED_GR_UHD_USRP_SINK_H
+
+#include <uhd/api.h>
+#include <gr_sync_block.h>
+#include <uhd/usrp/multi_usrp.hpp>
+
+#ifndef INCLUDED_UHD_STREAM_HPP
+namespace uhd {
+ struct GR_UHD_API stream_args_t
+ {
+ stream_args_t(const std::string &cpu = "",
+ const std::string &otw = "")
+ {
+ cpu_format = cpu;
+ otw_format = otw;
+ }
+ std::string cpu_format;
+ std::string otw_format;
+ device_addr_t args;
+ std::vector<size_t> channels;
+ };
+}
+# define INCLUDED_UHD_STREAM_HPP
+#else
+# define GR_UHD_USE_STREAM_API
+#endif
+
+namespace gr {
+ namespace uhd {
+
+ class uhd_usrp_sink;
+
+ class GR_UHD_API usrp_sink : virtual public gr_sync_block
+ {
+ public:
+ // gr::uhd::usrp_sink::sptr
+ typedef boost::shared_ptr<usrp_sink> sptr;
+
+ /*!
+ * \brief Make a new USRP sink block.
+ * \ingroup uhd_blk
+ *
+ * The USRP sink block reads a stream and transmits the samples.
+ * The sink block also provides API calls for transmitter settings.
+ *
+ * TX Stream tagging:
+ *
+ * The following tag keys will be consumed by the work function:
+ * - pmt::string_to_symbol("tx_sob")
+ * - pmt::string_to_symbol("tx_eob")
+ * - pmt::string_to_symbol("tx_time")
+ *
+ * The sob and eob (start and end of burst) tag values are pmt booleans.
+ * When present, burst tags should be set to true (pmt::PMT_T).
+ *
+ * The timstamp tag value is a pmt tuple of the following:
+ * (uint64 seconds, and double fractional seconds).
+ *
+ * See the UHD manual for more detailed documentation:
+ * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
+ *
+ * \param device_addr the address to identify the hardware
+ * \param io_type the desired input data type
+ * \param num_channels number of stream from the device
+ * \return a new USRP sink block object
+ */
+ static sptr make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::io_type_t &io_type,
+ size_t num_channels);
+
+ /*!
+ * \brief Make a new USRP sink block.
+ *
+ * The USRP sink block reads a stream and transmits the samples.
+ * The sink block also provides API calls for transmitter settings.
+ *
+ * TX Stream tagging:
+ *
+ * The following tag keys will be consumed by the work function:
+ * - pmt::string_to_symbol("tx_sob")
+ * - pmt::string_to_symbol("tx_eob")
+ * - pmt::string_to_symbol("tx_time")
+ *
+ * The sob and eob (start and end of burst) tag values are pmt booleans.
+ * When present, burst tags should be set to true (pmt::PMT_T).
+ *
+ * The timstamp tag value is a pmt tuple of the following:
+ * (uint64 seconds, and double fractional seconds).
+ *
+ * See the UHD manual for more detailed documentation:
+ * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
+ *
+ * \param device_addr the address to identify the hardware
+ * \param stream_args the IO format and channel specification
+ * \return a new USRP sink block object
+ */
+ static sptr make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args);
+
+ /*!
+ * Set the start time for outgoing samples.
+ * To control when samples are transmitted,
+ * set this value before starting the flow graph.
+ * The value is cleared after each run.
+ * When not specified, the start time will be:
+ * - Immediately for the one channel case
+ * - in the near future for multi-channel
+ *
+ * \param time the absolute time for transmission to begin
+ */
+ virtual void set_start_time(const ::uhd::time_spec_t &time) = 0;
+
+ /*!
+ * Returns identifying information about this USRP's configuration.
+ * Returns motherboard ID, name, and serial.
+ * Returns daughterboard TX ID, subdev name and spec, serial, and antenna.
+ * \param chan channel index 0 to N-1
+ * \return TX info
+ */
+ virtual ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0;
+
+ /*!
+ * Set the frontend specification.
+ * \param spec the subdev spec markup string
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0;
+
+ /*!
+ * Get the TX frontend specification.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the frontend specification in use
+ */
+ virtual std::string get_subdev_spec (size_t mboard = 0) = 0;
+
+ /*!
+ * Set the sample rate for the usrp device.
+ * \param rate a new rate in Sps
+ */
+ virtual void set_samp_rate(double rate) = 0;
+
+ /*!
+ * Get the sample rate for the usrp device.
+ * This is the actual sample rate and may differ from the rate set.
+ * \return the actual rate in Sps
+ */
+ virtual double get_samp_rate(void) = 0;
+
+ /*!
+ * Get the possible sample rates for the usrp device.
+ * \return a range of rates in Sps
+ */
+ virtual ::uhd::meta_range_t get_samp_rates(void) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * \param tune_request the tune request instructions
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ virtual ::uhd::tune_result_t set_center_freq
+ (const ::uhd::tune_request_t tune_request, size_t chan = 0) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * This is a wrapper around set center freq so that in this case,
+ * the user can pass a single frequency in the call through swig.
+ * \param freq the desired frequency in Hz
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ ::uhd::tune_result_t set_center_freq(double freq, size_t chan = 0)
+ {
+ return set_center_freq(::uhd::tune_request_t(freq), chan);
+ }
+
+ /*!
+ * Get the center frequency.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency in Hz
+ */
+ virtual double get_center_freq(size_t chan = 0) = 0;
+
+ /*!
+ * Get the tunable frequency range.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency range in Hz
+ */
+ virtual ::uhd::freq_range_t get_freq_range(size_t chan = 0) = 0;
+
+ /*!
+ * Set the gain for the dboard.
+ * \param gain the gain in dB
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(double gain, size_t chan = 0) = 0;
+
+ /*!
+ * Set the named gain on the dboard.
+ * \param gain the gain in dB
+ * \param name the name of the gain stage
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(double gain,
+ const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual double get_gain(size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting of named stage.
+ * \param name the name of the gain stage
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual double get_gain(const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting of named stage.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual ::uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param name the name of the gain stage
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual ::uhd::gain_range_t get_gain_range(const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Set the antenna to use.
+ * \param ant the antenna string
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_antenna(const std::string &ant,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get the antenna in use.
+ * \param chan the channel index 0 to N-1
+ * \return the antenna string
+ */
+ virtual std::string get_antenna(size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible antennas.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of antenna strings
+ */
+ virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
+
+ /*!
+ * Set the bandpass filter on the RF frontend.
+ * \param chan the channel index 0 to N-1
+ * \param bandwidth the filter bandwidth in Hz
+ */
+ virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
+
+ /*!
+ * Set a constant DC offset value.
+ * The value is complex to control both I and Q.
+ * \param offset the dc offset (1.0 is full-scale)
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_dc_offset(const std::complex<double> &offset,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Set the RX frontend IQ imbalance correction.
+ * Use this to adjust the magnitude and phase of I and Q.
+ *
+ * \param correction the complex correction (1.0 is full-scale)
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_iq_balance(const std::complex<double> &correction,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get an RF frontend sensor value.
+ * \param name the name of the sensor
+ * \param chan the channel index 0 to N-1
+ * \return a sensor value object
+ */
+ virtual ::uhd::sensor_value_t get_sensor(const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible RF frontend sensor names.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_sensor_names(size_t chan = 0) = 0;
+
+ //! DEPRECATED use get_sensor
+ ::uhd::sensor_value_t get_dboard_sensor(const std::string &name,
+ size_t chan = 0)
+ {
+ return this->get_sensor(name, chan);
+ }
+
+ //! DEPRECATED use get_sensor_names
+ std::vector<std::string> get_dboard_sensor_names(size_t chan = 0)
+ {
+ return this->get_sensor_names(chan);
+ }
+
+ /*!
+ * Get a motherboard sensor value.
+ * \param name the name of the sensor
+ * \param mboard the motherboard index 0 to M-1
+ * \return a sensor value object
+ */
+ virtual ::uhd::sensor_value_t get_mboard_sensor(const std::string &name,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Get a list of possible motherboard sensor names.
+ * \param mboard the motherboard index 0 to M-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
+
+ /*!
+ * Set the clock configuration.
+ * DEPRECATED for set_time/clock_source.
+ * \param clock_config the new configuration
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_config(const ::uhd::clock_config_t &clock_config,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Set the time source for the usrp device.
+ * This sets the method of time synchronization,
+ * typically a pulse per second or an encoded time.
+ * Typical options for source: external, MIMO.
+ * \param source a string representing the time source
+ * \param mboard which motherboard to set the config
+ */
+ virtual void set_time_source(const std::string &source,
+ const size_t mboard = 0) = 0;
+
+ /*!
+ * Get the currently set time source.
+ * \param mboard which motherboard to get the config
+ * \return the string representing the time source
+ */
+ virtual std::string get_time_source(const size_t mboard) = 0;
+
+ /*!
+ * Get a list of possible time sources.
+ * \param mboard which motherboard to get the list
+ * \return a vector of strings for possible settings
+ */
+ virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
+
+ /*!
+ * Set the clock source for the usrp device.
+ * This sets the source for a 10 Mhz reference clock.
+ * Typical options for source: internal, external, MIMO.
+ * \param source a string representing the clock source
+ * \param mboard which motherboard to set the config
+ */
+ virtual void set_clock_source(const std::string &source,
+ const size_t mboard = 0) = 0;
+
+ /*!
+ * Get the currently set clock source.
+ * \param mboard which motherboard to get the config
+ * \return the string representing the clock source
+ */
+ virtual std::string get_clock_source(const size_t mboard) = 0;
+
+ /*!
+ * Get a list of possible clock sources.
+ * \param mboard which motherboard to get the list
+ * \return a vector of strings for possible settings
+ */
+ virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
+
+ /*!
+ * Get the master clock rate.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the clock rate in Hz
+ */
+ virtual double get_clock_rate(size_t mboard = 0) = 0;
+
+ /*!
+ * Set the master clock rate.
+ * \param rate the new rate in Hz
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
+
+ /*!
+ * Get the current time registers.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the current usrp time
+ */
+ virtual ::uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
+
+ /*!
+ * Get the time when the last pps pulse occured.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the current usrp time
+ */
+ virtual ::uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
+
+ /*!
+ * Sets the time registers immediately.
+ * \param time_spec the new time
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_time_now(const ::uhd::time_spec_t &time_spec, size_t mboard = 0) = 0;
+
+ /*!
+ * Set the time registers at the next pps.
+ * \param time_spec the new time
+ */
+ virtual void set_time_next_pps(const ::uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Sync the time registers with an unknown pps edge.
+ * \param time_spec the new time
+ */
+ virtual void set_time_unknown_pps(const ::uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Set the time at which the control commands will take effect.
+ *
+ * A timed command will back-pressure all subsequent timed commands,
+ * assuming that the subsequent commands occur within the time-window.
+ * If the time spec is late, the command will be activated upon arrival.
+ *
+ * \param time_spec the time at which the next command will activate
+ * \param mboard which motherboard to set the config
+ */
+ virtual void set_command_time(const ::uhd::time_spec_t &time_spec,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Clear the command time so future commands are sent ASAP.
+ *
+ * \param mboard which motherboard to set the config
+ */
+ virtual void clear_command_time(size_t mboard = 0) = 0;
+
+ /*!
+ * Get access to the underlying uhd dboard iface object.
+ * \return the dboard_iface object
+ */
+ virtual ::uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0;
+
+ /*!
+ * Get access to the underlying uhd device object.
+ * \return the multi usrp device object
+ */
+ virtual ::uhd::usrp::multi_usrp::sptr get_device(void) = 0;
+
+ /*!
+ * Perform write on the user configuration register bus. These
+ * only exist if the user has implemented custom setting
+ * registers in the device FPGA.
+ * \param addr 8-bit register address
+ * \param data 32-bit register value
+ * \param mboard which motherboard to set the user register
+ */
+ virtual void set_user_register(const uint8_t addr,
+ const uint32_t data,
+ size_t mboard = 0) = 0;
+ };
+
+ } /* namespace uhd */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UHD_USRP_SINK_H */
diff --git a/gr-uhd/include/uhd/usrp_source.h b/gr-uhd/include/uhd/usrp_source.h
new file mode 100644
index 0000000000..2348e73ed4
--- /dev/null
+++ b/gr-uhd/include/uhd/usrp_source.h
@@ -0,0 +1,567 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_UHD_USRP_SOURCE_H
+#define INCLUDED_GR_UHD_USRP_SOURCE_H
+
+#include <uhd/api.h>
+#include <gr_sync_block.h>
+#include <uhd/usrp/multi_usrp.hpp>
+
+#ifndef INCLUDED_UHD_STREAM_HPP
+namespace uhd {
+ struct GR_UHD_API stream_args_t
+ {
+ stream_args_t(const std::string &cpu = "",
+ const std::string &otw = "")
+ {
+ cpu_format = cpu;
+ otw_format = otw;
+ }
+ std::string cpu_format;
+ std::string otw_format;
+ device_addr_t args;
+ std::vector<size_t> channels;
+ };
+}
+# define INCLUDED_UHD_STREAM_HPP
+#else
+# define GR_UHD_USE_STREAM_API
+#endif
+
+namespace gr {
+ namespace uhd {
+
+ class uhd_usrp_source;
+
+ class GR_UHD_API usrp_source : virtual public gr_sync_block
+ {
+ public:
+ // gr::uhd::usrp_source::sptr
+ typedef boost::shared_ptr<usrp_source> sptr;
+
+ /*!
+ * \brief Make a new USRP source block.
+ * \ingroup uhd_blk
+ *
+ * The USRP source block receives samples and writes to a stream.
+ * The source block also provides API calls for receiver settings.
+ *
+ * RX Stream tagging:
+ *
+ * The following tag keys will be produced by the work function:
+ * - pmt::string_to_symbol("rx_time")
+ * - pmt::string_to_symbol("rx_rate")
+ * - pmt::string_to_symbol("rx_freq")
+ *
+ * The timstamp tag value is a pmt tuple of the following:
+ * (uint64 seconds, and double fractional seconds).
+ * A timestamp tag is produced at start() and after overflows.
+ *
+ * The sample rate and center frequency tags are doubles,
+ * representing the sample rate in Sps and frequency in Hz.
+ * These tags are produced upon the user changing parameters.
+ *
+ * See the UHD manual for more detailed documentation:
+ * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
+ *
+ * \param device_addr the address to identify the hardware
+ * \param io_type the desired output data type
+ * \param num_channels number of stream from the device
+ * \return a new USRP source block object
+ */
+ static sptr make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::io_type_t &io_type,
+ size_t num_channels);
+
+ /*!
+ * \brief Make a new USRP source block.
+ *
+ * The USRP source block receives samples and writes to a stream.
+ * The source block also provides API calls for receiver settings.
+ *
+ * RX Stream tagging:
+ *
+ * The following tag keys will be produced by the work function:
+ * - pmt::string_to_symbol("rx_time")
+ *
+ * The timstamp tag value is a pmt tuple of the following:
+ * (uint64 seconds, and double fractional seconds).
+ * A timestamp tag is produced at start() and after overflows.
+ *
+ * See the UHD manual for more detailed documentation:
+ * http://code.ettus.com/redmine/ettus/projects/uhd/wiki
+ *
+ * \param device_addr the address to identify the hardware
+ * \param stream_args the IO format and channel specification
+ * \return a new USRP source block object
+ */
+ static sptr make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args);
+
+ /*!
+ * Set the start time for incoming samples.
+ * To control when samples are received,
+ * set this value before starting the flow graph.
+ * The value is cleared after each run.
+ * When not specified, the start time will be:
+ * - Immediately for the one channel case
+ * - in the near future for multi-channel
+ *
+ * \param time the absolute time for reception to begin
+ */
+ virtual void set_start_time(const ::uhd::time_spec_t &time) = 0;
+
+ /*!
+ * *Advanced use only:*
+ * Issue a stream command to all channels in this source block.
+ *
+ * This method is intended to override the default "always on"
+ * behavior. After starting the flow graph, the user should
+ * call stop() on this block, then issue any desired arbitrary
+ * stream_cmd_t structs to the device. The USRP will be able to
+ * enqueue several stream commands in the FPGA.
+ *
+ * \param cmd the stream command to issue to all source channels
+ */
+ virtual void issue_stream_cmd(const ::uhd::stream_cmd_t &cmd) = 0;
+
+ /*!
+ * Returns identifying information about this USRP's configuration.
+ * Returns motherboard ID, name, and serial.
+ * Returns daughterboard RX ID, subdev name and spec, serial, and antenna.
+ * \param chan channel index 0 to N-1
+ * \return RX info
+ */
+ virtual ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan = 0) = 0;
+
+ /*!
+ * Set the frontend specification.
+ * \param spec the subdev spec markup string
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_subdev_spec(const std::string &spec, size_t mboard = 0) = 0;
+
+ /*!
+ * Get the RX frontend specification.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the frontend specification in use
+ */
+ virtual std::string get_subdev_spec(size_t mboard = 0) = 0;
+
+ /*!
+ * Set the sample rate for the usrp device.
+ * \param rate a new rate in Sps
+ */
+ virtual void set_samp_rate(double rate) = 0;
+
+ /*!
+ * Get the sample rate for the usrp device.
+ * This is the actual sample rate and may differ from the rate set.
+ * \return the actual rate in Sps
+ */
+ virtual double get_samp_rate(void) = 0;
+
+ /*!
+ * Get the possible sample rates for the usrp device.
+ * \return a range of rates in Sps
+ */
+ virtual ::uhd::meta_range_t get_samp_rates(void) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * \param tune_request the tune request instructions
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ virtual ::uhd::tune_result_t set_center_freq
+ (const ::uhd::tune_request_t tune_request, size_t chan = 0) = 0;
+
+ /*!
+ * Tune the usrp device to the desired center frequency.
+ * This is a wrapper around set center freq so that in this case,
+ * the user can pass a single frequency in the call through swig.
+ * \param freq the desired frequency in Hz
+ * \param chan the channel index 0 to N-1
+ * \return a tune result with the actual frequencies
+ */
+ ::uhd::tune_result_t set_center_freq(double freq, size_t chan = 0)
+ {
+ return set_center_freq(::uhd::tune_request_t(freq), chan);
+ }
+
+ /*!
+ * Get the center frequency.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency in Hz
+ */
+ virtual double get_center_freq(size_t chan = 0) = 0;
+
+ /*!
+ * Get the tunable frequency range.
+ * \param chan the channel index 0 to N-1
+ * \return the frequency range in Hz
+ */
+ virtual ::uhd::freq_range_t get_freq_range(size_t chan = 0) = 0;
+
+ /*!
+ * Set the gain for the dboard.
+ * \param gain the gain in dB
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(double gain, size_t chan = 0) = 0;
+
+ /*!
+ * Set the named gain on the dboard.
+ * \param gain the gain in dB
+ * \param name the name of the gain stage
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_gain(double gain,
+ const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual double get_gain(size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting of named stage.
+ * \param name the name of the gain stage
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual double get_gain(const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get the actual dboard gain setting of named stage.
+ * \param chan the channel index 0 to N-1
+ * \return the actual gain in dB
+ */
+ virtual std::vector<std::string> get_gain_names(size_t chan = 0) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual ::uhd::gain_range_t get_gain_range(size_t chan = 0) = 0;
+
+ /*!
+ * Get the settable gain range.
+ * \param name the name of the gain stage
+ * \param chan the channel index 0 to N-1
+ * \return the gain range in dB
+ */
+ virtual ::uhd::gain_range_t get_gain_range(const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Set the antenna to use.
+ * \param ant the antenna string
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_antenna(const std::string &ant,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get the antenna in use.
+ * \param chan the channel index 0 to N-1
+ * \return the antenna string
+ */
+ virtual std::string get_antenna(size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible antennas.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of antenna strings
+ */
+ virtual std::vector<std::string> get_antennas(size_t chan = 0) = 0;
+
+ /*!
+ * Set the bandpass filter on the RF frontend.
+ * \param bandwidth the filter bandwidth in Hz
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0;
+
+ /*!
+ * Enable/disable the automatic DC offset correction.
+ * The automatic correction subtracts out the long-run average.
+ *
+ * When disabled, the averaging option operation is halted.
+ * Once halted, the average value will be held constant until
+ * the user re-enables the automatic correction or overrides the
+ * value by manually setting the offset.
+ *
+ * \param enb true to enable automatic DC offset correction
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_auto_dc_offset(const bool enb, size_t chan = 0) = 0;
+
+ /*!
+ * Set a constant DC offset value.
+ * The value is complex to control both I and Q.
+ * Only set this when automatic correction is disabled.
+ * \param offset the dc offset (1.0 is full-scale)
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_dc_offset(const std::complex<double> &offset, size_t chan = 0) = 0;
+
+ /*!
+ * Set the RX frontend IQ imbalance correction.
+ * Use this to adjust the magnitude and phase of I and Q.
+ *
+ * \param correction the complex correction value
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_iq_balance(const std::complex<double> &correction,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get a RF frontend sensor value.
+ * \param name the name of the sensor
+ * \param chan the channel index 0 to N-1
+ * \return a sensor value object
+ */
+ virtual ::uhd::sensor_value_t get_sensor(const std::string &name,
+ size_t chan = 0) = 0;
+
+ /*!
+ * Get a list of possible RF frontend sensor names.
+ * \param chan the channel index 0 to N-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_sensor_names(size_t chan = 0) = 0;
+
+ //! DEPRECATED use get_sensor
+ ::uhd::sensor_value_t get_dboard_sensor(const std::string &name,
+ size_t chan = 0)
+ {
+ return this->get_sensor(name, chan);
+ }
+
+ //! DEPRECATED use get_sensor_names
+ std::vector<std::string> get_dboard_sensor_names(size_t chan = 0)
+ {
+ return this->get_sensor_names(chan);
+ }
+
+ /*!
+ * Get a motherboard sensor value.
+ * \param name the name of the sensor
+ * \param mboard the motherboard index 0 to M-1
+ * \return a sensor value object
+ */
+ virtual ::uhd::sensor_value_t get_mboard_sensor(const std::string &name,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Get a list of possible motherboard sensor names.
+ * \param mboard the motherboard index 0 to M-1
+ * \return a vector of sensor names
+ */
+ virtual std::vector<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0;
+
+ /*!
+ * Set the clock configuration.
+ * DEPRECATED for set_time/clock_source.
+ * \param clock_config the new configuration
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_config(const ::uhd::clock_config_t &clock_config,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Set the time source for the usrp device.
+ * This sets the method of time synchronization,
+ * typically a pulse per second or an encoded time.
+ * Typical options for source: external, MIMO.
+ * \param source a string representing the time source
+ * \param mboard which motherboard to set the config
+ */
+ virtual void set_time_source(const std::string &source,
+ const size_t mboard = 0) = 0;
+
+ /*!
+ * Get the currently set time source.
+ * \param mboard which motherboard to get the config
+ * \return the string representing the time source
+ */
+ virtual std::string get_time_source(const size_t mboard) = 0;
+
+ /*!
+ * Get a list of possible time sources.
+ * \param mboard which motherboard to get the list
+ * \return a vector of strings for possible settings
+ */
+ virtual std::vector<std::string> get_time_sources(const size_t mboard) = 0;
+
+ /*!
+ * Set the clock source for the usrp device.
+ * This sets the source for a 10 Mhz reference clock.
+ * Typical options for source: internal, external, MIMO.
+ * \param source a string representing the clock source
+ * \param mboard which motherboard to set the config
+ */
+ virtual void set_clock_source(const std::string &source,
+ const size_t mboard = 0) = 0;
+
+ /*!
+ * Get the currently set clock source.
+ * \param mboard which motherboard to get the config
+ * \return the string representing the clock source
+ */
+ virtual std::string get_clock_source(const size_t mboard) = 0;
+
+ /*!
+ * Get a list of possible clock sources.
+ * \param mboard which motherboard to get the list
+ * \return a vector of strings for possible settings
+ */
+ virtual std::vector<std::string> get_clock_sources(const size_t mboard) = 0;
+
+ /*!
+ * Get the master clock rate.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the clock rate in Hz
+ */
+ virtual double get_clock_rate(size_t mboard = 0) = 0;
+
+ /*!
+ * Set the master clock rate.
+ * \param rate the new rate in Hz
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_clock_rate(double rate, size_t mboard = 0) = 0;
+
+ /*!
+ * Get the current time registers.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the current usrp time
+ */
+ virtual ::uhd::time_spec_t get_time_now(size_t mboard = 0) = 0;
+
+ /*!
+ * Get the time when the last pps pulse occured.
+ * \param mboard the motherboard index 0 to M-1
+ * \return the current usrp time
+ */
+ virtual ::uhd::time_spec_t get_time_last_pps(size_t mboard = 0) = 0;
+
+ /*!
+ * Sets the time registers immediately.
+ * \param time_spec the new time
+ * \param mboard the motherboard index 0 to M-1
+ */
+ virtual void set_time_now(const ::uhd::time_spec_t &time_spec,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Set the time registers at the next pps.
+ * \param time_spec the new time
+ */
+ virtual void set_time_next_pps(const ::uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Sync the time registers with an unknown pps edge.
+ * \param time_spec the new time
+ */
+ virtual void set_time_unknown_pps(const ::uhd::time_spec_t &time_spec) = 0;
+
+ /*!
+ * Set the time at which the control commands will take effect.
+ *
+ * A timed command will back-pressure all subsequent timed
+ * commands, assuming that the subsequent commands occur within
+ * the time-window. If the time spec is late, the command will
+ * be activated upon arrival.
+ *
+ * \param time_spec the time at which the next command will activate
+ * \param mboard which motherboard to set the config
+ */
+ virtual void set_command_time(const ::uhd::time_spec_t &time_spec,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Clear the command time so future commands are sent ASAP.
+ *
+ * \param mboard which motherboard to set the config
+ */
+ virtual void clear_command_time(size_t mboard = 0) = 0;
+
+ /*!
+ * Get access to the underlying uhd dboard iface object.
+ * \return the dboard_iface object
+ */
+ virtual ::uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan = 0) = 0;
+
+ /*!
+ * Get access to the underlying uhd device object.
+ * \return the multi usrp device object
+ */
+ virtual ::uhd::usrp::multi_usrp::sptr get_device(void) = 0;
+
+ /*!
+ * Perform write on the user configuration register bus. These
+ * only exist if the user has implemented custom setting
+ * registers in the device FPGA.
+ * \param addr 8-bit register address
+ * \param data 32-bit register value
+ * \param mboard which motherboard to set the user register
+ */
+ virtual void set_user_register(const uint8_t addr,
+ const uint32_t data,
+ size_t mboard = 0) = 0;
+
+ /*!
+ * Convenience function for finite data acquisition.
+ * This is not to be used with the scheduler; rather,
+ * one can request samples from the USRP in python.
+ * //TODO assumes fc32
+ * \param nsamps the number of samples
+ * \return a vector of complex float samples
+ */
+ virtual std::vector<std::complex<float> >
+ finite_acquisition(const size_t nsamps) = 0;
+
+ /*!
+ * Convenience function for finite data acquisition. This is the
+ * multi-channel version of finite_acquisition; This is not to
+ * be used with the scheduler; rather, one can request samples
+ * from the USRP in python.
+ * //TODO assumes fc32
+ * \param nsamps the number of samples per channel
+ * \return a vector of buffers, where each buffer represents a channel
+ */
+ virtual std::vector<std::vector<std::complex<float> > >
+ finite_acquisition_v(const size_t nsamps) = 0;
+ };
+
+ } /* namespace uhd */
+} /* namespace gr */
+
+#endif /* INCLUDED_GR_UHD_USRP_SOURCE_H */
diff --git a/gr-uhd/lib/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt
index f23885aca5..a6bd4e98b7 100644
--- a/gr-uhd/lib/CMakeLists.txt
+++ b/gr-uhd/lib/CMakeLists.txt
@@ -25,25 +25,29 @@ include_directories(
${GR_UHD_INCLUDE_DIRS}
${GNURADIO_CORE_INCLUDE_DIRS}
${GRUEL_INCLUDE_DIRS}
+ ${LOG4CXX_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${UHD_INCLUDE_DIRS}
)
link_directories(
- ${UHD_LIBRARY_DIRS}
- ${Boost_LIBRARY_DIRS}
+ ${UHD_LIBRARY_DIRS}
+ ${LOG4CXX_LIBRARY_DIRS}
+ ${Boost_LIBRARY_DIRS}
)
-include_directories(${LOG4CXX_INCLUDE_DIRS})
-link_directories(${LOG4CXX_LIBRARY_DIRS})
+if(ENABLE_GR_CTRLPORT)
+ ADD_DEFINITIONS(-DGR_CTRLPORT)
+ include_directories(${ICE_INCLUDE_DIR})
+endif(ENABLE_GR_CTRLPORT)
########################################################################
# Setup library
########################################################################
list(APPEND gr_uhd_sources
- gr_uhd_usrp_source.cc
- gr_uhd_usrp_sink.cc
- gr_uhd_amsg_source.cc
+ usrp_source_impl.cc
+ usrp_sink_impl.cc
+ amsg_source_impl.cc
)
#Add Windows DLL resource file if using MSVC
diff --git a/gr-uhd/lib/amsg_source_impl.cc b/gr-uhd/lib/amsg_source_impl.cc
new file mode 100644
index 0000000000..76603e4989
--- /dev/null
+++ b/gr-uhd/lib/amsg_source_impl.cc
@@ -0,0 +1,86 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "amsg_source_impl.h"
+#include "gr_uhd_common.h"
+#include <boost/bind.hpp>
+
+namespace gr {
+ namespace uhd {
+
+ amsg_source::sptr
+ amsg_source::make(const ::uhd::device_addr_t &device_addr,
+ gr_msg_queue_sptr msgq)
+ {
+ check_abi();
+ return amsg_source::sptr
+ (new amsg_source_impl(device_addr, msgq));
+ }
+
+ ::uhd::async_metadata_t
+ amsg_source::msg_to_async_metadata_t(const gr_message_sptr msg)
+ {
+ return *(::uhd::async_metadata_t *)msg->msg();
+ }
+
+ amsg_source_impl::amsg_source_impl(const ::uhd::device_addr_t &device_addr,
+ gr_msg_queue_sptr msgq)
+ : _msgq(msgq), _running(true)
+ {
+ _dev = ::uhd::usrp::multi_usrp::make(device_addr);
+ _amsg_thread =
+ gruel::thread(boost::bind(&amsg_source_impl::recv_loop, this));
+ }
+
+ amsg_source_impl::~amsg_source_impl()
+ {
+ _running = false;
+ _amsg_thread.join();
+ }
+
+ void
+ amsg_source_impl::recv_loop()
+ {
+ gr_message_sptr msg;
+ ::uhd::async_metadata_t *md;
+
+ while(_running) {
+ msg = gr_make_message(0, 0.0, 0.0, sizeof(::uhd::async_metadata_t));
+ md = (::uhd::async_metadata_t*) msg->msg();
+
+ while(!_dev->get_device()->recv_async_msg(*md, 0.1)) {
+ if(!_running)
+ return;
+ }
+
+ post(msg);
+ }
+ }
+
+ void
+ amsg_source_impl::post(gr_message_sptr msg)
+ {
+ _msgq->insert_tail(msg);
+ }
+
+ } /* namespace uhd */
+} /* namespace gr */
diff --git a/gr-uhd/lib/amsg_source_impl.h b/gr-uhd/lib/amsg_source_impl.h
new file mode 100644
index 0000000000..2928e85adb
--- /dev/null
+++ b/gr-uhd/lib/amsg_source_impl.h
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2011-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <uhd/amsg_source.h>
+#include <gruel/thread.h>
+
+namespace gr {
+ namespace uhd {
+
+ class amsg_source_impl : public amsg_source
+ {
+ public:
+ amsg_source_impl(const ::uhd::device_addr_t &device_addr,
+ gr_msg_queue_sptr msgq);
+ ~amsg_source_impl();
+
+ void recv_loop();
+ void post(gr_message_sptr msg);
+
+ protected:
+ ::uhd::usrp::multi_usrp::sptr _dev;
+ gruel::thread _amsg_thread;
+ gr_msg_queue_sptr _msgq;
+ bool _running;
+ };
+
+ } /* namespace uhd */
+} /* namespace gr */
+
diff --git a/gr-uhd/lib/gr_uhd_amsg_source.cc b/gr-uhd/lib/gr_uhd_amsg_source.cc
deleted file mode 100644
index d2e2dd0bf8..0000000000
--- a/gr-uhd/lib/gr_uhd_amsg_source.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2011-2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <gr_uhd_amsg_source.h>
-#include <boost/bind.hpp>
-#include <gruel/thread.h>
-#include "gr_uhd_common.h"
-
-/***********************************************************************
- * UHD Asynchronous Message Source Impl
- **********************************************************************/
-class uhd_amsg_source_impl : public uhd_amsg_source{
-public:
- uhd_amsg_source_impl(
- const uhd::device_addr_t &device_addr,
- gr_msg_queue_sptr msgq
- ):
- _msgq(msgq), _running(true)
- {
- _dev = uhd::usrp::multi_usrp::make(device_addr);
- _amsg_thread =
- gruel::thread(boost::bind(&uhd_amsg_source_impl::recv_loop, this));
- }
-
- ~uhd_amsg_source_impl()
- {
- _running = false;
- _amsg_thread.join();
- }
-
- void recv_loop()
- {
- gr_message_sptr msg;
- uhd::async_metadata_t *md;
-
- while (_running) {
- msg = gr_make_message(0, 0.0, 0.0, sizeof(uhd::async_metadata_t));
- md = (uhd::async_metadata_t *) msg->msg();
-
- while (!_dev->get_device()->recv_async_msg(*md, 0.1)) {
- if (!_running)
- return;
- }
-
- post(msg);
- }
- }
-
- void post(gr_message_sptr msg)
- {
- _msgq->insert_tail(msg);
- }
-
-protected:
- uhd::usrp::multi_usrp::sptr _dev;
- gruel::thread _amsg_thread;
- gr_msg_queue_sptr _msgq;
- bool _running;
-};
-
-uhd::async_metadata_t uhd_amsg_source::msg_to_async_metadata_t(const gr_message_sptr msg)
-{
- return *(uhd::async_metadata_t *)msg->msg();
-}
-
-/***********************************************************************
- * Make UHD Asynchronous Message Source
- **********************************************************************/
-boost::shared_ptr<uhd_amsg_source> uhd_make_amsg_source(
- const uhd::device_addr_t &device_addr,
- gr_msg_queue_sptr msgq
-){
- gr_uhd_check_abi();
- return boost::shared_ptr<uhd_amsg_source>(
- new uhd_amsg_source_impl(device_addr, msgq)
- );
-}
diff --git a/gr-uhd/lib/gr_uhd_common.h b/gr-uhd/lib/gr_uhd_common.h
index f2433b288c..0c18fa4634 100644
--- a/gr-uhd/lib/gr_uhd_common.h
+++ b/gr-uhd/lib/gr_uhd_common.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2012 Free Software Foundation, Inc.
+ * Copyright 2012-2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,17 +27,26 @@
#include <boost/format.hpp>
#include <stdexcept>
-static inline void gr_uhd_check_abi(void){
- #ifdef UHD_VERSION_ABI_STRING
- if (std::string(UHD_VERSION_ABI_STRING) == uhd::get_abi_string()) return;
- throw std::runtime_error(str(boost::format(
+namespace gr {
+ namespace uhd {
+
+ static inline void check_abi(void)
+ {
+#ifdef UHD_VERSION_ABI_STRING
+ if(std::string(UHD_VERSION_ABI_STRING) == ::uhd::get_abi_string())
+ return;
+
+ throw std::runtime_error(str(boost::format(
"\nGR-UHD detected ABI compatibility mismatch with UHD library.\n"
"GR-UHD was build against ABI: %s,\n"
"but UHD library reports ABI: %s\n"
"Suggestion: install an ABI compatible version of UHD,\n"
"or rebuild GR-UHD component against this ABI version.\n"
- ) % UHD_VERSION_ABI_STRING % uhd::get_abi_string()));
- #endif
-}
+ ) % UHD_VERSION_ABI_STRING % ::uhd::get_abi_string()));
+#endif
+ }
+
+ } /* namespace uhd */
+} /* namespace gr */
#endif /* INCLUDED_GR_UHD_COMMON_H */
diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc
deleted file mode 100644
index 6216c94a83..0000000000
--- a/gr-uhd/lib/gr_uhd_usrp_sink.cc
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Copyright 2010-2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <gr_uhd_usrp_sink.h>
-#include <gr_io_signature.h>
-#include <stdexcept>
-#include <boost/make_shared.hpp>
-#include "gr_uhd_common.h"
-
-static const pmt::pmt_t SOB_KEY = pmt::pmt_string_to_symbol("tx_sob");
-static const pmt::pmt_t EOB_KEY = pmt::pmt_string_to_symbol("tx_eob");
-static const pmt::pmt_t TIME_KEY = pmt::pmt_string_to_symbol("tx_time");
-
-#include <uhd/convert.hpp>
-inline gr_io_signature_sptr args_to_io_sig(const uhd::stream_args_t &args){
- const size_t nchan = std::max<size_t>(args.channels.size(), 1);
- #ifdef GR_UHD_USE_STREAM_API
- const size_t size = uhd::convert::get_bytes_per_item(args.cpu_format);
- #else
- size_t size = 0;
- if (args.cpu_format == "fc32") size = 8;
- if (args.cpu_format == "sc16") size = 4;
- #endif
- return gr_make_io_signature(nchan, nchan, size);
-}
-
-/***********************************************************************
- * UHD Multi USRP Sink Impl
- **********************************************************************/
-class uhd_usrp_sink_impl : public uhd_usrp_sink{
-public:
- uhd_usrp_sink_impl(
- const uhd::device_addr_t &device_addr,
- const uhd::stream_args_t &stream_args
- ):
- gr_sync_block(
- "gr uhd usrp sink",
- args_to_io_sig(stream_args),
- gr_make_io_signature(0, 0, 0)
- ),
- _stream_args(stream_args),
- _nchan(std::max<size_t>(1, stream_args.channels.size())),
- _stream_now(_nchan == 1),
- _start_time_set(false)
- {
- if (stream_args.cpu_format == "fc32") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_FLOAT32);
- if (stream_args.cpu_format == "sc16") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_INT16);
- _dev = uhd::usrp::multi_usrp::make(device_addr);
- }
-
- uhd::dict<std::string, std::string> get_usrp_info(size_t chan){
- #ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
- return _dev->get_usrp_tx_info(chan);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void set_subdev_spec(const std::string &spec, size_t mboard){
- return _dev->set_tx_subdev_spec(spec, mboard);
- }
-
- std::string get_subdev_spec(size_t mboard){
- return _dev->get_tx_subdev_spec(mboard).to_string();
- }
-
- void set_samp_rate(double rate){
- _dev->set_tx_rate(rate);
- _sample_rate = this->get_samp_rate();
- }
-
- double get_samp_rate(void){
- return _dev->get_tx_rate();
- }
-
- uhd::meta_range_t get_samp_rates(void){
- #ifdef UHD_USRP_MULTI_USRP_GET_RATES_API
- return _dev->get_tx_rates();
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- uhd::tune_result_t set_center_freq(
- const uhd::tune_request_t tune_request, size_t chan
- ){
- return _dev->set_tx_freq(tune_request, chan);
- }
-
- double get_center_freq(size_t chan){
- return _dev->get_tx_freq(chan);
- }
-
- uhd::freq_range_t get_freq_range(size_t chan){
- return _dev->get_tx_freq_range(chan);
- }
-
- void set_gain(double gain, size_t chan){
- return _dev->set_tx_gain(gain, chan);
- }
-
- void set_gain(double gain, const std::string &name, size_t chan){
- return _dev->set_tx_gain(gain, name, chan);
- }
-
- double get_gain(size_t chan){
- return _dev->get_tx_gain(chan);
- }
-
- double get_gain(const std::string &name, size_t chan){
- return _dev->get_tx_gain(name, chan);
- }
-
- std::vector<std::string> get_gain_names(size_t chan){
- return _dev->get_tx_gain_names(chan);
- }
-
- uhd::gain_range_t get_gain_range(size_t chan){
- return _dev->get_tx_gain_range(chan);
- }
-
- uhd::gain_range_t get_gain_range(const std::string &name, size_t chan){
- return _dev->get_tx_gain_range(name, chan);
- }
-
- void set_antenna(const std::string &ant, size_t chan){
- return _dev->set_tx_antenna(ant, chan);
- }
-
- std::string get_antenna(size_t chan){
- return _dev->get_tx_antenna(chan);
- }
-
- std::vector<std::string> get_antennas(size_t chan){
- return _dev->get_tx_antennas(chan);
- }
-
- void set_bandwidth(double bandwidth, size_t chan){
- return _dev->set_tx_bandwidth(bandwidth, chan);
- }
-
- void set_dc_offset(const std::complex<double> &offset, size_t chan){
- #ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
- return _dev->set_tx_dc_offset(offset, chan);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void set_iq_balance(const std::complex<double> &correction, size_t chan){
- #ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
- return _dev->set_tx_iq_balance(correction, chan);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- uhd::sensor_value_t get_sensor(const std::string &name, size_t chan){
- return _dev->get_tx_sensor(name, chan);
- }
-
- std::vector<std::string> get_sensor_names(size_t chan){
- return _dev->get_tx_sensor_names(chan);
- }
-
- uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){
- return _dev->get_mboard_sensor(name, mboard);
- }
-
- std::vector<std::string> get_mboard_sensor_names(size_t mboard){
- return _dev->get_mboard_sensor_names(mboard);
- }
-
- void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){
- return _dev->set_clock_config(clock_config, mboard);
- }
-
- void set_time_source(const std::string &source, const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->set_time_source(source, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::string get_time_source(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_time_source(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::vector<std::string> get_time_sources(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_time_sources(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void set_clock_source(const std::string &source, const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->set_clock_source(source, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::string get_clock_source(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_clock_source(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::vector<std::string> get_clock_sources(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_clock_sources(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- double get_clock_rate(size_t mboard){
- return _dev->get_master_clock_rate(mboard);
- }
-
- void set_clock_rate(double rate, size_t mboard){
- return _dev->set_master_clock_rate(rate, mboard);
- }
-
- uhd::time_spec_t get_time_now(size_t mboard = 0){
- return _dev->get_time_now(mboard);
- }
-
- uhd::time_spec_t get_time_last_pps(size_t mboard){
- return _dev->get_time_last_pps(mboard);
- }
-
- void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard){
- return _dev->set_time_now(time_spec, mboard);
- }
-
- void set_time_next_pps(const uhd::time_spec_t &time_spec){
- return _dev->set_time_next_pps(time_spec);
- }
-
- void set_time_unknown_pps(const uhd::time_spec_t &time_spec){
- return _dev->set_time_unknown_pps(time_spec);
- }
-
- void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
- return _dev->set_command_time(time_spec, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void clear_command_time(size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
- return _dev->clear_command_time(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){
- return _dev->get_tx_dboard_iface(chan);
- }
-
- uhd::usrp::multi_usrp::sptr get_device(void){
- return _dev;
- }
-
- void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_USER_REGS_API
- _dev->set_user_register(addr, data, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
-
-/***********************************************************************
- * Work
- **********************************************************************/
- int work(
- int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items
- ){
- int ninput_items = noutput_items; //cuz its a sync block
-
- //send a mid-burst packet with time spec
- _metadata.start_of_burst = false;
- _metadata.end_of_burst = false;
-
- //collect tags in this work()
- const uint64_t samp0_count = nitems_read(0);
- get_tags_in_range(_tags, 0, samp0_count, samp0_count + ninput_items);
- if (not _tags.empty()) this->tag_work(ninput_items);
-
- #ifdef GR_UHD_USE_STREAM_API
- //send all ninput_items with metadata
- const size_t num_sent = _tx_stream->send(
- input_items, ninput_items, _metadata, 1.0
- );
- #else
- const size_t num_sent = _dev->get_device()->send(
- input_items, ninput_items, _metadata,
- *_type, uhd::device::SEND_MODE_FULL_BUFF, 1.0
- );
- #endif
-
- //increment the timespec by the number of samples sent
- _metadata.time_spec += uhd::time_spec_t(0, num_sent, _sample_rate);
- return num_sent;
- }
-
-/***********************************************************************
- * Tag Work
- **********************************************************************/
- inline void tag_work(int &ninput_items){
- //the for loop below assumes tags sorted by count low -> high
- std::sort(_tags.begin(), _tags.end(), gr_tag_t::offset_compare);
-
- //extract absolute sample counts
- const gr_tag_t &tag0 = _tags.front();
- const uint64_t tag0_count = tag0.offset;
- const uint64_t samp0_count = this->nitems_read(0);
-
- //only transmit nsamples from 0 to the first tag
- //this ensures that the next work starts on a tag
- if (samp0_count != tag0_count){
- ninput_items = tag0_count - samp0_count;
- return;
- }
-
- //time will not be set unless a time tag is found
- _metadata.has_time_spec = false;
-
- //process all of the tags found with the same count as tag0
- BOOST_FOREACH(const gr_tag_t &my_tag, _tags){
- const uint64_t my_tag_count = my_tag.offset;
- const pmt::pmt_t &key = my_tag.key;
- const pmt::pmt_t &value = my_tag.value;
-
- //determine how many samples to send...
- //from zero until the next tag or end of work
- if (my_tag_count != tag0_count){
- ninput_items = my_tag_count - samp0_count;
- break;
- }
-
- //handle end of burst with a mini end of burst packet
- else if (pmt::pmt_equal(key, EOB_KEY)){
- _metadata.end_of_burst = pmt::pmt_to_bool(value);
- ninput_items = 1;
- return;
- }
-
- //set the start of burst flag in the metadata
- else if (pmt::pmt_equal(key, SOB_KEY)){
- _metadata.start_of_burst = pmt::pmt_to_bool(value);
- }
-
- //set the time specification in the metadata
- else if (pmt::pmt_equal(key, TIME_KEY)){
- _metadata.has_time_spec = true;
- _metadata.time_spec = uhd::time_spec_t(
- pmt::pmt_to_uint64(pmt::pmt_tuple_ref(value, 0)),
- pmt::pmt_to_double(pmt::pmt_tuple_ref(value, 1))
- );
- }
- }
- }
-
- void set_start_time(const uhd::time_spec_t &time){
- _start_time = time;
- _start_time_set = true;
- _stream_now = false;
- }
-
- //Send an empty start-of-burst packet to begin streaming.
- //Set at a time in the near future to avoid late packets.
- bool start(void){
- #ifdef GR_UHD_USE_STREAM_API
- _tx_stream = _dev->get_tx_stream(_stream_args);
- #endif
-
- _metadata.start_of_burst = true;
- _metadata.end_of_burst = false;
- _metadata.has_time_spec = not _stream_now;
- if (_start_time_set){
- _start_time_set = false; //cleared for next run
- _metadata.time_spec = _start_time;
- }
- else{
- _metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01);
- }
-
- #ifdef GR_UHD_USE_STREAM_API
- _tx_stream->send(
- gr_vector_const_void_star(_nchan), 0, _metadata, 1.0
- );
- #else
- _dev->get_device()->send(
- gr_vector_const_void_star(_nchan), 0, _metadata,
- *_type, uhd::device::SEND_MODE_ONE_PACKET, 1.0
- );
- #endif
- return true;
- }
-
- //Send an empty end-of-burst packet to end streaming.
- //Ending the burst avoids an underflow error on stop.
- bool stop(void){
- _metadata.start_of_burst = false;
- _metadata.end_of_burst = true;
- _metadata.has_time_spec = false;
-
- #ifdef GR_UHD_USE_STREAM_API
- _tx_stream->send(gr_vector_const_void_star(_nchan), 0, _metadata, 1.0);
- #else
- _dev->get_device()->send(
- gr_vector_const_void_star(_nchan), 0, _metadata,
- *_type, uhd::device::SEND_MODE_ONE_PACKET, 1.0
- );
- #endif
- return true;
- }
-
-private:
- uhd::usrp::multi_usrp::sptr _dev;
- const uhd::stream_args_t _stream_args;
- boost::shared_ptr<uhd::io_type_t> _type;
- #ifdef GR_UHD_USE_STREAM_API
- uhd::tx_streamer::sptr _tx_stream;
- #endif
- size_t _nchan;
- bool _stream_now;
- uhd::tx_metadata_t _metadata;
- double _sample_rate;
-
- uhd::time_spec_t _start_time;
- bool _start_time_set;
-
- //stream tags related stuff
- std::vector<gr_tag_t> _tags;
-};
-
-/***********************************************************************
- * Make UHD Multi USRP Sink
- **********************************************************************/
-boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels
-){
- //fill in the streamer args
- uhd::stream_args_t stream_args;
- switch(io_type.tid){
- case uhd::io_type_t::COMPLEX_FLOAT32: stream_args.cpu_format = "fc32"; break;
- case uhd::io_type_t::COMPLEX_INT16: stream_args.cpu_format = "sc16"; break;
- default: throw std::runtime_error("only complex float and shorts known to work");
- }
- stream_args.otw_format = "sc16"; //only sc16 known to work
- for (size_t chan = 0; chan < num_channels; chan++)
- stream_args.channels.push_back(chan); //linear mapping
-
- return uhd_make_usrp_sink(device_addr, stream_args);
-}
-
-boost::shared_ptr<uhd_usrp_sink> uhd_make_usrp_sink(
- const uhd::device_addr_t &device_addr,
- const uhd::stream_args_t &stream_args
-){
- gr_uhd_check_abi();
- return boost::shared_ptr<uhd_usrp_sink>(
- new uhd_usrp_sink_impl(device_addr, stream_args)
- );
-}
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc
deleted file mode 100644
index 3813673b4b..0000000000
--- a/gr-uhd/lib/gr_uhd_usrp_source.cc
+++ /dev/null
@@ -1,563 +0,0 @@
-/*
- * Copyright 2010-2012 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#include <gr_uhd_usrp_source.h>
-#include <gr_io_signature.h>
-#include <stdexcept>
-#include <iostream>
-#include <boost/format.hpp>
-#include <boost/thread/thread.hpp>
-#include <boost/make_shared.hpp>
-#include "gr_uhd_common.h"
-
-static const pmt::pmt_t TIME_KEY = pmt::pmt_string_to_symbol("rx_time");
-static const pmt::pmt_t RATE_KEY = pmt::pmt_string_to_symbol("rx_rate");
-static const pmt::pmt_t FREQ_KEY = pmt::pmt_string_to_symbol("rx_freq");
-
-#include <uhd/convert.hpp>
-inline gr_io_signature_sptr args_to_io_sig(const uhd::stream_args_t &args){
- const size_t nchan = std::max<size_t>(args.channels.size(), 1);
- #ifdef GR_UHD_USE_STREAM_API
- const size_t size = uhd::convert::get_bytes_per_item(args.cpu_format);
- #else
- size_t size = 0;
- if (args.cpu_format == "fc32") size = 8;
- if (args.cpu_format == "sc16") size = 4;
- #endif
- return gr_make_io_signature(nchan, nchan, size);
-}
-
-/***********************************************************************
- * UHD Multi USRP Source Impl
- **********************************************************************/
-class uhd_usrp_source_impl : public uhd_usrp_source{
-public:
- uhd_usrp_source_impl(
- const uhd::device_addr_t &device_addr,
- const uhd::stream_args_t &stream_args
- ):
- gr_sync_block(
- "gr uhd usrp source",
- gr_make_io_signature(0, 0, 0),
- args_to_io_sig(stream_args)
- ),
- _stream_args(stream_args),
- _nchan(std::max<size_t>(1, stream_args.channels.size())),
- _stream_now(_nchan == 1),
- _tag_now(false),
- _start_time_set(false)
- {
- if (stream_args.cpu_format == "fc32") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_FLOAT32);
- if (stream_args.cpu_format == "sc16") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_INT16);
- std::stringstream str;
- str << name() << unique_id();
- _id = pmt::pmt_string_to_symbol(str.str());
- _dev = uhd::usrp::multi_usrp::make(device_addr);
- }
-
- uhd::dict<std::string, std::string> get_usrp_info(size_t chan){
- #ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
- return _dev->get_usrp_rx_info(chan);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void set_subdev_spec(const std::string &spec, size_t mboard){
- return _dev->set_rx_subdev_spec(spec, mboard);
- }
-
- std::string get_subdev_spec(size_t mboard){
- return _dev->get_rx_subdev_spec(mboard).to_string();
- }
-
- void set_samp_rate(double rate){
- _dev->set_rx_rate(rate);
- _samp_rate = this->get_samp_rate();
- _tag_now = true;
- }
-
- double get_samp_rate(void){
- return _dev->get_rx_rate();
- }
-
- uhd::meta_range_t get_samp_rates(void){
- #ifdef UHD_USRP_MULTI_USRP_GET_RATES_API
- return _dev->get_rx_rates();
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- uhd::tune_result_t set_center_freq(
- const uhd::tune_request_t tune_request, size_t chan
- ){
- const uhd::tune_result_t res = _dev->set_rx_freq(tune_request, chan);
- _center_freq = this->get_center_freq(chan);
- _tag_now = true;
- return res;
- }
-
- double get_center_freq(size_t chan){
- return _dev->get_rx_freq(chan);
- }
-
- uhd::freq_range_t get_freq_range(size_t chan){
- return _dev->get_rx_freq_range(chan);
- }
-
- void set_gain(double gain, size_t chan){
- return _dev->set_rx_gain(gain, chan);
- }
-
- void set_gain(double gain, const std::string &name, size_t chan){
- return _dev->set_rx_gain(gain, name, chan);
- }
-
- double get_gain(size_t chan){
- return _dev->get_rx_gain(chan);
- }
-
- double get_gain(const std::string &name, size_t chan){
- return _dev->get_rx_gain(name, chan);
- }
-
- std::vector<std::string> get_gain_names(size_t chan){
- return _dev->get_rx_gain_names(chan);
- }
-
- uhd::gain_range_t get_gain_range(size_t chan){
- return _dev->get_rx_gain_range(chan);
- }
-
- uhd::gain_range_t get_gain_range(const std::string &name, size_t chan){
- return _dev->get_rx_gain_range(name, chan);
- }
-
- void set_antenna(const std::string &ant, size_t chan){
- return _dev->set_rx_antenna(ant, chan);
- }
-
- std::string get_antenna(size_t chan){
- return _dev->get_rx_antenna(chan);
- }
-
- std::vector<std::string> get_antennas(size_t chan){
- return _dev->get_rx_antennas(chan);
- }
-
- void set_bandwidth(double bandwidth, size_t chan){
- return _dev->set_rx_bandwidth(bandwidth, chan);
- }
-
- void set_auto_dc_offset(const bool enable, size_t chan){
- #ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
- return _dev->set_rx_dc_offset(enable, chan);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void set_dc_offset(const std::complex<double> &offset, size_t chan){
- #ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
- return _dev->set_rx_dc_offset(offset, chan);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void set_iq_balance(const std::complex<double> &correction, size_t chan){
- #ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
- return _dev->set_rx_iq_balance(correction, chan);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- uhd::sensor_value_t get_sensor(const std::string &name, size_t chan){
- return _dev->get_rx_sensor(name, chan);
- }
-
- std::vector<std::string> get_sensor_names(size_t chan){
- return _dev->get_rx_sensor_names(chan);
- }
-
- uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){
- return _dev->get_mboard_sensor(name, mboard);
- }
-
- std::vector<std::string> get_mboard_sensor_names(size_t mboard){
- return _dev->get_mboard_sensor_names(mboard);
- }
-
- void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){
- return _dev->set_clock_config(clock_config, mboard);
- }
-
- void set_time_source(const std::string &source, const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->set_time_source(source, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::string get_time_source(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_time_source(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::vector<std::string> get_time_sources(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_time_sources(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void set_clock_source(const std::string &source, const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->set_clock_source(source, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::string get_clock_source(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_clock_source(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- std::vector<std::string> get_clock_sources(const size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
- return _dev->get_clock_sources(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- double get_clock_rate(size_t mboard){
- return _dev->get_master_clock_rate(mboard);
- }
-
- void set_clock_rate(double rate, size_t mboard){
- return _dev->set_master_clock_rate(rate, mboard);
- }
-
- uhd::time_spec_t get_time_now(size_t mboard = 0){
- return _dev->get_time_now(mboard);
- }
-
- uhd::time_spec_t get_time_last_pps(size_t mboard){
- return _dev->get_time_last_pps(mboard);
- }
-
- void set_time_now(const uhd::time_spec_t &time_spec, size_t mboard){
- return _dev->set_time_now(time_spec, mboard);
- }
-
- void set_time_next_pps(const uhd::time_spec_t &time_spec){
- return _dev->set_time_next_pps(time_spec);
- }
-
- void set_time_unknown_pps(const uhd::time_spec_t &time_spec){
- return _dev->set_time_unknown_pps(time_spec);
- }
-
- void set_command_time(const uhd::time_spec_t &time_spec, size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
- return _dev->set_command_time(time_spec, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- void clear_command_time(size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
- return _dev->clear_command_time(mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
- uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan){
- return _dev->get_rx_dboard_iface(chan);
- }
-
- uhd::usrp::multi_usrp::sptr get_device(void){
- return _dev;
- }
-
- void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard){
- #ifdef UHD_USRP_MULTI_USRP_USER_REGS_API
- _dev->set_user_register(addr, data, mboard);
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
-/***********************************************************************
- * Work
- **********************************************************************/
- int work(
- int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items
- ){
- #ifdef GR_UHD_USE_STREAM_API
- //In order to allow for low-latency:
- //We receive all available packets without timeout.
- //This call can timeout under regular operation...
- size_t num_samps = _rx_stream->recv(
- output_items, noutput_items, _metadata, 0.0
- );
-
- //If receive resulted in a timeout condition:
- //We now receive a single packet with a large timeout.
- if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT)
- {
- num_samps = _rx_stream->recv(
- output_items, noutput_items, _metadata, 0.1, true/*one pkt*/
- );
- }
- #else
- size_t num_samps = _dev->get_device()->recv(
- output_items, noutput_items, _metadata,
- *_type, uhd::device::RECV_MODE_FULL_BUFF, 0.0
- );
- if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){
- num_samps = _dev->get_device()->recv(
- output_items, noutput_items, _metadata,
- *_type, uhd::device::RECV_MODE_ONE_PACKET, 1.0
- );
- }
- #endif
-
- //handle possible errors conditions
- switch(_metadata.error_code){
- case uhd::rx_metadata_t::ERROR_CODE_NONE:
- if (_tag_now){
- _tag_now = false;
- //create a timestamp pmt for the first sample
- const pmt::pmt_t val = pmt::pmt_make_tuple(
- pmt::pmt_from_uint64(_metadata.time_spec.get_full_secs()),
- pmt::pmt_from_double(_metadata.time_spec.get_frac_secs())
- );
- //create a tag set for each channel
- for (size_t i = 0; i < _nchan; i++){
- this->add_item_tag(i, nitems_written(0), TIME_KEY, val, _id);
- this->add_item_tag(i, nitems_written(0), RATE_KEY, pmt::pmt_from_double(_samp_rate), _id);
- this->add_item_tag(i, nitems_written(0), FREQ_KEY, pmt::pmt_from_double(_center_freq), _id);
- }
- }
- break;
-
- case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
- //its ok to timeout, perhaps the user is doing finite streaming
- return 0;
-
- case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
- _tag_now = true;
- //ignore overflows and try work again
- return work(noutput_items, input_items, output_items);
-
- default:
- std::cout << boost::format(
- "UHD source block got error code 0x%x"
- ) % _metadata.error_code << std::endl;
- return num_samps;
- }
-
- return num_samps;
- }
-
- void set_start_time(const uhd::time_spec_t &time){
- _start_time = time;
- _start_time_set = true;
- _stream_now = false;
- }
-
- void issue_stream_cmd(const uhd::stream_cmd_t &cmd)
- {
- _dev->issue_stream_cmd(cmd);
- }
-
- bool start(void){
- #ifdef GR_UHD_USE_STREAM_API
- _rx_stream = _dev->get_rx_stream(_stream_args);
- _samps_per_packet = _rx_stream->get_max_num_samps();
- #endif
- //setup a stream command that starts streaming slightly in the future
- static const double reasonable_delay = 0.1; //order of magnitude over RTT
- uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
- stream_cmd.stream_now = _stream_now;
- if (_start_time_set){
- _start_time_set = false; //cleared for next run
- stream_cmd.time_spec = _start_time;
- }
- else{
- stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay);
- }
- _dev->issue_stream_cmd(stream_cmd);
- _tag_now = true;
- return true;
- }
-
- void flush(void){
- const size_t nbytes = 4096;
- gr_vector_void_star outputs;
- std::vector<std::vector<char> > buffs(_nchan, std::vector<char>(nbytes));
- for (size_t i = 0; i < _nchan; i++){
- outputs.push_back(&buffs[i].front());
- }
- while (true){
- #ifdef GR_UHD_USE_STREAM_API
- const size_t bpi = uhd::convert::get_bytes_per_item(_stream_args.cpu_format);
- _rx_stream->recv(
- outputs, nbytes/bpi, _metadata, 0.0
- );
- #else
- _dev->get_device()->recv(
- outputs, nbytes/_type->size, _metadata,
- *_type, uhd::device::RECV_MODE_FULL_BUFF, 0.0
- );
- #endif
- if (_metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break;
- }
- }
-
- bool stop(void){
- _dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
-
- this->flush();
-
- return true;
- }
-
- std::vector<std::complex<float> > finite_acquisition(const size_t nsamps){
- if (_nchan != 1) throw std::runtime_error("finite_acquisition: usrp source has multiple channels, call finite_acquisition_v");
- return finite_acquisition_v(nsamps).front();
- }
-
- std::vector<std::vector<std::complex<float> > > finite_acquisition_v(const size_t nsamps){
- #ifdef GR_UHD_USE_STREAM_API
-
- //kludgy way to ensure rx streamer exsists
- if (!_rx_stream){
- this->start();
- this->stop();
- }
-
- //flush so there is no queued-up data
- this->flush();
-
- //create a multi-dimensional container to hold an array of sample buffers
- std::vector<std::vector<std::complex<float> > > samps(_nchan, std::vector<std::complex<float> >(nsamps));
-
- //load the void* vector of buffer pointers
- std::vector<void *> buffs(_nchan);
- for (size_t i = 0; i < _nchan; i++){
- buffs[i] = &samps[i].front();
- }
-
- //tell the device to stream a finite amount
- uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
- cmd.num_samps = nsamps;
- cmd.stream_now = _stream_now;
- static const double reasonable_delay = 0.1; //order of magnitude over RTT
- cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay);
- _dev->issue_stream_cmd(cmd);
-
- //receive samples until timeout
- const size_t actual_num_samps = _rx_stream->recv(
- buffs, nsamps, _metadata, 1.0
- );
-
- //resize the resulting sample buffers
- for (size_t i = 0; i < _nchan; i++){
- samps[i].resize(actual_num_samps);
- }
-
- return samps;
- #else
- throw std::runtime_error("not implemented in this version");
- #endif
- }
-
-private:
- uhd::usrp::multi_usrp::sptr _dev;
- const uhd::stream_args_t _stream_args;
- boost::shared_ptr<uhd::io_type_t> _type;
- #ifdef GR_UHD_USE_STREAM_API
- uhd::rx_streamer::sptr _rx_stream;
- size_t _samps_per_packet;
- #endif
- size_t _nchan;
- bool _stream_now, _tag_now;
- uhd::rx_metadata_t _metadata;
- pmt::pmt_t _id;
-
- uhd::time_spec_t _start_time;
- bool _start_time_set;
-
- //tag shadows
- double _samp_rate;
- double _center_freq;
-};
-
-
-/***********************************************************************
- * Make UHD Multi USRP Source
- **********************************************************************/
-boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source(
- const uhd::device_addr_t &device_addr,
- const uhd::io_type_t &io_type,
- size_t num_channels
-){
- //fill in the streamer args
- uhd::stream_args_t stream_args;
- switch(io_type.tid){
- case uhd::io_type_t::COMPLEX_FLOAT32: stream_args.cpu_format = "fc32"; break;
- case uhd::io_type_t::COMPLEX_INT16: stream_args.cpu_format = "sc16"; break;
- default: throw std::runtime_error("only complex float and shorts known to work");
- }
- stream_args.otw_format = "sc16"; //only sc16 known to work
- for (size_t chan = 0; chan < num_channels; chan++)
- stream_args.channels.push_back(chan); //linear mapping
-
- return uhd_make_usrp_source(device_addr, stream_args);
-}
-
-boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source(
- const uhd::device_addr_t &device_addr,
- const uhd::stream_args_t &stream_args
-){
- gr_uhd_check_abi();
- return boost::shared_ptr<uhd_usrp_source>(
- new uhd_usrp_source_impl(device_addr, stream_args)
- );
-}
diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
new file mode 100644
index 0000000000..563917abaf
--- /dev/null
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -0,0 +1,575 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "usrp_sink_impl.h"
+#include "gr_uhd_common.h"
+#include <gr_io_signature.h>
+#include <boost/make_shared.hpp>
+#include <stdexcept>
+
+namespace gr {
+ namespace uhd {
+
+ usrp_sink::sptr
+ usrp_sink::make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::io_type_t &io_type,
+ size_t num_channels)
+ {
+ //fill in the streamer args
+ ::uhd::stream_args_t stream_args;
+ switch(io_type.tid) {
+ case ::uhd::io_type_t::COMPLEX_FLOAT32: stream_args.cpu_format = "fc32"; break;
+ case ::uhd::io_type_t::COMPLEX_INT16: stream_args.cpu_format = "sc16"; break;
+ default: throw std::runtime_error("only complex float and shorts known to work");
+ }
+
+ stream_args.otw_format = "sc16"; //only sc16 known to work
+ for(size_t chan = 0; chan < num_channels; chan++)
+ stream_args.channels.push_back(chan); //linear mapping
+
+ return usrp_sink::make(device_addr, stream_args);
+ }
+
+ usrp_sink::sptr
+ usrp_sink::make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args)
+ {
+ check_abi();
+ return usrp_sink::sptr
+ (new usrp_sink_impl(device_addr, stream_args));
+ }
+
+ usrp_sink_impl::usrp_sink_impl(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args)
+ : gr_sync_block("gr uhd usrp sink",
+ args_to_io_sig(stream_args),
+ gr_make_io_signature(0, 0, 0)),
+ _stream_args(stream_args),
+ _nchan(std::max<size_t>(1, stream_args.channels.size())),
+ _stream_now(_nchan == 1),
+ _start_time_set(false)
+ {
+ if(stream_args.cpu_format == "fc32")
+ _type = boost::make_shared< ::uhd::io_type_t >(::uhd::io_type_t::COMPLEX_FLOAT32);
+ if(stream_args.cpu_format == "sc16")
+ _type = boost::make_shared< ::uhd::io_type_t >(::uhd::io_type_t::COMPLEX_INT16);
+ _dev = ::uhd::usrp::multi_usrp::make(device_addr);
+ }
+
+ usrp_sink_impl::~usrp_sink_impl()
+ {
+ }
+
+ ::uhd::dict<std::string, std::string>
+ usrp_sink_impl::get_usrp_info(size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
+ return _dev->get_usrp_tx_info(chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_sink_impl::set_subdev_spec(const std::string &spec,
+ size_t mboard)
+ {
+ return _dev->set_tx_subdev_spec(spec, mboard);
+ }
+
+ std::string
+ usrp_sink_impl::get_subdev_spec(size_t mboard)
+ {
+ return _dev->get_tx_subdev_spec(mboard).to_string();
+ }
+
+ void
+ usrp_sink_impl::set_samp_rate(double rate)
+ {
+ _dev->set_tx_rate(rate);
+ _sample_rate = this->get_samp_rate();
+ }
+
+ double
+ usrp_sink_impl::get_samp_rate(void)
+ {
+ return _dev->get_tx_rate();
+ }
+
+ ::uhd::meta_range_t
+ usrp_sink_impl::get_samp_rates(void)
+ {
+#ifdef UHD_USRP_MULTI_USRP_GET_RATES_API
+ return _dev->get_tx_rates();
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ ::uhd::tune_result_t
+ usrp_sink_impl::set_center_freq(const ::uhd::tune_request_t tune_request,
+ size_t chan)
+ {
+ return _dev->set_tx_freq(tune_request, chan);
+ }
+
+ double
+ usrp_sink_impl::get_center_freq(size_t chan)
+ {
+ return _dev->get_tx_freq(chan);
+ }
+
+ ::uhd::freq_range_t
+ usrp_sink_impl::get_freq_range(size_t chan)
+ {
+ return _dev->get_tx_freq_range(chan);
+ }
+
+ void
+ usrp_sink_impl::set_gain(double gain, size_t chan)
+ {
+ return _dev->set_tx_gain(gain, chan);
+ }
+
+ void
+ usrp_sink_impl::set_gain(double gain,
+ const std::string &name,
+ size_t chan)
+ {
+ return _dev->set_tx_gain(gain, name, chan);
+ }
+
+ double
+ usrp_sink_impl::get_gain(size_t chan)
+ {
+ return _dev->get_tx_gain(chan);
+ }
+
+ double
+ usrp_sink_impl::get_gain(const std::string &name, size_t chan)
+ {
+ return _dev->get_tx_gain(name, chan);
+ }
+
+ std::vector<std::string>
+ usrp_sink_impl::get_gain_names(size_t chan)
+ {
+ return _dev->get_tx_gain_names(chan);
+ }
+
+ ::uhd::gain_range_t
+ usrp_sink_impl::get_gain_range(size_t chan)
+ {
+ return _dev->get_tx_gain_range(chan);
+ }
+
+ ::uhd::gain_range_t
+ usrp_sink_impl::get_gain_range(const std::string &name,
+ size_t chan)
+ {
+ return _dev->get_tx_gain_range(name, chan);
+ }
+
+ void
+ usrp_sink_impl::set_antenna(const std::string &ant,
+ size_t chan)
+ {
+ return _dev->set_tx_antenna(ant, chan);
+ }
+
+ std::string
+ usrp_sink_impl::get_antenna(size_t chan)
+ {
+ return _dev->get_tx_antenna(chan);
+ }
+
+ std::vector<std::string>
+ usrp_sink_impl::get_antennas(size_t chan)
+ {
+ return _dev->get_tx_antennas(chan);
+ }
+
+ void
+ usrp_sink_impl::set_bandwidth(double bandwidth, size_t chan)
+ {
+ return _dev->set_tx_bandwidth(bandwidth, chan);
+ }
+
+ void
+ usrp_sink_impl::set_dc_offset(const std::complex<double> &offset,
+ size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
+ return _dev->set_tx_dc_offset(offset, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_sink_impl::set_iq_balance(const std::complex<double> &correction,
+ size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
+ return _dev->set_tx_iq_balance(correction, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ ::uhd::sensor_value_t
+ usrp_sink_impl::get_sensor(const std::string &name, size_t chan)
+ {
+ return _dev->get_tx_sensor(name, chan);
+ }
+
+ std::vector<std::string>
+ usrp_sink_impl::get_sensor_names(size_t chan)
+ {
+ return _dev->get_tx_sensor_names(chan);
+ }
+
+ ::uhd::sensor_value_t
+ usrp_sink_impl::get_mboard_sensor(const std::string &name,
+ size_t mboard)
+ {
+ return _dev->get_mboard_sensor(name, mboard);
+ }
+
+ std::vector<std::string>
+ usrp_sink_impl::get_mboard_sensor_names(size_t mboard)
+ {
+ return _dev->get_mboard_sensor_names(mboard);
+ }
+
+ void
+ usrp_sink_impl::set_clock_config(const ::uhd::clock_config_t &clock_config,
+ size_t mboard)
+ {
+ return _dev->set_clock_config(clock_config, mboard);
+ }
+
+ void
+ usrp_sink_impl::set_time_source(const std::string &source,
+ const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->set_time_source(source, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::string
+ usrp_sink_impl::get_time_source(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_time_source(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::vector<std::string>
+ usrp_sink_impl::get_time_sources(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_time_sources(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_sink_impl::set_clock_source(const std::string &source,
+ const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->set_clock_source(source, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::string
+ usrp_sink_impl::get_clock_source(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_clock_source(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::vector<std::string>
+ usrp_sink_impl::get_clock_sources(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_clock_sources(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ double
+ usrp_sink_impl::get_clock_rate(size_t mboard)
+ {
+ return _dev->get_master_clock_rate(mboard);
+ }
+
+ void
+ usrp_sink_impl::set_clock_rate(double rate, size_t mboard)
+ {
+ return _dev->set_master_clock_rate(rate, mboard);
+ }
+
+ ::uhd::time_spec_t
+ usrp_sink_impl::get_time_now(size_t mboard)
+ {
+ return _dev->get_time_now(mboard);
+ }
+
+ ::uhd::time_spec_t
+ usrp_sink_impl::get_time_last_pps(size_t mboard)
+ {
+ return _dev->get_time_last_pps(mboard);
+ }
+
+ void
+ usrp_sink_impl::set_time_now(const ::uhd::time_spec_t &time_spec,
+ size_t mboard)
+ {
+ return _dev->set_time_now(time_spec, mboard);
+ }
+
+ void
+ usrp_sink_impl::set_time_next_pps(const ::uhd::time_spec_t &time_spec)
+ {
+ return _dev->set_time_next_pps(time_spec);
+ }
+
+ void
+ usrp_sink_impl::set_time_unknown_pps(const ::uhd::time_spec_t &time_spec)
+ {
+ return _dev->set_time_unknown_pps(time_spec);
+ }
+
+ void
+ usrp_sink_impl::set_command_time(const ::uhd::time_spec_t &time_spec,
+ size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
+ return _dev->set_command_time(time_spec, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_sink_impl::clear_command_time(size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
+ return _dev->clear_command_time(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ ::uhd::usrp::dboard_iface::sptr
+ usrp_sink_impl::get_dboard_iface(size_t chan)
+ {
+ return _dev->get_tx_dboard_iface(chan);
+ }
+
+ ::uhd::usrp::multi_usrp::sptr
+ usrp_sink_impl::get_device(void)
+ {
+ return _dev;
+ }
+
+ void
+ usrp_sink_impl::set_user_register(const uint8_t addr,
+ const uint32_t data,
+ size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_USER_REGS_API
+ _dev->set_user_register(addr, data, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+
+ /***********************************************************************
+ * Work
+ **********************************************************************/
+ int
+ usrp_sink_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int ninput_items = noutput_items; //cuz its a sync block
+
+ //send a mid-burst packet with time spec
+ _metadata.start_of_burst = false;
+ _metadata.end_of_burst = false;
+
+ //collect tags in this work()
+ const uint64_t samp0_count = nitems_read(0);
+ get_tags_in_range(_tags, 0, samp0_count, samp0_count + ninput_items);
+ if(not _tags.empty())
+ this->tag_work(ninput_items);
+
+#ifdef GR_UHD_USE_STREAM_API
+ //send all ninput_items with metadata
+ const size_t num_sent = _tx_stream->send
+ (input_items, ninput_items, _metadata, 1.0);
+#else
+ const size_t num_sent = _dev->get_device()->send
+ (input_items, ninput_items, _metadata,
+ *_type, ::uhd::device::SEND_MODE_FULL_BUFF, 1.0);
+#endif
+
+ //increment the timespec by the number of samples sent
+ _metadata.time_spec += ::uhd::time_spec_t(0, num_sent, _sample_rate);
+ return num_sent;
+ }
+
+ /***********************************************************************
+ * Tag Work
+ **********************************************************************/
+ void
+ usrp_sink_impl::tag_work(int &ninput_items)
+ {
+ //the for loop below assumes tags sorted by count low -> high
+ std::sort(_tags.begin(), _tags.end(), gr_tag_t::offset_compare);
+
+ //extract absolute sample counts
+ const gr_tag_t &tag0 = _tags.front();
+ const uint64_t tag0_count = tag0.offset;
+ const uint64_t samp0_count = this->nitems_read(0);
+
+ //only transmit nsamples from 0 to the first tag
+ //this ensures that the next work starts on a tag
+ if(samp0_count != tag0_count) {
+ ninput_items = tag0_count - samp0_count;
+ return;
+ }
+
+ //time will not be set unless a time tag is found
+ _metadata.has_time_spec = false;
+
+ //process all of the tags found with the same count as tag0
+ BOOST_FOREACH(const gr_tag_t &my_tag, _tags) {
+ const uint64_t my_tag_count = my_tag.offset;
+ const pmt::pmt_t &key = my_tag.key;
+ const pmt::pmt_t &value = my_tag.value;
+
+ //determine how many samples to send...
+ //from zero until the next tag or end of work
+ if(my_tag_count != tag0_count) {
+ ninput_items = my_tag_count - samp0_count;
+ break;
+ }
+
+ //handle end of burst with a mini end of burst packet
+ else if(pmt::equal(key, EOB_KEY)) {
+ _metadata.end_of_burst = pmt::to_bool(value);
+ ninput_items = 1;
+ return;
+ }
+
+ //set the start of burst flag in the metadata
+ else if(pmt::equal(key, SOB_KEY)) {
+ _metadata.start_of_burst = pmt::to_bool(value);
+ }
+
+ //set the time specification in the metadata
+ else if(pmt::equal(key, TIME_KEY)) {
+ _metadata.has_time_spec = true;
+ _metadata.time_spec = ::uhd::time_spec_t
+ (pmt::to_uint64(pmt::tuple_ref(value, 0)),
+ pmt::to_double(pmt::tuple_ref(value, 1)));
+ }
+ }
+ }
+
+ void
+ usrp_sink_impl::set_start_time(const ::uhd::time_spec_t &time)
+ {
+ _start_time = time;
+ _start_time_set = true;
+ _stream_now = false;
+ }
+
+ //Send an empty start-of-burst packet to begin streaming.
+ //Set at a time in the near future to avoid late packets.
+ bool
+ usrp_sink_impl::start(void)
+ {
+#ifdef GR_UHD_USE_STREAM_API
+ _tx_stream = _dev->get_tx_stream(_stream_args);
+#endif
+
+ _metadata.start_of_burst = true;
+ _metadata.end_of_burst = false;
+ _metadata.has_time_spec = not _stream_now;
+ if(_start_time_set) {
+ _start_time_set = false; //cleared for next run
+ _metadata.time_spec = _start_time;
+ }
+ else {
+ _metadata.time_spec = get_time_now() + ::uhd::time_spec_t(0.01);
+ }
+
+#ifdef GR_UHD_USE_STREAM_API
+ _tx_stream->send
+ (gr_vector_const_void_star(_nchan), 0, _metadata, 1.0);
+#else
+ _dev->get_device()->send
+ (gr_vector_const_void_star(_nchan), 0, _metadata,
+ *_type, ::uhd::device::SEND_MODE_ONE_PACKET, 1.0);
+#endif
+ return true;
+ }
+
+ //Send an empty end-of-burst packet to end streaming.
+ //Ending the burst avoids an underflow error on stop.
+ bool
+ usrp_sink_impl::stop(void)
+ {
+ _metadata.start_of_burst = false;
+ _metadata.end_of_burst = true;
+ _metadata.has_time_spec = false;
+
+#ifdef GR_UHD_USE_STREAM_API
+ _tx_stream->send(gr_vector_const_void_star(_nchan), 0, _metadata, 1.0);
+#else
+ _dev->get_device()->send
+ (gr_vector_const_void_star(_nchan), 0, _metadata,
+ *_type, ::uhd::device::SEND_MODE_ONE_PACKET, 1.0);
+#endif
+ return true;
+ }
+
+ } /* namespace uhd */
+} /* namespace gr */
diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h
new file mode 100644
index 0000000000..d630e0f2fc
--- /dev/null
+++ b/gr-uhd/lib/usrp_sink_impl.h
@@ -0,0 +1,137 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <uhd/usrp_sink.h>
+#include <uhd/convert.hpp>
+
+static const pmt::pmt_t SOB_KEY = pmt::string_to_symbol("tx_sob");
+static const pmt::pmt_t EOB_KEY = pmt::string_to_symbol("tx_eob");
+static const pmt::pmt_t TIME_KEY = pmt::string_to_symbol("tx_time");
+
+namespace gr {
+ namespace uhd {
+
+ inline gr_io_signature_sptr
+ args_to_io_sig(const ::uhd::stream_args_t &args)
+ {
+ const size_t nchan = std::max<size_t>(args.channels.size(), 1);
+#ifdef GR_UHD_USE_STREAM_API
+ const size_t size = ::uhd::convert::get_bytes_per_item(args.cpu_format);
+#else
+ size_t size = 0;
+ if(args.cpu_format == "fc32")
+ size = 8;
+ if(args.cpu_format == "sc16")
+ size = 4;
+#endif
+ return gr_make_io_signature(nchan, nchan, size);
+ }
+
+ /***********************************************************************
+ * UHD Multi USRP Sink Impl
+ **********************************************************************/
+ class usrp_sink_impl : public usrp_sink
+ {
+ public:
+ usrp_sink_impl(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args);
+ ~usrp_sink_impl();
+
+ ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan);
+ double get_samp_rate(void);
+ ::uhd::meta_range_t get_samp_rates(void);
+ double get_center_freq(size_t chan);
+ ::uhd::freq_range_t get_freq_range(size_t chan);
+ double get_gain(size_t chan);
+ double get_gain(const std::string &name, size_t chan);
+ std::vector<std::string> get_gain_names(size_t chan);
+ ::uhd::gain_range_t get_gain_range(size_t chan);
+ ::uhd::gain_range_t get_gain_range(const std::string &name, size_t chan);
+ std::string get_antenna(size_t chan);
+ std::vector<std::string> get_antennas(size_t chan);
+ ::uhd::sensor_value_t get_sensor(const std::string &name, size_t chan);
+ std::vector<std::string> get_sensor_names(size_t chan);
+ ::uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard);
+ std::vector<std::string> get_mboard_sensor_names(size_t mboard);
+ std::string get_time_source(const size_t mboard);
+ std::vector<std::string> get_time_sources(const size_t mboard);
+ std::string get_clock_source(const size_t mboard);
+ std::vector<std::string> get_clock_sources(const size_t mboard);
+ double get_clock_rate(size_t mboard);
+ ::uhd::time_spec_t get_time_now(size_t mboard = 0);
+ ::uhd::time_spec_t get_time_last_pps(size_t mboard);
+ ::uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan);
+ ::uhd::usrp::multi_usrp::sptr get_device(void);
+
+ void set_subdev_spec(const std::string &spec, size_t mboard);
+ std::string get_subdev_spec(size_t mboard);
+ void set_samp_rate(double rate);
+ ::uhd::tune_result_t set_center_freq(const ::uhd::tune_request_t tune_request,
+ size_t chan);
+ void set_gain(double gain, size_t chan);
+ void set_gain(double gain, const std::string &name, size_t chan);
+ void set_antenna(const std::string &ant, size_t chan);
+ void set_bandwidth(double bandwidth, size_t chan);
+ void set_dc_offset(const std::complex<double> &offset, size_t chan);
+ void set_iq_balance(const std::complex<double> &correction, size_t chan);
+ void set_clock_config(const ::uhd::clock_config_t &clock_config, size_t mboard);
+ void set_time_source(const std::string &source, const size_t mboard);
+ void set_clock_source(const std::string &source, const size_t mboard);
+ void set_clock_rate(double rate, size_t mboard);
+ void set_time_now(const ::uhd::time_spec_t &time_spec, size_t mboard);
+ void set_time_next_pps(const ::uhd::time_spec_t &time_spec);
+ void set_time_unknown_pps(const ::uhd::time_spec_t &time_spec);
+ void set_command_time(const ::uhd::time_spec_t &time_spec, size_t mboard);
+ void clear_command_time(size_t mboard);
+ void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard);
+ void set_start_time(const ::uhd::time_spec_t &time);
+
+ bool start(void);
+ bool stop(void);
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ inline void tag_work(int &ninput_items);
+
+ private:
+ ::uhd::usrp::multi_usrp::sptr _dev;
+ const ::uhd::stream_args_t _stream_args;
+ boost::shared_ptr< ::uhd::io_type_t > _type;
+#ifdef GR_UHD_USE_STREAM_API
+ ::uhd::tx_streamer::sptr _tx_stream;
+#endif
+ size_t _nchan;
+ bool _stream_now;
+ ::uhd::tx_metadata_t _metadata;
+ double _sample_rate;
+
+ ::uhd::time_spec_t _start_time;
+ bool _start_time_set;
+
+ //stream tags related stuff
+ std::vector<gr_tag_t> _tags;
+ };
+
+ } /* namespace uhd */
+} /* namespace gr */
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
new file mode 100644
index 0000000000..9d6a55ae5a
--- /dev/null
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -0,0 +1,628 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "usrp_source_impl.h"
+#include "gr_uhd_common.h"
+#include <gr_io_signature.h>
+#include <boost/format.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/make_shared.hpp>
+#include <stdexcept>
+#include <iostream>
+
+namespace gr {
+ namespace uhd {
+
+ usrp_source::sptr
+ usrp_source::make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::io_type_t &io_type,
+ size_t num_channels)
+ {
+ //fill in the streamer args
+ ::uhd::stream_args_t stream_args;
+ switch(io_type.tid) {
+ case ::uhd::io_type_t::COMPLEX_FLOAT32: stream_args.cpu_format = "fc32"; break;
+ case ::uhd::io_type_t::COMPLEX_INT16: stream_args.cpu_format = "sc16"; break;
+ default: throw std::runtime_error("only complex float and shorts known to work");
+ }
+
+ stream_args.otw_format = "sc16"; //only sc16 known to work
+ for(size_t chan = 0; chan < num_channels; chan++)
+ stream_args.channels.push_back(chan); //linear mapping
+
+ return usrp_source::make(device_addr, stream_args);
+ }
+
+ usrp_source::sptr
+ usrp_source::make(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args)
+ {
+ check_abi();
+ return usrp_source::sptr
+ (new usrp_source_impl(device_addr, stream_args));
+ }
+
+ usrp_source_impl::usrp_source_impl(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args):
+ gr_sync_block("gr uhd usrp source",
+ gr_make_io_signature(0, 0, 0),
+ args_to_io_sig(stream_args)),
+ _stream_args(stream_args),
+ _nchan(std::max<size_t>(1, stream_args.channels.size())),
+ _stream_now(_nchan == 1),
+ _tag_now(false),
+ _start_time_set(false)
+ {
+ if(stream_args.cpu_format == "fc32")
+ _type = boost::make_shared< ::uhd::io_type_t >(::uhd::io_type_t::COMPLEX_FLOAT32);
+ if(stream_args.cpu_format == "sc16")
+ _type = boost::make_shared< ::uhd::io_type_t >(::uhd::io_type_t::COMPLEX_INT16);
+ std::stringstream str;
+ str << name() << unique_id();
+ _id = pmt::string_to_symbol(str.str());
+ _dev = ::uhd::usrp::multi_usrp::make(device_addr);
+ }
+
+ usrp_source_impl::~usrp_source_impl()
+ {
+ }
+
+ ::uhd::dict<std::string, std::string>
+ usrp_source_impl::get_usrp_info(size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_GET_USRP_INFO_API
+ return _dev->get_usrp_rx_info(chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::set_subdev_spec(const std::string &spec, size_t mboard)
+ {
+ return _dev->set_rx_subdev_spec(spec, mboard);
+ }
+
+ std::string
+ usrp_source_impl::get_subdev_spec(size_t mboard)
+ {
+ return _dev->get_rx_subdev_spec(mboard).to_string();
+ }
+
+ void
+ usrp_source_impl::set_samp_rate(double rate)
+ {
+ _dev->set_rx_rate(rate);
+ _samp_rate = this->get_samp_rate();
+ _tag_now = true;
+ }
+
+ double
+ usrp_source_impl::get_samp_rate(void)
+ {
+ return _dev->get_rx_rate();
+ }
+
+ ::uhd::meta_range_t
+ usrp_source_impl::get_samp_rates(void)
+ {
+#ifdef UHD_USRP_MULTI_USRP_GET_RATES_API
+ return _dev->get_rx_rates();
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ ::uhd::tune_result_t
+ usrp_source_impl::set_center_freq(const ::uhd::tune_request_t tune_request,
+ size_t chan)
+ {
+ const ::uhd::tune_result_t res = _dev->set_rx_freq(tune_request, chan);
+ _center_freq = this->get_center_freq(chan);
+ _tag_now = true;
+ return res;
+ }
+
+ double
+ usrp_source_impl::get_center_freq(size_t chan)
+ {
+ return _dev->get_rx_freq(chan);
+ }
+
+ ::uhd::freq_range_t
+ usrp_source_impl::get_freq_range(size_t chan)
+ {
+ return _dev->get_rx_freq_range(chan);
+ }
+
+ void
+ usrp_source_impl::set_gain(double gain, size_t chan)
+ {
+ return _dev->set_rx_gain(gain, chan);
+ }
+
+ void
+ usrp_source_impl::set_gain(double gain, const std::string &name, size_t chan)
+ {
+ return _dev->set_rx_gain(gain, name, chan);
+ }
+
+ double
+ usrp_source_impl::get_gain(size_t chan)
+ {
+ return _dev->get_rx_gain(chan);
+ }
+
+ double
+ usrp_source_impl::get_gain(const std::string &name, size_t chan)
+ {
+ return _dev->get_rx_gain(name, chan);
+ }
+
+ std::vector<std::string>
+ usrp_source_impl::get_gain_names(size_t chan)
+ {
+ return _dev->get_rx_gain_names(chan);
+ }
+
+ ::uhd::gain_range_t
+ usrp_source_impl::get_gain_range(size_t chan)
+ {
+ return _dev->get_rx_gain_range(chan);
+ }
+
+ ::uhd::gain_range_t
+ usrp_source_impl::get_gain_range(const std::string &name, size_t chan)
+ {
+ return _dev->get_rx_gain_range(name, chan);
+ }
+
+ void
+ usrp_source_impl::set_antenna(const std::string &ant, size_t chan)
+ {
+ return _dev->set_rx_antenna(ant, chan);
+ }
+
+ std::string
+ usrp_source_impl::get_antenna(size_t chan)
+ {
+ return _dev->get_rx_antenna(chan);
+ }
+
+ std::vector<std::string>
+ usrp_source_impl::get_antennas(size_t chan)
+ {
+ return _dev->get_rx_antennas(chan);
+ }
+
+ void
+ usrp_source_impl::set_bandwidth(double bandwidth, size_t chan)
+ {
+ return _dev->set_rx_bandwidth(bandwidth, chan);
+ }
+
+ void
+ usrp_source_impl::set_auto_dc_offset(const bool enable, size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
+ return _dev->set_rx_dc_offset(enable, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::set_dc_offset(const std::complex<double> &offset,
+ size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
+ return _dev->set_rx_dc_offset(offset, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::set_iq_balance(const std::complex<double> &correction,
+ size_t chan)
+ {
+#ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API
+ return _dev->set_rx_iq_balance(correction, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ ::uhd::sensor_value_t
+ usrp_source_impl::get_sensor(const std::string &name, size_t chan)
+ {
+ return _dev->get_rx_sensor(name, chan);
+ }
+
+ std::vector<std::string>
+ usrp_source_impl::get_sensor_names(size_t chan)
+ {
+ return _dev->get_rx_sensor_names(chan);
+ }
+
+ ::uhd::sensor_value_t
+ usrp_source_impl::get_mboard_sensor(const std::string &name, size_t mboard)
+ {
+ return _dev->get_mboard_sensor(name, mboard);
+ }
+
+ std::vector<std::string>
+ usrp_source_impl::get_mboard_sensor_names(size_t mboard)
+ {
+ return _dev->get_mboard_sensor_names(mboard);
+ }
+
+ void
+ usrp_source_impl::set_clock_config(const ::uhd::clock_config_t &clock_config,
+ size_t mboard)
+ {
+ return _dev->set_clock_config(clock_config, mboard);
+ }
+
+ void
+ usrp_source_impl::set_time_source(const std::string &source,
+ const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->set_time_source(source, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::string
+ usrp_source_impl::get_time_source(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_time_source(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::vector<std::string>
+ usrp_source_impl::get_time_sources(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_time_sources(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::set_clock_source(const std::string &source,
+ const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->set_clock_source(source, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::string
+ usrp_source_impl::get_clock_source(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_clock_source(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ std::vector<std::string>
+ usrp_source_impl::get_clock_sources(const size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_REF_SOURCES_API
+ return _dev->get_clock_sources(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ double
+ usrp_source_impl::get_clock_rate(size_t mboard)
+ {
+ return _dev->get_master_clock_rate(mboard);
+ }
+
+ void
+ usrp_source_impl::set_clock_rate(double rate, size_t mboard)
+ {
+ return _dev->set_master_clock_rate(rate, mboard);
+ }
+
+ ::uhd::time_spec_t
+ usrp_source_impl::get_time_now(size_t mboard)
+ {
+ return _dev->get_time_now(mboard);
+ }
+
+ ::uhd::time_spec_t
+ usrp_source_impl::get_time_last_pps(size_t mboard)
+ {
+ return _dev->get_time_last_pps(mboard);
+ }
+
+ void
+ usrp_source_impl::set_time_now(const ::uhd::time_spec_t &time_spec,
+ size_t mboard)
+ {
+ return _dev->set_time_now(time_spec, mboard);
+ }
+
+ void
+ usrp_source_impl::set_time_next_pps(const ::uhd::time_spec_t &time_spec)
+ {
+ return _dev->set_time_next_pps(time_spec);
+ }
+
+ void
+ usrp_source_impl::set_time_unknown_pps(const ::uhd::time_spec_t &time_spec)
+ {
+ return _dev->set_time_unknown_pps(time_spec);
+ }
+
+ void
+ usrp_source_impl::set_command_time(const ::uhd::time_spec_t &time_spec, size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
+ return _dev->set_command_time(time_spec, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::clear_command_time(size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_COMMAND_TIME_API
+ return _dev->clear_command_time(mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ ::uhd::usrp::dboard_iface::sptr
+ usrp_source_impl::get_dboard_iface(size_t chan)
+ {
+ return _dev->get_rx_dboard_iface(chan);
+ }
+
+ ::uhd::usrp::multi_usrp::sptr
+ usrp_source_impl::get_device(void)
+ {
+ return _dev;
+ }
+
+ void
+ usrp_source_impl::set_user_register(const uint8_t addr,
+ const uint32_t data,
+ size_t mboard)
+ {
+#ifdef UHD_USRP_MULTI_USRP_USER_REGS_API
+ _dev->set_user_register(addr, data, mboard);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ void
+ usrp_source_impl::set_start_time(const ::uhd::time_spec_t &time)
+ {
+ _start_time = time;
+ _start_time_set = true;
+ _stream_now = false;
+ }
+
+ void
+ usrp_source_impl::issue_stream_cmd(const ::uhd::stream_cmd_t &cmd)
+ {
+ _dev->issue_stream_cmd(cmd);
+ }
+
+ bool
+ usrp_source_impl::start(void)
+ {
+#ifdef GR_UHD_USE_STREAM_API
+ _rx_stream = _dev->get_rx_stream(_stream_args);
+ _samps_per_packet = _rx_stream->get_max_num_samps();
+#endif
+ //setup a stream command that starts streaming slightly in the future
+ static const double reasonable_delay = 0.1; //order of magnitude over RTT
+ ::uhd::stream_cmd_t stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
+ stream_cmd.stream_now = _stream_now;
+ if(_start_time_set) {
+ _start_time_set = false; //cleared for next run
+ stream_cmd.time_spec = _start_time;
+ }
+ else {
+ stream_cmd.time_spec = get_time_now() + ::uhd::time_spec_t(reasonable_delay);
+ }
+ _dev->issue_stream_cmd(stream_cmd);
+ _tag_now = true;
+ return true;
+ }
+
+ void
+ usrp_source_impl::flush(void)
+ {
+ const size_t nbytes = 4096;
+ gr_vector_void_star outputs;
+ std::vector<std::vector<char> > buffs(_nchan, std::vector<char>(nbytes));
+ for(size_t i = 0; i < _nchan; i++) {
+ outputs.push_back(&buffs[i].front());
+ }
+ while(true) {
+#ifdef GR_UHD_USE_STREAM_API
+ const size_t bpi = ::uhd::convert::get_bytes_per_item(_stream_args.cpu_format);
+ _rx_stream->recv(outputs, nbytes/bpi, _metadata, 0.0);
+#else
+ _dev->get_device()->recv
+ (outputs, nbytes/_type->size, _metadata, *_type,
+ ::uhd::device::RECV_MODE_FULL_BUFF, 0.0);
+#endif
+ if(_metadata.error_code == ::uhd::rx_metadata_t::ERROR_CODE_TIMEOUT)
+ break;
+ }
+ }
+
+ bool
+ usrp_source_impl::stop(void)
+ {
+ _dev->issue_stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
+
+ this->flush();
+
+ return true;
+ }
+
+ std::vector<std::complex<float> >
+ usrp_source_impl::finite_acquisition(const size_t nsamps)
+ {
+ if(_nchan != 1)
+ throw std::runtime_error("finite_acquisition: usrp source has multiple channels, call finite_acquisition_v");
+ return finite_acquisition_v(nsamps).front();
+ }
+
+ std::vector<std::vector<std::complex<float> > >
+ usrp_source_impl::finite_acquisition_v(const size_t nsamps)
+ {
+#ifdef GR_UHD_USE_STREAM_API
+ //kludgy way to ensure rx streamer exsists
+ if(!_rx_stream) {
+ this->start();
+ this->stop();
+ }
+
+ //flush so there is no queued-up data
+ this->flush();
+
+ //create a multi-dimensional container to hold an array of sample buffers
+ std::vector<std::vector<std::complex<float> > >
+ samps(_nchan, std::vector<std::complex<float> >(nsamps));
+
+ //load the void* vector of buffer pointers
+ std::vector<void *> buffs(_nchan);
+ for(size_t i = 0; i < _nchan; i++) {
+ buffs[i] = &samps[i].front();
+ }
+
+ //tell the device to stream a finite amount
+ ::uhd::stream_cmd_t cmd(::uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
+ cmd.num_samps = nsamps;
+ cmd.stream_now = _stream_now;
+ static const double reasonable_delay = 0.1; //order of magnitude over RTT
+ cmd.time_spec = get_time_now() + ::uhd::time_spec_t(reasonable_delay);
+ _dev->issue_stream_cmd(cmd);
+
+ //receive samples until timeout
+ const size_t actual_num_samps = _rx_stream->recv
+ (buffs, nsamps, _metadata, 1.0);
+
+ //resize the resulting sample buffers
+ for(size_t i = 0; i < _nchan; i++) {
+ samps[i].resize(actual_num_samps);
+ }
+
+ return samps;
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
+ int
+ usrp_source_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+#ifdef GR_UHD_USE_STREAM_API
+ //In order to allow for low-latency:
+ //We receive all available packets without timeout.
+ //This call can timeout under regular operation...
+ size_t num_samps = _rx_stream->recv
+ (output_items, noutput_items, _metadata, 0.0);
+
+ //If receive resulted in a timeout condition:
+ //We now receive a single packet with a large timeout.
+ if(_metadata.error_code == ::uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) {
+ num_samps = _rx_stream->recv
+ (output_items, noutput_items, _metadata, 0.1, true/*one pkt*/);
+ }
+#else
+ size_t num_samps = _dev->get_device()->recv
+ (output_items, noutput_items, _metadata,
+ *_type, ::uhd::device::RECV_MODE_FULL_BUFF, 0.0);
+
+ if(_metadata.error_code == ::uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) {
+ num_samps = _dev->get_device()->recv
+ (output_items, noutput_items, _metadata, *_type,
+ ::uhd::device::RECV_MODE_ONE_PACKET, 1.0);
+ }
+#endif
+
+ //handle possible errors conditions
+ switch(_metadata.error_code) {
+ case ::uhd::rx_metadata_t::ERROR_CODE_NONE:
+ if(_tag_now) {
+ _tag_now = false;
+ //create a timestamp pmt for the first sample
+ const pmt::pmt_t val = pmt::make_tuple
+ (pmt::from_uint64(_metadata.time_spec.get_full_secs()),
+ pmt::from_double(_metadata.time_spec.get_frac_secs()));
+ //create a tag set for each channel
+ for(size_t i = 0; i < _nchan; i++) {
+ this->add_item_tag(i, nitems_written(0), TIME_KEY, val, _id);
+ this->add_item_tag(i, nitems_written(0), RATE_KEY,
+ pmt::from_double(_samp_rate), _id);
+ this->add_item_tag(i, nitems_written(0), FREQ_KEY,
+ pmt::from_double(_center_freq), _id);
+ }
+ }
+ break;
+
+ case ::uhd::rx_metadata_t::ERROR_CODE_TIMEOUT:
+ //its ok to timeout, perhaps the user is doing finite streaming
+ return 0;
+
+ case ::uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
+ _tag_now = true;
+ //ignore overflows and try work again
+ return work(noutput_items, input_items, output_items);
+
+ default:
+ std::cout << boost::format("UHD source block got error code 0x%x")
+ % _metadata.error_code << std::endl;
+ return num_samps;
+ }
+
+ return num_samps;
+ }
+
+ } /* namespace uhd */
+} /* namespace gr */
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
new file mode 100644
index 0000000000..b0b04a795b
--- /dev/null
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -0,0 +1,144 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2010-2013 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <uhd/usrp_source.h>
+#include <uhd/convert.hpp>
+
+static const pmt::pmt_t TIME_KEY = pmt::string_to_symbol("rx_time");
+static const pmt::pmt_t RATE_KEY = pmt::string_to_symbol("rx_rate");
+static const pmt::pmt_t FREQ_KEY = pmt::string_to_symbol("rx_freq");
+
+namespace gr {
+ namespace uhd {
+
+ inline gr_io_signature_sptr
+ args_to_io_sig(const ::uhd::stream_args_t &args)
+ {
+ const size_t nchan = std::max<size_t>(args.channels.size(), 1);
+#ifdef GR_UHD_USE_STREAM_API
+ const size_t size = ::uhd::convert::get_bytes_per_item(args.cpu_format);
+#else
+ size_t size = 0;
+ if(args.cpu_format == "fc32")
+ size = 8;
+ if(args.cpu_format == "sc16")
+ size = 4;
+#endif
+ return gr_make_io_signature(nchan, nchan, size);
+ }
+
+ /***********************************************************************
+ * UHD Multi USRP Source Impl
+ **********************************************************************/
+ class usrp_source_impl : public usrp_source
+ {
+ public:
+ usrp_source_impl(const ::uhd::device_addr_t &device_addr,
+ const ::uhd::stream_args_t &stream_args);
+ ~usrp_source_impl();
+
+ // Get Commands
+ ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan);
+ std::string get_subdev_spec(size_t mboard);
+ double get_samp_rate(void);
+ ::uhd::meta_range_t get_samp_rates(void);
+ double get_center_freq(size_t chan);
+ ::uhd::freq_range_t get_freq_range(size_t chan);
+ double get_gain(size_t chan);
+ double get_gain(const std::string &name, size_t chan);
+ std::vector<std::string> get_gain_names(size_t chan);
+ ::uhd::gain_range_t get_gain_range(size_t chan);
+ ::uhd::gain_range_t get_gain_range(const std::string &name, size_t chan);
+ std::string get_antenna(size_t chan);
+ std::vector<std::string> get_antennas(size_t chan);
+ ::uhd::sensor_value_t get_sensor(const std::string &name, size_t chan);
+ std::vector<std::string> get_sensor_names(size_t chan);
+ ::uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard);
+ std::vector<std::string> get_mboard_sensor_names(size_t mboard);
+ std::string get_time_source(const size_t mboard);
+ std::vector<std::string> get_time_sources(const size_t mboard);
+ std::string get_clock_source(const size_t mboard);
+ std::vector<std::string> get_clock_sources(const size_t mboard);
+ double get_clock_rate(size_t mboard);
+ ::uhd::time_spec_t get_time_now(size_t mboard = 0);
+ ::uhd::time_spec_t get_time_last_pps(size_t mboard);
+ ::uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan);
+ ::uhd::usrp::multi_usrp::sptr get_device(void);
+
+ // Set Commands
+ void set_subdev_spec(const std::string &spec, size_t mboard);
+ void set_samp_rate(double rate);
+ ::uhd::tune_result_t set_center_freq(const ::uhd::tune_request_t tune_request,
+ size_t chan);
+ void set_gain(double gain, size_t chan);
+ void set_gain(double gain, const std::string &name, size_t chan);
+ void set_antenna(const std::string &ant, size_t chan);
+ void set_bandwidth(double bandwidth, size_t chan);
+ void set_auto_dc_offset(const bool enable, size_t chan);
+ void set_dc_offset(const std::complex<double> &offset, size_t chan);
+ void set_iq_balance(const std::complex<double> &correction, size_t chan);
+ void set_clock_config(const ::uhd::clock_config_t &clock_config, size_t mboard);
+ void set_time_source(const std::string &source, const size_t mboard);
+ void set_clock_source(const std::string &source, const size_t mboard);
+ void set_clock_rate(double rate, size_t mboard);
+ void set_time_now(const ::uhd::time_spec_t &time_spec, size_t mboard);
+ void set_time_next_pps(const ::uhd::time_spec_t &time_spec);
+ void set_time_unknown_pps(const ::uhd::time_spec_t &time_spec);
+ void set_command_time(const ::uhd::time_spec_t &time_spec, size_t mboard);
+ void set_user_register(const uint8_t addr, const uint32_t data, size_t mboard);
+ void set_start_time(const ::uhd::time_spec_t &time);
+
+ void issue_stream_cmd(const ::uhd::stream_cmd_t &cmd);
+ void clear_command_time(size_t mboard);
+ void flush(void);
+ bool start(void);
+ bool stop(void);
+ std::vector<std::complex<float> > finite_acquisition(const size_t nsamps);
+ std::vector<std::vector<std::complex<float> > > finite_acquisition_v(const size_t nsamps);
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ private:
+ ::uhd::usrp::multi_usrp::sptr _dev;
+ const ::uhd::stream_args_t _stream_args;
+ boost::shared_ptr< ::uhd::io_type_t > _type;
+
+#ifdef GR_UHD_USE_STREAM_API
+ ::uhd::rx_streamer::sptr _rx_stream;
+ size_t _samps_per_packet;
+#endif
+ size_t _nchan;
+ bool _stream_now, _tag_now;
+ ::uhd::rx_metadata_t _metadata;
+ pmt::pmt_t _id;
+
+ ::uhd::time_spec_t _start_time;
+ bool _start_time_set;
+
+ //tag shadows
+ double _samp_rate;
+ double _center_freq;
+ };
+
+ } /* namespace uhd */
+} /* namespace gr */
diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i
index 99258c0f5e..8ab4d59f3e 100644
--- a/gr-uhd/swig/uhd_swig.i
+++ b/gr-uhd/swig/uhd_swig.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2010-2012 Free Software Foundation, Inc.
+ * Copyright 2010-2013 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -41,9 +41,9 @@
// block headers
////////////////////////////////////////////////////////////////////////
%{
-#include <gr_uhd_usrp_source.h>
-#include <gr_uhd_usrp_sink.h>
-#include <gr_uhd_amsg_source.h>
+#include <uhd/usrp_source.h>
+#include <uhd/usrp_sink.h>
+#include <uhd/amsg_source.h>
%}
////////////////////////////////////////////////////////////////////////
@@ -99,14 +99,13 @@
////////////////////////////////////////////////////////////////////////
// block magic
////////////////////////////////////////////////////////////////////////
-GR_SWIG_BLOCK_MAGIC(uhd,usrp_source)
-%include <gr_uhd_usrp_source.h>
+%include <uhd/usrp_source.h>
+%include <uhd/usrp_sink.h>
+%include <uhd/amsg_source.h>
-GR_SWIG_BLOCK_MAGIC(uhd,usrp_sink)
-%include <gr_uhd_usrp_sink.h>
-
-GR_SWIG_BLOCK_MAGIC(uhd,amsg_source)
-%include <gr_uhd_amsg_source.h>
+GR_SWIG_BLOCK_MAGIC2(uhd, usrp_source)
+GR_SWIG_BLOCK_MAGIC2(uhd, usrp_sink)
+GR_SWIG_BLOCK_MAGIC2(uhd, amsg_source)
////////////////////////////////////////////////////////////////////////
// device discovery (no need to %include device.hpp)