diff options
159 files changed, 7005 insertions, 1721 deletions
diff --git a/docs/howto-write-a-block/.gitignore b/docs/howto-write-a-block/.gitignore index 719ea5d4f..f65ab6cf7 100644 --- a/docs/howto-write-a-block/.gitignore +++ b/docs/howto-write-a-block/.gitignore @@ -1 +1,18 @@ +/Makefile +/Makefile.in +/.deps +/.libs +/*.la +/*.lo +/autom4te.cache +/*.cache /howto-write-a-block.html +/gr_block.h.xml +/howto_1.i.xml +/howto_square_ff.cc.xml +/howto_square_ff.h.xml +/qa_howto_1.py.xml +/src_lib_Makefile_1.am.xml +/src_lib_Makefile_2.am.xml +/howto_square2_ff.cc.xml +/howto_square2_ff.h.xml diff --git a/gr-howto-write-a-block/doc/Makefile.am b/docs/howto-write-a-block/Makefile.am index 0152ecad4..5f58a21e9 100644 --- a/gr-howto-write-a-block/doc/Makefile.am +++ b/docs/howto-write-a-block/Makefile.am @@ -21,7 +21,6 @@ TARGETS = howto-write-a-block.html - # To avoid build problems for folks who don't have xmlto installed, we # don't build the docs by default. @@ -30,6 +29,7 @@ all: $(TARGETS) EXTRA_DIST = \ + README \ howto-write-a-block.xml \ howto_1.i \ make_numbered_listing.py \ diff --git a/docs/howto-write-a-block/README b/docs/howto-write-a-block/README index 73b8e6028..ff3b75e57 100644 --- a/docs/howto-write-a-block/README +++ b/docs/howto-write-a-block/README @@ -1,3 +1 @@ -If you're looking for howto-write-a-block, it was moved into it's own -tarball: gr-howto-write-a-block. It includes the document source -and a full build tree, Makefiles, examples, etc. +The contents of this directory are obsolete. diff --git a/gr-howto-write-a-block/doc/howto-write-a-block.xml b/docs/howto-write-a-block/howto-write-a-block.xml index f8027b456..f8027b456 100644 --- a/gr-howto-write-a-block/doc/howto-write-a-block.xml +++ b/docs/howto-write-a-block/howto-write-a-block.xml diff --git a/gr-howto-write-a-block/doc/howto_1.i b/docs/howto-write-a-block/howto_1.i index 640d0897b..640d0897b 100644 --- a/gr-howto-write-a-block/doc/howto_1.i +++ b/docs/howto-write-a-block/howto_1.i diff --git a/gr-howto-write-a-block/doc/make_numbered_listing.py b/docs/howto-write-a-block/make_numbered_listing.py index 889c2d78d..889c2d78d 100755 --- a/gr-howto-write-a-block/doc/make_numbered_listing.py +++ b/docs/howto-write-a-block/make_numbered_listing.py diff --git a/gr-howto-write-a-block/doc/qa_howto_1.py b/docs/howto-write-a-block/qa_howto_1.py index 3173110f8..3173110f8 100755 --- a/gr-howto-write-a-block/doc/qa_howto_1.py +++ b/docs/howto-write-a-block/qa_howto_1.py diff --git a/gr-howto-write-a-block/doc/src_lib_Makefile_1.am b/docs/howto-write-a-block/src_lib_Makefile_1.am index e97d70d1c..e97d70d1c 100644 --- a/gr-howto-write-a-block/doc/src_lib_Makefile_1.am +++ b/docs/howto-write-a-block/src_lib_Makefile_1.am diff --git a/gr-howto-write-a-block/doc/src_lib_Makefile_2.am b/docs/howto-write-a-block/src_lib_Makefile_2.am index dca236e20..dca236e20 100644 --- a/gr-howto-write-a-block/doc/src_lib_Makefile_2.am +++ b/docs/howto-write-a-block/src_lib_Makefile_2.am diff --git a/gnuradio-core/src/lib/general/gr_head.cc b/gnuradio-core/src/lib/general/gr_head.cc index 01035ffcd..b52735c06 100644 --- a/gnuradio-core/src/lib/general/gr_head.cc +++ b/gnuradio-core/src/lib/general/gr_head.cc @@ -27,7 +27,7 @@ #include <gr_io_signature.h> #include <string.h> -gr_head::gr_head (size_t sizeof_stream_item, int nitems) +gr_head::gr_head (size_t sizeof_stream_item, unsigned long long nitems) : gr_sync_block ("head", gr_make_io_signature (1, 1, sizeof_stream_item), gr_make_io_signature (1, 1, sizeof_stream_item)), @@ -36,7 +36,7 @@ gr_head::gr_head (size_t sizeof_stream_item, int nitems) } gr_head_sptr -gr_make_head (size_t sizeof_stream_item, int nitems) +gr_make_head (size_t sizeof_stream_item, unsigned long long nitems) { return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems)); } @@ -49,7 +49,7 @@ gr_head::work (int noutput_items, if (d_ncopied_items >= d_nitems) return -1; // Done! - unsigned n = std::min (d_nitems - d_ncopied_items, noutput_items); + unsigned n = std::min (d_nitems - d_ncopied_items, (unsigned long long) noutput_items); if (n == 0) return 0; diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h index 430d5f8b9..f7eee1064 100644 --- a/gnuradio-core/src/lib/general/gr_head.h +++ b/gnuradio-core/src/lib/general/gr_head.h @@ -38,11 +38,11 @@ typedef boost::shared_ptr<gr_head> gr_head_sptr; class gr_head : public gr_sync_block { - friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, int nitems); - gr_head (size_t sizeof_stream_item, int nitems); + friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); + gr_head (size_t sizeof_stream_item, unsigned long long nitems); - int d_nitems; - int d_ncopied_items; + unsigned long long d_nitems; + unsigned long long d_ncopied_items; public: int work (int noutput_items, @@ -53,7 +53,7 @@ class gr_head : public gr_sync_block }; gr_head_sptr -gr_make_head (size_t sizeof_stream_item, int nitems); +gr_make_head (size_t sizeof_stream_item, unsigned long long nitems); #endif /* INCLUDED_GR_HEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i index 2a88b885f..3aece9601 100644 --- a/gnuradio-core/src/lib/general/gr_head.i +++ b/gnuradio-core/src/lib/general/gr_head.i @@ -22,7 +22,7 @@ GR_SWIG_BLOCK_MAGIC(gr,head); -gr_head_sptr gr_make_head(size_t sizeof_stream_item, int nitems); +gr_head_sptr gr_make_head(size_t sizeof_stream_item, unsigned long long nitems); class gr_head : public gr_block { gr_head(); diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc index 50d480d00..9cad687fb 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc +++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc @@ -90,7 +90,7 @@ gr_top_block_impl::~gr_top_block_impl() void gr_top_block_impl::start() { - gr_lock_guard l(d_mutex); + gruel::scoped_lock l(d_mutex); if (d_state != IDLE) throw std::runtime_error("top_block::start: top block already running or wait() not called after previous stop()"); @@ -131,14 +131,14 @@ gr_top_block_impl::wait() void gr_top_block_impl::lock() { - gr_lock_guard lock(d_mutex); + gruel::scoped_lock lock(d_mutex); d_lock_count++; } void gr_top_block_impl::unlock() { - gr_lock_guard lock(d_mutex); + gruel::scoped_lock lock(d_mutex); if (d_lock_count <= 0){ d_lock_count = 0; // fix it, then complain diff --git a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h index 35fb44ef9..ef28dd829 100644 --- a/gnuradio-core/src/lib/runtime/gr_top_block_impl.h +++ b/gnuradio-core/src/lib/runtime/gr_top_block_impl.h @@ -24,10 +24,7 @@ #define INCLUDED_GR_TOP_BLOCK_IMPL_H #include <gr_scheduler.h> -#include <boost/thread.hpp> - -typedef boost::mutex gr_mutex; // FIXME move these elsewhere -typedef boost::lock_guard<boost::mutex> gr_lock_guard; +#include <gruel/thread.h> /*! *\brief Abstract implementation details of gr_top_block @@ -69,7 +66,7 @@ protected: gr_flat_flowgraph_sptr d_ffg; gr_scheduler_sptr d_scheduler; - gr_mutex d_mutex; // protects d_state and d_lock_count + gruel::mutex d_mutex; // protects d_state and d_lock_count tb_state d_state; int d_lock_count; diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py index 4541b453b..cd9a207c8 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/dbpsk2.py @@ -187,7 +187,8 @@ class dbpsk2_demod(gr.hier_block2): timing_max_dev=_def_timing_max_dev, gray_code=_def_gray_code, verbose=_def_verbose, - log=_def_log): + log=_def_log, + sync_out=False): """ Hierarchical block for RRC-filtered differential BPSK demodulation @@ -208,14 +209,18 @@ class dbpsk2_demod(gr.hier_block2): @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool + @param log: Print modualtion data to files? + @type log: bool + @param sync_out: Output a sync signal on :1? + @type sync_out: bool """ - - gr.hier_block2.__init__(self, "dbpsk2_demod", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature - + if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex)) + else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char) + + gr.hier_block2.__init__(self, "dqpsk2_demod", + gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature + io_sig_out) # Output signature + self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._costas_alpha = costas_alpha @@ -278,6 +283,7 @@ class dbpsk2_demod(gr.hier_block2): self.clock_recov, self.time_recov, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) + if sync_out: self.connect(self.time_recov, (self, 1)) def samples_per_symbol(self): return self._samples_per_symbol diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py index 9704ac98c..fd1e9f0ef 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/dqpsk2.py @@ -187,7 +187,8 @@ class dqpsk2_demod(gr.hier_block2): timing_max_dev=_def_timing_max_dev, gray_code=_def_gray_code, verbose=_def_verbose, - log=_def_log): + log=_def_log, + sync_out=False): """ Hierarchical block for RRC-filtered DQPSK demodulation @@ -208,13 +209,17 @@ class dqpsk2_demod(gr.hier_block2): @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool - @param debug: Print modualtion data to files? - @type debug: bool + @param log: Print modualtion data to files? + @type log: bool + @param sync_out: Output a sync signal on :1? + @type sync_out: bool """ + if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex)) + else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char) gr.hier_block2.__init__(self, "dqpsk2_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_char)) # Output signature + io_sig_out) # Output signature self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw @@ -278,6 +283,7 @@ class dqpsk2_demod(gr.hier_block2): self.clock_recov, self.time_recov, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) + if sync_out: self.connect(self.time_recov, (self, 1)) def samples_per_symbol(self): return self._samples_per_symbol diff --git a/gnuradio-examples/grc/Makefile.am b/gnuradio-examples/grc/Makefile.am index 97417c5a2..f8a26bace 100644 --- a/gnuradio-examples/grc/Makefile.am +++ b/gnuradio-examples/grc/Makefile.am @@ -49,6 +49,8 @@ usrpdatadir = $(grc_examples_prefix)/usrp dist_usrpdata_DATA = \ usrp/usrp2_const_wave.grc \ usrp/usrp2_dpsk_mod.grc \ + usrp/usrp_rx_dpsk.grc \ + usrp/usrp_tx_dpsk.grc \ usrp/usrp2_fft.grc \ usrp/usrp_two_tone_loopback.grc \ usrp/usrp_wbfm_receive.grc diff --git a/gnuradio-examples/grc/usrp/usrp_rx_dpsk.grc b/gnuradio-examples/grc/usrp/usrp_rx_dpsk.grc new file mode 100644 index 000000000..9843ee6b0 --- /dev/null +++ b/gnuradio-examples/grc/usrp/usrp_rx_dpsk.grc @@ -0,0 +1,727 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Wed Dec 2 11:03:20 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>usrp_rx_dpsk</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value>USRP RX DPSK</value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></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>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(12, 9)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samps_per_sym</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>4</value> + </param> + <param> + <key>_coordinate</key> + <value>(14, 79)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>bb_freq</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>2.45e9</value> + </param> + <param> + <key>_coordinate</key> + <value>(18, 151)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>p2p</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>2.0</value> + </param> + <param> + <key>_coordinate</key> + <value>(13, 314)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>timing_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Timing Alpha</value> + </param> + <param> + <key>value</key> + <value>.1</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>.5</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(759, 365)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_null_sink</key> + <param> + <key>id</key> + <value>gr_null_sink_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(815, 80)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>costas_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Costas Alpha</value> + </param> + <param> + <key>value</key> + <value>0.175</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>.5</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(598, 367)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>wxgui_fftsink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Receive Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>bb_freq</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>-40</value> + </param> + <param> + <key>ref_scale</key> + <value>p2p</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(383, 321)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>1e6/4</value> + </param> + <param> + <key>_coordinate</key> + <value>(20, 234)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>gain</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Gain</value> + </param> + <param> + <key>value</key> + <value>20</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>70</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(152, 378)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>usrp2_source_xxxx</key> + <param> + <key>id</key> + <value>usrp2_source_xxxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>interface</key> + <value></value> + </param> + <param> + <key>mac_addr</key> + <value></value> + </param> + <param> + <key>decimation</key> + <value>int(100e6/samp_rate)</value> + </param> + <param> + <key>frequency</key> + <value>bb_freq</value> + </param> + <param> + <key>lo_offset</key> + <value>float('inf')</value> + </param> + <param> + <key>gain</key> + <value>gain</value> + </param> + <param> + <key>_coordinate</key> + <value>(158, 51)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>usrp_simple_source_x</key> + <param> + <key>id</key> + <value>usrp_simple_source_x_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>format</key> + <value></value> + </param> + <param> + <key>which</key> + <value>0</value> + </param> + <param> + <key>decimation</key> + <value>int(64e6/samp_rate)</value> + </param> + <param> + <key>frequency</key> + <value>bb_freq</value> + </param> + <param> + <key>lo_offset</key> + <value>float('inf')</value> + </param> + <param> + <key>gain</key> + <value>gain</value> + </param> + <param> + <key>side</key> + <value>B</value> + </param> + <param> + <key>rx_ant</key> + <value>TX/RX</value> + </param> + <param> + <key>hb_filters</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(154, 218)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blks2_dxpsk2_demod</key> + <param> + <key>id</key> + <value>blks2_dxpsk2_demod_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>dqpsk</value> + </param> + <param> + <key>samples_per_symbol</key> + <value>samps_per_sym</value> + </param> + <param> + <key>excess_bw</key> + <value>0.35</value> + </param> + <param> + <key>costas_alpha</key> + <value>costas_alpha</value> + </param> + <param> + <key>timing_alpha</key> + <value>timing_alpha</value> + </param> + <param> + <key>timing_max_dev</key> + <value>1.5</value> + </param> + <param> + <key>omega_relative_limit</key> + <value>0.005</value> + </param> + <param> + <key>gray_code</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>False</value> + </param> + <param> + <key>log</key> + <value>False</value> + </param> + <param> + <key>sync_out</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(487, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>wxgui_scopesink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Recovered DQPSK Constellation</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate/4/20</value> + </param> + <param> + <key>v_scale</key> + <value>0</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>True</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(760, 239)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>gr_keep_one_in_n</key> + <param> + <key>id</key> + <value>gr_keep_one_in_n_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>n</key> + <value>20</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(873, 151)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>usrp2_source_xxxx_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>usrp2_source_xxxx_0</source_block_id> + <sink_block_id>blks2_dxpsk2_demod_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blks2_dxpsk2_demod_0</source_block_id> + <sink_block_id>gr_null_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blks2_dxpsk2_demod_0</source_block_id> + <sink_block_id>gr_keep_one_in_n_0</sink_block_id> + <source_key>1</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>gr_keep_one_in_n_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gnuradio-examples/grc/usrp/usrp_tx_dpsk.grc b/gnuradio-examples/grc/usrp/usrp_tx_dpsk.grc new file mode 100644 index 000000000..90ec5e910 --- /dev/null +++ b/gnuradio-examples/grc/usrp/usrp_tx_dpsk.grc @@ -0,0 +1,583 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Thu Dec 3 11:42:41 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>usrp_tx_dpsk</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value>USRP TX DPSK</value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></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>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>variable</key> + <param> + <key>id</key> + <value>samps_per_sym</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>4</value> + </param> + <param> + <key>_coordinate</key> + <value>(15, 76)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>random_source_x</key> + <param> + <key>id</key> + <value>random_source_x_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>2**8</value> + </param> + <param> + <key>num_samps</key> + <value>1000</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(23, 319)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blks2_dxpsk2_mod</key> + <param> + <key>id</key> + <value>blks2_dxpsk2_mod_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>dqpsk</value> + </param> + <param> + <key>samples_per_symbol</key> + <value>samps_per_sym</value> + </param> + <param> + <key>excess_bw</key> + <value>0.35</value> + </param> + <param> + <key>gray_code</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>False</value> + </param> + <param> + <key>log</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(234, 151)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>usrp_simple_sink_x</key> + <param> + <key>id</key> + <value>usrp_simple_sink_x_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>which</key> + <value>0</value> + </param> + <param> + <key>interpolation</key> + <value>int(128e6/samp_rate)</value> + </param> + <param> + <key>frequency</key> + <value>bb_freq</value> + </param> + <param> + <key>lo_offset</key> + <value>float('inf')</value> + </param> + <param> + <key>gain</key> + <value>0</value> + </param> + <param> + <key>side</key> + <value>A</value> + </param> + <param> + <key>transmit</key> + <value>auto_tr</value> + </param> + <param> + <key>_coordinate</key> + <value>(516, 203)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>usrp2_sink_xxxx</key> + <param> + <key>id</key> + <value>usrp2_sink_xxxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>interface</key> + <value></value> + </param> + <param> + <key>mac_addr</key> + <value></value> + </param> + <param> + <key>interpolation</key> + <value>int(100e6/samp_rate)</value> + </param> + <param> + <key>frequency</key> + <value>bb_freq</value> + </param> + <param> + <key>lo_offset</key> + <value>float('inf')</value> + </param> + <param> + <key>gain</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(498, 51)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>tx_ampl</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>TX Amplitude</value> + </param> + <param> + <key>value</key> + <value>.2</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>1</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(277, 491)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>bb_freq</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>2.45e9+freq_off</value> + </param> + <param> + <key>_coordinate</key> + <value>(14, 141)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>freq_off</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Frequency Offset</value> + </param> + <param> + <key>value</key> + <value>0</value> + </param> + <param> + <key>min</key> + <value>-samp_rate/2</value> + </param> + <param> + <key>max</key> + <value>samp_rate/2</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(63, 483)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>p2p</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>2**15</value> + </param> + <param> + <key>_coordinate</key> + <value>(179, 37)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_multiply_const_vxx</key> + <param> + <key>id</key> + <value>gr_multiply_const_vxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>const</key> + <value>tx_ampl*p2p/2.</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(306, 355)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>wxgui_fftsink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Transmit Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>bb_freq</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>p2p</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>20</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(576, 410)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>1e6/4</value> + </param> + <param> + <key>_coordinate</key> + <value>(12, 207)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>random_source_x_0</source_block_id> + <sink_block_id>blks2_dxpsk2_mod_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blks2_dxpsk2_mod_0</source_block_id> + <sink_block_id>gr_multiply_const_vxx_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> + <sink_block_id>usrp_simple_sink_x_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> + <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-howto-write-a-block/INSTALL b/gr-howto-write-a-block/INSTALL index d3c5b40a9..8b82ade08 100644 --- a/gr-howto-write-a-block/INSTALL +++ b/gr-howto-write-a-block/INSTALL @@ -2,15 +2,15 @@ Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007 Free Software Foundation, Inc. +2006, 2007, 2008 Free Software Foundation, Inc. -This file is free documentation; the Free Software Foundation gives + This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== -Briefly, the shell commands `./configure; make; make install' should + Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. @@ -73,9 +73,9 @@ The simplest way to compile this package is: Compilers and Options ===================== -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here @@ -88,7 +88,7 @@ is an example: Compiling For Multiple Architectures ==================================== -You can compile the package for more than one kind of computer at the + You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run @@ -100,10 +100,24 @@ architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. + Installation Names ================== -By default, `make install' installs the package's commands under + By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. @@ -126,7 +140,7 @@ option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= -Some packages pay attention to `--enable-FEATURE' options to + Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The @@ -138,14 +152,36 @@ find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `<wchar.h>' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + Specifying the System Type ========================== -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: @@ -171,9 +207,9 @@ eventually be run) with `--host=TYPE'. Sharing Defaults ================ -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. @@ -182,7 +218,7 @@ A warning: not all `configure' scripts look for a site script. Defining Variables ================== -Variables not defined in a site shell script can be set in the + Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set @@ -201,11 +237,19 @@ an Autoconf bug. Until the bug is fixed you can use this workaround: `configure' Invocation ====================== -`configure' recognizes the following options to control how it operates. + `configure' recognizes the following options to control how it +operates. `--help' `-h' - Print a summary of the options to `configure', and exit. + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. `--version' `-V' @@ -232,6 +276,16 @@ an Autoconf bug. Until the bug is fixed you can use this workaround: Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. +`--prefix=DIR' + Use DIR as the installation prefix. *Note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. diff --git a/gr-howto-write-a-block/Makefile.am b/gr-howto-write-a-block/Makefile.am index 56307aada..98368c211 100644 --- a/gr-howto-write-a-block/Makefile.am +++ b/gr-howto-write-a-block/Makefile.am @@ -23,11 +23,19 @@ ACLOCAL_AMFLAGS = -I config include $(top_srcdir)/Makefile.common -EXTRA_DIST = bootstrap configure config.h.in \ - Makefile.swig Makefile.swig.gen.t +EXTRA_DIST = \ + bootstrap \ + configure \ + config.h.in \ + Makefile.swig \ + Makefile.swig.gen.t \ + version.sh \ + README \ + README.hacking -SUBDIRS = config src -DIST_SUBDIRS = config src doc +SUBDIRS = config lib swig python grc apps pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = + +DISTCLEANFILES = gr-howto-write-a-block*.tar.gz diff --git a/gr-howto-write-a-block/Makefile.common b/gr-howto-write-a-block/Makefile.common index 4b8081125..c81bc780d 100644 --- a/gr-howto-write-a-block/Makefile.common +++ b/gr-howto-write-a-block/Makefile.common @@ -50,6 +50,9 @@ swigincludedir = $(grincludedir)/swig grpythondir = $(pythondir)/gnuradio grpyexecdir = $(pyexecdir)/gnuradio +# Data directory for grc block wrappers +grc_blocksdir = $(prefix)/share/gnuradio/grc/blocks + # Don't assume that make predefines $(RM), because BSD make does # not. We define it now in configure.ac using AM_PATH_PROG, but now # here have to add a -f to be like GNU make. diff --git a/gr-howto-write-a-block/README b/gr-howto-write-a-block/README index 29c1e99b1..368e71994 100644 --- a/gr-howto-write-a-block/README +++ b/gr-howto-write-a-block/README @@ -1,5 +1,5 @@ # -# Copyright 2005, 2006 Free Software Foundation, Inc. +# Copyright 2005,2006,2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -27,7 +27,8 @@ rest of GNU Radio in order to avoid problems for people who have begun to write blocks with a modified copy of gr-howto-write-a-block. This package requires that gnuradio-core is already installed. It -also depends on some GNU Radio prerequisites, such as boost. +also depends on some GNU Radio prerequisites, such as Boost and +cppunit. To build the examples from the tarball use the normal recipe: @@ -35,16 +36,10 @@ To build the examples from the tarball use the normal recipe: $ make $ make check -If you're building from CVS, you'll need to use this sequence, since -CVS doesn't contain configure or the generated Makefiles. +If you're building from git, you'll need to use this sequence, since +git doesn't contain configure or the generated Makefiles. $ ./bootstrap $ ./configure $ make $ make check - - -The doc directory is not built by default. This is to avoid spurious -build problems on systems that don't have xmlto installed. If you -have xmlto and its dependencies installed, you can build the html -version of the howto article by cd'ing to doc and invoking make. diff --git a/gr-howto-write-a-block/README.hacking b/gr-howto-write-a-block/README.hacking new file mode 100644 index 000000000..c670fd19e --- /dev/null +++ b/gr-howto-write-a-block/README.hacking @@ -0,0 +1,95 @@ +# +# Copyright 2009 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. +# + +The layout of this tree is as follows. The top-level directory contains +the autoconf/automake build definition files: + +bootstrap +config.guess +config.sub +configure.ac +Makefile.am +Makefile.common +Makefile.swig +Makefile.swig.gen.t +version.sh + +Of these files, only configure.ac, Makefile.am, and Makefile.common would +likely need changing in order to customize this into a new out-of-tree +project. + +Subdirectory Layout +------------------- + +config - autoconf configuration macros +lib - GNU Radio blocks C++ API, shared lib and headers and QA code +swig - Generates Python API from C++ blocks +python - Pure Python modules (hierarchical blocks, other classes) +grc - GNU Radio Companion block wrappers +apps - GRC applications, scripts, or other executables installed to bin + +The 'config' directory contains autoconf configuration files which help the +configuration script discover various things about the software development +environment during the execution of the 'configure' script. These files +would likely not need any changing to customize this tree. + +The 'lib' directory contains those files needed to generate GNU Radio +signal processing blocks. These take the form of a shared library that one +dynamically links against, and header files that one would include in +their C++ GNU Radio application. This directory also contains the framework +for adding QA tests that are executed during 'make check' using the cppunit +unit testing framework. The generated shared library is installed into +$prefix/lib and the header files are installed into $prefix/include/gnuradio. + +Adding new blocks starts here, by adding new .cc and new .h files for each +new block, and modifying Makefile.am to add them to the build and link. If +desired, one can add unit tests to the QA framework that get executed during +'make check'. + +The 'swig' directory contains the SWIG machinery to create a Python module +that exports the C++ API into a Python namespace. Each GNU Radio block gets a +.i file (using SWIG syntax). The master howto.i file must also have a line +to include the block header file and a line to import the block .i file. The +resulting _howto_swig.so and _howto_swig.py files are installed into the +system Python lib directory under gnuradio/howto and become part of the +gnuradio.howto Python namespace. The Makefile.am must be customized to +recognize new files created here. + +The 'python' directory contains pure Python modules that get installed into +the system Python lib directory under gnuradio/howto and the __init__.py +module needed to turn the directory into the gnuradio.howto namespace. +This is the appropriate place to put hierarchical blocks and utility classes. +Be sure to edit the __init__.py to add your module/symbol imports as +necessary, and to modify the Makefile.am accordingly. + +This directory also contains Python-based QA code, which is executed during +'make check'. + +The 'grc' directory contains the XML-based wrappers that describe your blocks +to the GNU Radio Companion graphical flowgraph editor. These get installed +into the $prefix/share/gnuradio/grc/blocks directory and require modification +of the Makefile.am to recognize new files put here. Note: GRC only scans the +system directory for wrapper files, so you must do a 'make install' before +GRC will see your new files or modifications to existing ones. + +The 'apps' directory contains those Python and C++ programs which are to be +installed into the system $prefix/bin directory. (FIXME: there is not +currently an example of building a C++ binary in this directory.) diff --git a/gr-howto-write-a-block/apps/.gitignore b/gr-howto-write-a-block/apps/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-howto-write-a-block/apps/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-howto-write-a-block/src/Makefile.am b/gr-howto-write-a-block/apps/Makefile.am index 4c8650d7d..85ed222cf 100644 --- a/gr-howto-write-a-block/src/Makefile.am +++ b/gr-howto-write-a-block/apps/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2009 Free Software Foundation, Inc. +# Copyright 2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -19,8 +19,14 @@ # Boston, MA 02110-1301, USA. # -SUBDIRS = lib +include $(top_srcdir)/Makefile.common if PYTHON -SUBDIRS += python + +dist_bin_SCRIPTS = \ + howto_square.py + +EXTRA_DIST = \ + howto_square.grc + endif diff --git a/gr-howto-write-a-block/apps/howto_square.grc b/gr-howto-write-a-block/apps/howto_square.grc new file mode 100644 index 000000000..a8563698b --- /dev/null +++ b/gr-howto-write-a-block/apps/howto_square.grc @@ -0,0 +1,325 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Thu Nov 12 11:26:07 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>howto_square</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></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>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>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>10e3</value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 170)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>sink</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>title</key> + <value>Input</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>v_scale</key> + <value>20</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0.002</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(691, 222)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>howto_square_ff</key> + <param> + <key>id</key> + <value>sqr</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(709, 344)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_throttle</key> + <param> + <key>id</key> + <value>thr</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(497, 340)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_vector_source_x</key> + <param> + <key>id</key> + <value>src</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>vector</key> + <value>[float(n)-50 for n in range(100)]</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(246, 332)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>sink2</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>title</key> + <value>Output</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>v_scale</key> + <value>0</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0.002</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(869, 324)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>thr</source_block_id> + <sink_block_id>sqr</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>src</source_block_id> + <sink_block_id>thr</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>thr</source_block_id> + <sink_block_id>sink</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>sqr</source_block_id> + <sink_block_id>sink2</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-howto-write-a-block/apps/howto_square.py b/gr-howto-write-a-block/apps/howto_square.py new file mode 100755 index 000000000..8d3d870d8 --- /dev/null +++ b/gr-howto-write-a-block/apps/howto_square.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Howto Square +# Generated: Thu Nov 12 11:26:07 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import howto +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import wx + +class howto_square(grc_wxgui.top_block_gui): + + def __init__(self): + grc_wxgui.top_block_gui.__init__(self, title="Howto Square") + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 10e3 + + ################################################## + # Blocks + ################################################## + self.sink = scopesink2.scope_sink_f( + self.GetWin(), + title="Input", + sample_rate=samp_rate, + v_scale=20, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink.win) + self.sink2 = scopesink2.scope_sink_f( + self.GetWin(), + title="Output", + sample_rate=samp_rate, + v_scale=0, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink2.win) + self.sqr = howto.square_ff() + self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1) + self.thr = gr.throttle(gr.sizeof_float*1, samp_rate) + + ################################################## + # Connections + ################################################## + self.connect((self.thr, 0), (self.sqr, 0)) + self.connect((self.src, 0), (self.thr, 0)) + self.connect((self.thr, 0), (self.sink, 0)) + self.connect((self.sqr, 0), (self.sink2, 0)) + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.sink.set_sample_rate(self.samp_rate) + self.sink2.set_sample_rate(self.samp_rate) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = howto_square() + tb.Run(True) + diff --git a/gr-howto-write-a-block/config.guess b/gr-howto-write-a-block/config.guess index f32079abd..f32079abd 100644..100755 --- a/gr-howto-write-a-block/config.guess +++ b/gr-howto-write-a-block/config.guess diff --git a/gr-howto-write-a-block/config.sub b/gr-howto-write-a-block/config.sub index 6759825a5..6759825a5 100644..100755 --- a/gr-howto-write-a-block/config.sub +++ b/gr-howto-write-a-block/config.sub diff --git a/gr-howto-write-a-block/config/Makefile.am b/gr-howto-write-a-block/config/Makefile.am index 5858d2219..23f4a4b16 100644 --- a/gr-howto-write-a-block/config/Makefile.am +++ b/gr-howto-write-a-block/config/Makefile.am @@ -49,6 +49,7 @@ m4macros = \ gr_check_usrp.m4 \ gr_doxygen.m4 \ gr_fortran.m4 \ + gr_git.m4 \ gr_gprof.m4 \ gr_lib64.m4 \ gr_libgnuradio_core_extra_ldflags.m4 \ @@ -63,6 +64,7 @@ m4macros = \ gr_subversion.m4 \ gr_swig.m4 \ gr_sysv_shm.m4 \ + gr_version.m4 \ lf_cc.m4 \ lf_cxx.m4 \ lf_warnings.m4 \ diff --git a/gr-howto-write-a-block/config/gr_fortran.m4 b/gr-howto-write-a-block/config/gr_fortran.m4 index b5b0470f4..033ef0307 100644 --- a/gr-howto-write-a-block/config/gr_fortran.m4 +++ b/gr-howto-write-a-block/config/gr_fortran.m4 @@ -29,4 +29,5 @@ AC_DEFUN([GR_FORTRAN],[ AC_PROG_F77 AC_F77_LIBRARY_LDFLAGS fi + AC_PROG_CC dnl bug fix to restore $ac_ext ]) diff --git a/gr-howto-write-a-block/config/gr_git.m4 b/gr-howto-write-a-block/config/gr_git.m4 new file mode 100644 index 000000000..5fe424808 --- /dev/null +++ b/gr-howto-write-a-block/config/gr_git.m4 @@ -0,0 +1,35 @@ +dnl Copyright 2009 Free Software Foundation, Inc. +dnl +dnl This file is part of GNU Radio +dnl +dnl GNU Radio is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3, or (at your option) +dnl any later version. +dnl +dnl GNU Radio is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with GNU Radio; see the file COPYING. If not, write to +dnl the Free Software Foundation, Inc., 51 Franklin Street, +dnl Boston, MA 02110-1301, USA. + + +AC_DEFUN([GR_GIT],[ + dnl Identify git binary + AC_PATH_PROG([GIT],[git]) + + dnl If it exists, get either 'git describe' or fallback to current commit + if test x$GIT != x ; then + if (cd $srcdir && $GIT describe >/dev/null 2>&1); then + GIT_VERSION=`cd $srcdir && $GIT describe --abbrev=8 | cut -f 2- -d '-'` + else + if (cd $srcdir && $GIT describe --always --abbrev=8 >/dev/null 2>&1); then + GIT_VERSION=`cd $srcdir && $GIT describe --always --abbrev=8` + fi + fi + fi +]) diff --git a/gr-howto-write-a-block/config/gr_pwin32.m4 b/gr-howto-write-a-block/config/gr_pwin32.m4 index 7b99cba6b..495e9dd4d 100644 --- a/gr-howto-write-a-block/config/gr_pwin32.m4 +++ b/gr-howto-write-a-block/config/gr_pwin32.m4 @@ -99,6 +99,9 @@ struct timespec { long tv_nsec; }; #endif +#if HAVE_UNISTD_H +#include <unistd.h> +#endif static inline int nanosleep(const struct timespec *req, struct timespec *rem) { return usleep(req->tv_sec*1000000+req->tv_nsec/1000); } #endif diff --git a/gr-howto-write-a-block/config/gr_python.m4 b/gr-howto-write-a-block/config/gr_python.m4 index 6c862bba3..43ccfc015 100644 --- a/gr-howto-write-a-block/config/gr_python.m4 +++ b/gr-howto-write-a-block/config/gr_python.m4 @@ -123,6 +123,50 @@ print path ;; esac + case $host_os in + *mingw* ) + # Python 2.5 requires ".pyd" instead of ".dll" for extensions + PYTHON_LDFLAGS="-shrext .pyd ${PYTHON_LDFLAGS}" + esac + AC_SUBST(PYTHON_LDFLAGS) fi ]) + +# PYTHON_CHECK_MODULE +# +# Determines if a particular Python module can be imported +# +# $1 - module name +# $2 - module description +# $3 - action if found +# $4 - action if not found +# $5 - test command + +AC_DEFUN([PYTHON_CHECK_MODULE],[ + AC_MSG_CHECKING([for $2]) + dnl ######################################## + dnl # import and test checking + dnl ######################################## + if test "$5"; then + python_cmd=' +try: + import $1 + assert $5 +except: exit(1)' + dnl ######################################## + dnl # import checking only + dnl ######################################## + else + python_cmd=' +try: import $1 +except: exit(1)' + fi + if ! $PYTHON -c "$python_cmd" 2> /dev/null; then + AC_MSG_RESULT([no]) + $4 + else + AC_MSG_RESULT([yes]) + $3 + fi +]) diff --git a/gr-howto-write-a-block/config/gr_set_md_cpu.m4 b/gr-howto-write-a-block/config/gr_set_md_cpu.m4 index b9c570ede..7ebf88a66 100644 --- a/gr-howto-write-a-block/config/gr_set_md_cpu.m4 +++ b/gr-howto-write-a-block/config/gr_set_md_cpu.m4 @@ -1,5 +1,5 @@ dnl -dnl Copyright 2003,2008 Free Software Foundation, Inc. +dnl Copyright 2003,2008,2009 Free Software Foundation, Inc. dnl dnl This file is part of GNU Radio dnl @@ -19,20 +19,89 @@ dnl the Free Software Foundation, Inc., 51 Franklin Street, dnl Boston, MA 02110-1301, USA. dnl +AC_DEFUN([_TRY_ADD_ALTIVEC], +[ + LF_CHECK_CC_FLAG([-mabi=altivec -maltivec]) + LF_CHECK_CXX_FLAG([-mabi=altivec -maltivec]) +]) + +AC_DEFUN([_FIND_ARM_ISA], +[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[#ifndef __ARM_ARCH_5__ + #error "Not armv5" + #endif + ]])], + [is_armv5=yes], + [is_armv5=no]) + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[#ifndef __ARM_ARCH_7A__ + #error "Not armv7-a" + #endif + ]])], + [is_armv7_a=yes], + [is_armv7_a=no]) + +]) + AC_DEFUN([GR_SET_MD_CPU],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_WITH(md-cpu, - [ --with-md-cpu=ARCH set machine dependent speedups (auto)], + AC_HELP_STRING([--with-md-cpu=ARCH],[set machine dependent speedups (auto)]), [cf_with_md_cpu="$withval"], - [cf_with_md_cpu="$host_cpu"]) - - AC_MSG_CHECKING([for machine dependent speedups]) + [ + dnl see if the user has specified --host or --build, via 'cross_compiling' + if test "$cross_compiling" != no; then + dnl when cross-compiling, because the user specified it either via + dnl --target or --build, just keep the user's specs & hope for the best. + cf_with_md_cpu="$host_cpu" + else + dnl when the user didn't specify --target or --build, on Darwin 10 + dnl (OSX 10.6.0 and .1) and GNU libtoool 2.2.6, 'configure' doesn't + dnl figure out the CPU type correctly, so do it by hand here using + dnl the sizeof (void*): if 4 then use i386, and otherwise use x86_64. + case "$host_os" in + *darwin*10*) + AC_CHECK_SIZEOF(void*) + if test "$ac_cv_sizeof_voidp" = 4; then + cf_with_md_cpu="i386" + else + cf_with_md_cpu="x86_64" + fi + ;; + *) + cf_with_md_cpu="$host_cpu" + ;; + esac + fi + ]) case "$cf_with_md_cpu" in x86 | i[[3-7]]86) MD_CPU=x86 MD_SUBCPU=x86 ;; x86_64) MD_CPU=x86 MD_SUBCPU=x86_64 ;; powerpc*) MD_CPU=powerpc ;; + arm) + _FIND_ARM_ISA + if test $is_armv5 = yes; then MD_CPU=armv5; + elif test $is_armv7_a = yes; then MD_CPU=armv7_a; + else MD_CPU=generic; fi + ;; *) MD_CPU=generic ;; esac + + AC_ARG_ENABLE(altivec, + AC_HELP_STRING([--enable-altivec],[enable altivec on PowerPC (yes)]), + [ if test $MD_CPU = powerpc; then + case "$enableval" in + (no) MD_CPU=generic ;; + (yes) _TRY_ADD_ALTIVEC ;; + (*) AC_MSG_ERROR([Invalid argument ($enableval) to --enable-altivec]) ;; + esac + fi], + [ if test $MD_CPU = powerpc; then _TRY_ADD_ALTIVEC fi]) + + + AC_MSG_CHECKING([for machine dependent speedups]) AC_MSG_RESULT($MD_CPU) AC_SUBST(MD_CPU) AC_SUBST(MD_SUBCPU) @@ -40,5 +109,7 @@ AC_DEFUN([GR_SET_MD_CPU],[ AM_CONDITIONAL(MD_CPU_x86, test "$MD_CPU" = "x86") AM_CONDITIONAL(MD_SUBCPU_x86_64, test "$MD_SUBCPU" = "x86_64") AM_CONDITIONAL(MD_CPU_powerpc, test "$MD_CPU" = "powerpc") + AM_CONDITIONAL(MD_CPU_armv5, test "$MD_CPU" = "armv5") + AM_CONDITIONAL(MD_CPU_armv7_a, test "$MD_CPU" = "armv7_a") AM_CONDITIONAL(MD_CPU_generic, test "$MD_CPU" = "generic") ]) diff --git a/gr-howto-write-a-block/config/gr_standalone.m4 b/gr-howto-write-a-block/config/gr_standalone.m4 index 2f8851676..3f8ddf1d6 100644 --- a/gr-howto-write-a-block/config/gr_standalone.m4 +++ b/gr-howto-write-a-block/config/gr_standalone.m4 @@ -31,12 +31,6 @@ m4_define([GR_STANDALONE], AC_CONFIG_SRCDIR([config/gr_standalone.m4]) AM_CONFIG_HEADER(config.h) - AC_CANONICAL_BUILD - AC_CANONICAL_HOST - AC_CANONICAL_TARGET - - AM_INIT_AUTOMAKE - dnl Remember if the user explicity set CXXFLAGS if test -n "${CXXFLAGS}"; then user_set_cxxflags=yes @@ -130,4 +124,12 @@ m4_define([GR_STANDALONE], [enable_python=yes] ) AM_CONDITIONAL([PYTHON], [test x$enable_python = xyes]) + + dnl Define where to look for cppunit includes and libs + dnl sets CPPUNIT_CFLAGS and CPPUNIT_LIBS + dnl Try using pkg-config first, then fall back to cppunit-config. + PKG_CHECK_EXISTS(cppunit, + [PKG_CHECK_MODULES(CPPUNIT, cppunit >= 1.9.14)], + [AM_PATH_CPPUNIT([1.9.14],[], + [AC_MSG_ERROR([GNU Radio requires cppunit. Stop])])]) ]) diff --git a/gr-howto-write-a-block/config/gr_version.m4 b/gr-howto-write-a-block/config/gr_version.m4 new file mode 100644 index 000000000..3360b7d54 --- /dev/null +++ b/gr-howto-write-a-block/config/gr_version.m4 @@ -0,0 +1,74 @@ +dnl Copyright 2009 Free Software Foundation, Inc. +dnl +dnl This file is part of GNU Radio +dnl +dnl GNU Radio is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3, or (at your option) +dnl any later version. +dnl +dnl GNU Radio is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with GNU Radio; see the file COPYING. If not, write to +dnl the Free Software Foundation, Inc., 51 Franklin Street, +dnl Boston, MA 02110-1301, USA. + +AC_DEFUN([GR_VERSION],[ + dnl Computed version based on version.sh + dnl Does not force recompile on rev change + dnl + dnl Source the variables describing the release version + dnl + dnl MAJOR_VERSION Major release generation (2.x, 3.x, etc.) + dnl API_COMPAT API compatibility version (3.2.x, 3.3.x, etc.) + dnl MINOR_VERSION Minor release version + dnl MAINT_VERSION Pure bugfix additions to make maintenance release + dnl + dnl The last two fields can have 'git' instead of a number to indicate + dnl that this branch is between versions. + . $srcdir/version.sh + RELEASE=$MAJOR_VERSION.$API_COMPAT + + dnl Get git version if available + GR_GIT + + dnl Test if we should use git version + if test "$MINOR_VERSION" == "git"; then + dnl 3.3git-xxx-gxxxxxxxx + RELEASE=$RELEASE$MINOR_VERSION + DOCVER=$RELEASE + if test "$GIT_VERSION" != "" ; then + RELEASE=$RELEASE-$GIT_VERSION + fi + else + if test "$MAINT_VERSION" == "git" ; then + dnl 3.3.1git-xxx-gxxxxxxxx + RELEASE=$RELEASE.$MINOR_VERSION$MAINT_VERSION + DOCVER=$RELEASE + if test "$GIT_VERSION" != "" ; then + RELEASE=$RELEASE-$GIT_VERSION + fi + else + dnl This is a numbered reelase. + dnl Test if minor version is 0, which we don't encode, unless it is also + dnl a maintenance release + if test "$MINOR_VERSION" != "0" -o "$MAINT_VERSION" != "0"; then + dnl 3.3.1 + RELEASE=$RELEASE.$MINOR_VERSION + if test "$MAINT_VERSION" != "0"; then + dnl 3.3.0.1, 3.3.1.1 + RELEASE=$RELEASE.$MAINT_VERSION + fi + DOCVER=$RELEASE + fi + fi + fi + + AC_MSG_NOTICE([GNU Radio Release $RELEASE]) + AC_SUBST(RELEASE) + AC_SUBST(DOCVER) +]) diff --git a/gr-howto-write-a-block/config/lf_warnings.m4 b/gr-howto-write-a-block/config/lf_warnings.m4 index 4e2ca9111..d40c77f14 100644 --- a/gr-howto-write-a-block/config/lf_warnings.m4 +++ b/gr-howto-write-a-block/config/lf_warnings.m4 @@ -1,4 +1,5 @@ dnl Copyright (C) 1988 Eleftherios Gkioulekas <lf@amath.washington.edu> +dnl Copyright (C) 2009 Free Software Foundation, Inc. dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by @@ -21,7 +22,7 @@ dnl distribution terms that you use for the rest of that program. # -------------------------------------------------------------------------- # Check whether the C++ compiler accepts a certain flag -# If it does it adds the flag to CXXFLAGS +# If it does it adds the flag to lf_CXXFLAGS # If it does not then it returns an error to lf_ok # Usage: # LF_CHECK_CXX_FLAG(-flag1 -flag2 -flag3 ...) @@ -34,18 +35,19 @@ AC_DEFUN([LF_CHECK_CXX_FLAG],[ AC_MSG_CHECKING([whether $CXX accepts $i]) if test -z "`${CXX} $i -c conftest.cc 2>&1`" then - CXXFLAGS="${CXXFLAGS} $i" + lf_CXXFLAGS="${lf_CXXFLAGS} $i" AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi done rm -f conftest.cc conftest.o + AC_SUBST(lf_CXXFLAGS) ]) # -------------------------------------------------------------------------- # Check whether the C compiler accepts a certain flag -# If it does it adds the flag to CFLAGS +# If it does it adds the flag to lf_CFLAGS # If it does not then it returns an error to lf_ok # Usage: # LF_CHECK_CC_FLAG(-flag1 -flag2 -flag3 ...) @@ -58,18 +60,19 @@ AC_DEFUN([LF_CHECK_CC_FLAG],[ AC_MSG_CHECKING([whether $CC accepts $i]) if test -z "`${CC} $i -c conftest.c 2>&1`" then - CFLAGS="${CFLAGS} $i" + lf_CFLAGS="${lf_CFLAGS} $i" AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi done rm -f conftest.c conftest.o + AC_SUBST(lf_CFLAGS) ]) # -------------------------------------------------------------------------- # Check whether the Fortran compiler accepts a certain flag -# If it does it adds the flag to FFLAGS +# If it does it adds the flag to lf_FFLAGS # If it does not then it returns an error to lf_ok # Usage: # LF_CHECK_F77_FLAG(-flag1 -flag2 -flag3 ...) @@ -87,42 +90,32 @@ EOF AC_MSG_CHECKING([whether $F77 accepts $i]) if test -z "`${F77} $i -c conftest.f 2>&1`" then - FFLAGS="${FFLAGS} $i" + lf_FFLAGS="${lf_FFLAGS} $i" AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi done rm -f conftest.f conftest.o + AC_SUBST(lf_FFLAGS) ]) # ---------------------------------------------------------------------- -# Provide the configure script with an --with-warnings option that -# turns on warnings. Call this command AFTER you have configured ALL your -# compilers. +# Enable compiler warnings. +# Call this command AFTER you have configured ALL your compilers. # ---------------------------------------------------------------------- AC_DEFUN([LF_SET_WARNINGS],[ - dnl Check for --with-warnings - AC_MSG_CHECKING([whether user wants warnings]) - AC_ARG_WITH(warnings, - [ --with-warnings Turn on warnings], - [ lf_warnings=yes ], [ lf_warnings=no ]) - lf_warnings=yes # hard code for now -eb - AC_MSG_RESULT($lf_warnings) - dnl Warnings for the two main compilers - cc_warning_flags="-Wall" + dnl add -Wextra when you're got time to fix a bunch of them ;-) + cc_warning_flags="-Wall -Werror-implicit-function-declaration" cxx_warning_flags="-Wall -Woverloaded-virtual" - if test $lf_warnings = yes + if test -n "${CC}" then - if test -n "${CC}" - then - LF_CHECK_CC_FLAG($cc_warning_flags) - fi - if test -n "${CXX}" - then - LF_CHECK_CXX_FLAG($cxx_warning_flags) - fi + LF_CHECK_CC_FLAG($cc_warning_flags) + fi + if test -n "${CXX}" + then + LF_CHECK_CXX_FLAG($cxx_warning_flags) fi ]) diff --git a/gr-howto-write-a-block/config/usrp_fusb_tech.m4 b/gr-howto-write-a-block/config/usrp_fusb_tech.m4 index db857249b..b99cf2432 100644 --- a/gr-howto-write-a-block/config/usrp_fusb_tech.m4 +++ b/gr-howto-write-a-block/config/usrp_fusb_tech.m4 @@ -1,5 +1,5 @@ dnl -dnl Copyright 2003,2008 Free Software Foundation, Inc. +dnl Copyright 2003,2008,2009 Free Software Foundation, Inc. dnl dnl This file is part of GNU Radio dnl @@ -25,6 +25,8 @@ dnl # "" : do these tests AC_DEFUN([USRP_SET_FUSB_TECHNIQUE],[ + req_libusb1=no + USE_LIBUSB1=0 AC_ARG_WITH([fusb-tech], AC_HELP_STRING([--with-fusb-tech=OS], [Set fast USB technique (default=auto)]), @@ -32,6 +34,11 @@ AC_DEFUN([USRP_SET_FUSB_TECHNIQUE],[ [cf_with_fusb_tech="$host_os"]) if test [x]$1 != xno; then case "$cf_with_fusb_tech" in + libusb1*) + FUSB_TECH=libusb1 + req_libusb1=yes + USE_LIBUSB1=1 + ;; linux*) AC_CHECK_HEADER([linux/usbdevice_fs.h], [x_have_usbdevice_fs_h=yes], @@ -70,5 +77,11 @@ AC_DEFUN([USRP_SET_FUSB_TECHNIQUE],[ AM_CONDITIONAL(FUSB_TECH_win32, test x$FUSB_TECH = xwin32) AM_CONDITIONAL(FUSB_TECH_generic, test x$FUSB_TECH = xgeneric) AM_CONDITIONAL(FUSB_TECH_linux, test x$FUSB_TECH = xlinux) + AM_CONDITIONAL(FUSB_TECH_libusb1, test x$FUSB_TECH = xlibusb1) AM_CONDITIONAL(FUSB_TECH_ra_wb, test x$FUSB_TECH = xra_wb) + + AC_SUBST(USE_LIBUSB1) + AC_CONFIG_FILES([\ + usrp/host/include/usrp/libusb_types.h \ + ]) ]) diff --git a/gr-howto-write-a-block/configure.ac b/gr-howto-write-a-block/configure.ac index bfb431526..52c4639bb 100644 --- a/gr-howto-write-a-block/configure.ac +++ b/gr-howto-write-a-block/configure.ac @@ -19,10 +19,20 @@ dnl the Free Software Foundation, Inc., 51 Franklin Street, dnl Boston, MA 02110-1301, USA. dnl -AC_INIT(gr-howto-write-a-block,3.3svn) + +AC_INIT AC_PREREQ(2.57) AC_CONFIG_AUX_DIR([.]) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +GR_VERSION +dnl ustar required to have pathnames > 99 chars +_AM_SET_OPTION([tar-ustar]) +AM_INIT_AUTOMAKE(gr-howto-write-a-block,$RELEASE) + dnl This is kind of non-standard, but it sure shortens up this file :-) m4_include([config/gr_standalone.m4]) GR_STANDALONE @@ -61,15 +71,18 @@ dnl AX_BOOST_WSERIALIZATION AC_CONFIG_FILES([\ Makefile \ + apps/Makefile \ config/Makefile \ - doc/Makefile \ - src/Makefile \ - src/lib/Makefile \ - src/python/Makefile \ - src/python/run_tests \ + grc/Makefile \ + lib/Makefile \ + python/Makefile \ + python/run_tests \ + swig/Makefile \ ]) dnl run_tests is created from run_tests.in. Make it executable. -AC_CONFIG_COMMANDS([run_tests], [chmod +x src/python/run_tests]) +AC_CONFIG_COMMANDS([run_tests], [chmod +x python/run_tests]) AC_OUTPUT + +echo Configured gr-howto-write-a-block release $RELEASE for build. diff --git a/gr-howto-write-a-block/doc/.gitignore b/gr-howto-write-a-block/doc/.gitignore deleted file mode 100644 index f65ab6cf7..000000000 --- a/gr-howto-write-a-block/doc/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -/Makefile -/Makefile.in -/.deps -/.libs -/*.la -/*.lo -/autom4te.cache -/*.cache -/howto-write-a-block.html -/gr_block.h.xml -/howto_1.i.xml -/howto_square_ff.cc.xml -/howto_square_ff.h.xml -/qa_howto_1.py.xml -/src_lib_Makefile_1.am.xml -/src_lib_Makefile_2.am.xml -/howto_square2_ff.cc.xml -/howto_square2_ff.h.xml diff --git a/gr-howto-write-a-block/grc/.gitignore b/gr-howto-write-a-block/grc/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-howto-write-a-block/grc/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-howto-write-a-block/grc/Makefile.am b/gr-howto-write-a-block/grc/Makefile.am new file mode 100644 index 000000000..32dcf1b9e --- /dev/null +++ b/gr-howto-write-a-block/grc/Makefile.am @@ -0,0 +1,29 @@ +# +# Copyright 2009 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 $(top_srcdir)/Makefile.common + +grcblocksdir = $(grc_blocksdir) + +dist_grcblocks_DATA = \ + howto_square_ff.xml \ + howto_square2_ff.xml + diff --git a/gr-howto-write-a-block/grc/howto_square2_ff.xml b/gr-howto-write-a-block/grc/howto_square2_ff.xml new file mode 100644 index 000000000..2b46106e8 --- /dev/null +++ b/gr-howto-write-a-block/grc/howto_square2_ff.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<block> + <name>Square2</name> + <key>howto_square2_ff</key> + <category>HOWTO</category> + <import>from gnuradio import howto</import> + <make>howto.square2_ff()</make> + + <sink> + <name>in</name> + <type>float</type> + </sink> + + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-howto-write-a-block/grc/howto_square_ff.xml b/gr-howto-write-a-block/grc/howto_square_ff.xml new file mode 100644 index 000000000..ed318bfc6 --- /dev/null +++ b/gr-howto-write-a-block/grc/howto_square_ff.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<block> + <name>Square</name> + <key>howto_square_ff</key> + <category>HOWTO</category> + <import>from gnuradio import howto</import> + <make>howto.square_ff()</make> + + <sink> + <name>in</name> + <type>float</type> + </sink> + + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-howto-write-a-block/src/lib/.gitignore b/gr-howto-write-a-block/lib/.gitignore index d957a6821..b1e56d39e 100644 --- a/gr-howto-write-a-block/src/lib/.gitignore +++ b/gr-howto-write-a-block/lib/.gitignore @@ -9,3 +9,4 @@ /*.pyc /howto.cc /howto.py +/test_all
\ No newline at end of file diff --git a/gr-howto-write-a-block/lib/Makefile.am b/gr-howto-write-a-block/lib/Makefile.am new file mode 100644 index 000000000..336cb8a20 --- /dev/null +++ b/gr-howto-write-a-block/lib/Makefile.am @@ -0,0 +1,80 @@ +# +# Copyright 2004,2005,2006,2008,2009 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 $(top_srcdir)/Makefile.common + +# list of programs run by "make check" and "make distcheck" +TESTS = test_all + +# ---------------------------------------------------------------- +# howto C++ library: libgnuradio-howto.so +# ---------------------------------------------------------------- + +# C/C++ headers get installed in ${prefix}/include/gnuradio +grinclude_HEADERS = \ + howto_square_ff.h \ + howto_square2_ff.h + +lib_LTLIBRARIES = libgnuradio-howto.la + +libgnuradio_howto_la_SOURCES = \ + howto_square_ff.cc \ + howto_square2_ff.cc + +libgnuradio_howto_la_LIBADD = \ + $(GNURADIO_CORE_LA) + +libgnuradio_howto_la_LDFLAGS = \ + $(NO_UNDEFINED) + +# ---------------------------------------------------------------- +# howto C++ QA library: libgnuradio-howto-qa.so (not installed) +# ---------------------------------------------------------------- + +noinst_LTLIBRARIES = libgnuradio-howto-qa.la + +libgnuradio_howto_qa_la_SOURCES = \ + qa_howto.cc \ + qa_howto_square_ff.cc \ + qa_howto_square2_ff.cc + +libgnuradio_howto_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 + +libgnuradio_howto_qa_la_LIBADD = \ + libgnuradio-howto.la \ + $(CPPUNIT_LIBS) + +# ---------------------------------------------------------------- +# headers that don't get installed +# ---------------------------------------------------------------- +noinst_HEADERS = \ + qa_howto.h \ + qa_howto_square_ff.h \ + qa_howto_square2_ff.h + +# ---------------------------------------------------------------- +# test program +# ---------------------------------------------------------------- +noinst_PROGRAMS = \ + test_all + +test_all_SOURCES = test_all.cc +test_all_LDADD = libgnuradio-howto-qa.la diff --git a/gr-howto-write-a-block/src/lib/howto_square2_ff.cc b/gr-howto-write-a-block/lib/howto_square2_ff.cc index e86db93dd..e86db93dd 100644 --- a/gr-howto-write-a-block/src/lib/howto_square2_ff.cc +++ b/gr-howto-write-a-block/lib/howto_square2_ff.cc diff --git a/gr-howto-write-a-block/src/lib/howto_square2_ff.h b/gr-howto-write-a-block/lib/howto_square2_ff.h index 536b04fab..536b04fab 100644 --- a/gr-howto-write-a-block/src/lib/howto_square2_ff.h +++ b/gr-howto-write-a-block/lib/howto_square2_ff.h diff --git a/gr-howto-write-a-block/src/lib/howto_square_ff.cc b/gr-howto-write-a-block/lib/howto_square_ff.cc index 5ab45d1f2..5ab45d1f2 100644 --- a/gr-howto-write-a-block/src/lib/howto_square_ff.cc +++ b/gr-howto-write-a-block/lib/howto_square_ff.cc diff --git a/gr-howto-write-a-block/src/lib/howto_square_ff.h b/gr-howto-write-a-block/lib/howto_square_ff.h index 092b93698..092b93698 100644 --- a/gr-howto-write-a-block/src/lib/howto_square_ff.h +++ b/gr-howto-write-a-block/lib/howto_square_ff.h diff --git a/gr-howto-write-a-block/lib/qa_howto.cc b/gr-howto-write-a-block/lib/qa_howto.cc new file mode 100644 index 000000000..f1411a388 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto.cc @@ -0,0 +1,41 @@ +/* + * Copyright 2009 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. + */ + +/* + * This class gathers together all the test cases for the example + * directory into a single test suite. As you create new test cases, + * add them here. + */ + +#include <qa_howto.h> +#include <qa_howto_square_ff.h> +#include <qa_howto_square2_ff.h> + +CppUnit::TestSuite * +qa_howto::suite() +{ + CppUnit::TestSuite *s = new CppUnit::TestSuite("howto"); + + s->addTest(qa_howto_square_ff::suite()); + s->addTest(qa_howto_square2_ff::suite()); + + return s; +} diff --git a/gr-howto-write-a-block/lib/qa_howto.h b/gr-howto-write-a-block/lib/qa_howto.h new file mode 100644 index 000000000..fa5a42fd3 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto.h @@ -0,0 +1,36 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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 Example 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 Example Public License for more details. + * + * You should have received a copy of the GNU Example 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_QA_HOWTO_H +#define INCLUDED_QA_HOWTO_H + +#include <cppunit/TestSuite.h> + +//! collect all the tests for the example directory + +class qa_howto { + public: + //! return suite of tests for all of example directory + static CppUnit::TestSuite *suite (); +}; + +#endif /* INCLUDED_QA_HOWTO_H */ diff --git a/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc b/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc new file mode 100644 index 000000000..a37465104 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <qa_howto_square2_ff.h> +#include <cppunit/TestAssert.h> + +void +qa_howto_square2_ff::t1() +{ + // Insert CPPUNIT tests/asserts here +} + +void +qa_howto_square2_ff::t2() +{ + // Insert CPPUNIT tests/asserts here +} diff --git a/gr-howto-write-a-block/lib/qa_howto_square2_ff.h b/gr-howto-write-a-block/lib/qa_howto_square2_ff.h new file mode 100644 index 000000000..c74d0866f --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square2_ff.h @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_QA_HOWTO_SQUARE2_FF_H +#define INCLUDED_QA_HOWTO_SQUARE2_FF_H + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> + +class qa_howto_square2_ff : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_howto_square2_ff); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST_SUITE_END (); + + private: + void t1 (); + void t2 (); +}; + +#endif /* INCLUDED_QA_HOWTO_SQUARE2_FF_H */ diff --git a/gr-howto-write-a-block/lib/qa_howto_square_ff.cc b/gr-howto-write-a-block/lib/qa_howto_square_ff.cc new file mode 100644 index 000000000..2f0b59773 --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square_ff.cc @@ -0,0 +1,35 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <qa_howto_square_ff.h> +#include <cppunit/TestAssert.h> + +void +qa_howto_square_ff::t1() +{ + // Insert CPPUNIT tests/asserts here +} + +void +qa_howto_square_ff::t2() +{ + // Insert CPPUNIT tests/asserts here +} diff --git a/gr-howto-write-a-block/lib/qa_howto_square_ff.h b/gr-howto-write-a-block/lib/qa_howto_square_ff.h new file mode 100644 index 000000000..1b7c5e99f --- /dev/null +++ b/gr-howto-write-a-block/lib/qa_howto_square_ff.h @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_QA_HOWTO_SQUARE_FF_H +#define INCLUDED_QA_HOWTO_SQUARE_FF_H + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> + +class qa_howto_square_ff : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_howto_square_ff); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST_SUITE_END (); + + private: + void t1 (); + void t2 (); +}; + +#endif /* INCLUDED_QA_HOWTO_SQUARE_FF_H */ diff --git a/gr-howto-write-a-block/lib/test_all.cc b/gr-howto-write-a-block/lib/test_all.cc new file mode 100644 index 000000000..192c537bc --- /dev/null +++ b/gr-howto-write-a-block/lib/test_all.cc @@ -0,0 +1,38 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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 <cppunit/TextTestRunner.h> + +#include <qa_howto.h> + +int +main (int argc, char **argv) +{ + + CppUnit::TextTestRunner runner; + + runner.addTest(qa_howto::suite ()); + + bool was_successful = runner.run("", false); + + return was_successful ? 0 : 1; +} diff --git a/gr-howto-write-a-block/src/python/.gitignore b/gr-howto-write-a-block/python/.gitignore index bf03975bb..bf03975bb 100644 --- a/gr-howto-write-a-block/src/python/.gitignore +++ b/gr-howto-write-a-block/python/.gitignore diff --git a/gr-howto-write-a-block/src/python/Makefile.am b/gr-howto-write-a-block/python/Makefile.am index 79f44019d..4ef5fc964 100644 --- a/gr-howto-write-a-block/src/python/Makefile.am +++ b/gr-howto-write-a-block/python/Makefile.am @@ -21,12 +21,13 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = run_tests.in - +ourpythondir = $(grpythondir)/howto -TESTS = \ - run_tests +EXTRA_DIST = run_tests.in +TESTS = run_tests +ourpython_PYTHON = \ + __init__.py -noinst_PYTHON = \ +noinst_PYTHON = \ qa_howto.py diff --git a/gr-howto-write-a-block/python/__init__.py b/gr-howto-write-a-block/python/__init__.py new file mode 100644 index 000000000..d4a41c271 --- /dev/null +++ b/gr-howto-write-a-block/python/__init__.py @@ -0,0 +1,49 @@ +# +# Copyright 2008,2009 Free Software Foundation, Inc. +# +# This application 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. +# +# This application 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 this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# The presence of this file turns this directory into a Python package + +# ---------------------------------------------------------------- +# Temporary workaround for ticket:181 (swig+python problem) +import sys +_RTLD_GLOBAL = 0 +try: + from dl import RTLD_GLOBAL as _RTLD_GLOBAL +except ImportError: + try: + from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL + except ImportError: + pass + +if _RTLD_GLOBAL != 0: + _dlopenflags = sys.getdlopenflags() + sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) +# ---------------------------------------------------------------- + + +# import swig generated symbols into the howto namespace +from howto_swig import * + +# import any pure python here +# + +# ---------------------------------------------------------------- +# Tail of workaround +if _RTLD_GLOBAL != 0: + sys.setdlopenflags(_dlopenflags) # Restore original flags +# ---------------------------------------------------------------- diff --git a/gr-howto-write-a-block/src/python/qa_howto.py b/gr-howto-write-a-block/python/qa_howto.py index 0abe0e244..630f57bf4 100755 --- a/gr-howto-write-a-block/src/python/qa_howto.py +++ b/gr-howto-write-a-block/python/qa_howto.py @@ -21,7 +21,7 @@ # from gnuradio import gr, gr_unittest -import howto +import howto_swig class qa_howto (gr_unittest.TestCase): @@ -35,7 +35,7 @@ class qa_howto (gr_unittest.TestCase): src_data = (-3, 4, -5.5, 2, 3) expected_result = (9, 16, 30.25, 4, 9) src = gr.vector_source_f (src_data) - sqr = howto.square_ff () + sqr = howto_swig.square_ff () dst = gr.vector_sink_f () self.tb.connect (src, sqr) self.tb.connect (sqr, dst) @@ -47,7 +47,7 @@ class qa_howto (gr_unittest.TestCase): src_data = (-3, 4, -5.5, 2, 3) expected_result = (9, 16, 30.25, 4, 9) src = gr.vector_source_f (src_data) - sqr = howto.square2_ff () + sqr = howto_swig.square2_ff () dst = gr.vector_sink_f () self.tb.connect (src, sqr) self.tb.connect (sqr, dst) diff --git a/gr-howto-write-a-block/src/python/run_tests.in b/gr-howto-write-a-block/python/run_tests.in index 6e4b83ea0..5b50509e1 100644 --- a/gr-howto-write-a-block/src/python/run_tests.in +++ b/gr-howto-write-a-block/python/run_tests.in @@ -11,11 +11,11 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ # Where to look in the build tree for our shared library -libbld=@abs_top_builddir@/src/lib -# Where to look in the src tree for swig generated python code -libsrc=@abs_top_srcdir@/src/lib +libbld=@abs_top_builddir@/lib +# Where to look in the build tree for swig generated python code +libswig=@abs_top_builddir@/swig # Where to look in the src tree for hand written python code -py=@abs_top_srcdir@/src/python +py=@abs_top_srcdir@/python # Where to look for installed GNU Radio python modules # FIXME this is wrong on a distcheck. We really need to ask gnuradio-core @@ -23,8 +23,8 @@ py=@abs_top_srcdir@/src/python installed_pythondir=@pythondir@ installed_pyexecdir=@pyexecdir@ -PYTHONPATH="$libbld:$libbld/.libs:$libsrc:$py:$installed_pythondir:$installed_pyexecdir:$PYTHONPATH" -#PYTHONPATH="$libbld:$libbld/.libs:$libsrc:$py:$installed_pythondir:$installed_pyexecdir" +PYTHONPATH="$libbld:$libbld/.libs:$libswig:$libswig/.libs:$py:$installed_pythondir:$installed_pyexecdir:$PYTHONPATH" +echo $PYTHONPATH export PYTHONPATH diff --git a/gr-howto-write-a-block/src/.gitignore b/gr-howto-write-a-block/src/.gitignore deleted file mode 100644 index bb3f27777..000000000 --- a/gr-howto-write-a-block/src/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/howto.cc -/howto.py diff --git a/gr-howto-write-a-block/src/lib/howto.i b/gr-howto-write-a-block/src/lib/howto.i deleted file mode 100644 index c3dae9dfc..000000000 --- a/gr-howto-write-a-block/src/lib/howto.i +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "howto_square_ff.h" -#include "howto_square2_ff.h" -%} - -// ---------------------------------------------------------------- - -/* - * First arg is the package prefix. - * Second arg is the name of the class minus the prefix. - * - * This does some behind-the-scenes magic so we can - * access howto_square_ff from python as howto.square_ff - */ -GR_SWIG_BLOCK_MAGIC(howto,square_ff); - -howto_square_ff_sptr howto_make_square_ff (); - -class howto_square_ff : public gr_block -{ -private: - howto_square_ff (); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(howto,square2_ff); - -howto_square2_ff_sptr howto_make_square2_ff (); - -class howto_square2_ff : public gr_sync_block -{ -private: - howto_square2_ff (); -}; diff --git a/gr-howto-write-a-block/swig/.gitignore b/gr-howto-write-a-block/swig/.gitignore new file mode 100644 index 000000000..7f4c478d9 --- /dev/null +++ b/gr-howto-write-a-block/swig/.gitignore @@ -0,0 +1,6 @@ +/.deps +/.libs +/Makefile.in +/Makefile +/howto_swig.cc +/howto_swig.py diff --git a/gr-howto-write-a-block/src/lib/Makefile.am b/gr-howto-write-a-block/swig/Makefile.am index fa6b439ea..fc40109d0 100644 --- a/gr-howto-write-a-block/src/lib/Makefile.am +++ b/gr-howto-write-a-block/swig/Makefile.am @@ -21,25 +21,7 @@ include $(top_srcdir)/Makefile.common -################################### -# howto C++ library - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - howto_square_ff.h \ - howto_square2_ff.h - -lib_LTLIBRARIES = libgnuradio-howto.la - -libgnuradio_howto_la_SOURCES = \ - howto_square_ff.cc \ - howto_square2_ff.cc - -libgnuradio_howto_la_LIBADD = \ - $(GNURADIO_CORE_LA) - -libgnuradio_howto_la_LDFLAGS = \ - $(NO_UNDEFINED) +AM_CPPFLAGS += -I$(top_srcdir)/lib if PYTHON ################################### @@ -52,11 +34,10 @@ TOP_SWIG_IFILES = \ # import gnuradio.howto # This ends up at: # ${prefix}/lib/python${python_version}/site-packages/gnuradio -howto_pythondir_category = \ - gnuradio +howto_pythondir_category = gnuradio/howto howto_la_swig_libadd = \ - libgnuradio-howto.la + $(top_builddir)/lib/libgnuradio-howto.la include $(top_srcdir)/Makefile.swig @@ -65,4 +46,10 @@ BUILT_SOURCES = $(swig_built_sources) # Do not distribute the output of SWIG no_dist_files = $(swig_built_sources) + +# additional SWIG files to be installed +howto_swiginclude_headers = \ + howto_square_ff.i \ + howto_square2_ff.i + endif diff --git a/gr-howto-write-a-block/src/lib/Makefile.swig.gen b/gr-howto-write-a-block/swig/Makefile.swig.gen index f76cc6371..c62e5aa3e 100644 --- a/gr-howto-write-a-block/src/lib/Makefile.swig.gen +++ b/gr-howto-write-a-block/swig/Makefile.swig.gen @@ -72,42 +72,42 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## .h file is sometimes built, but not always ... so that one has to ## be added manually by the including Makefile.am . -swig_built_sources += howto.py howto.cc +swig_built_sources += howto_swig.py howto_swig.cc ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . howto_swiginclude_HEADERS = \ - howto.i \ + howto.i \ $(howto_swiginclude_headers) howto_pylib_LTLIBRARIES = \ - _howto.la + _howto_swig.la -_howto_la_SOURCES = \ - howto.cc \ +_howto_swig_la_SOURCES = \ + howto_swig.cc \ $(howto_la_swig_sources) -_howto_la_LIBADD = \ +_howto_swig_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(howto_la_swig_libadd) -_howto_la_LDFLAGS = \ +_howto_swig_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(howto_la_swig_ldflags) -_howto_la_CXXFLAGS = \ +_howto_swig_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ $(howto_la_swig_cxxflags) howto_python_PYTHON = \ - howto.py \ + howto_swig.py \ $(howto_python) ## Entry rule for running SWIG -howto.h howto.py howto.cc: howto.i +howto.h howto_swig.py howto_swig.cc: howto.i ## This rule will get called only when MAKE decides that one of the ## targets needs to be created or re-created, because: ## @@ -202,7 +202,7 @@ $(DEPDIR)/howto-generate-stamp: ## if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(howto_swig_args) \ -MD -MF $(DEPDIR)/howto.Std \ - -module howto -o howto.cc $(WHAT); then \ + -module howto_swig -o howto_swig.cc $(WHAT); then \ if test $(host_os) = mingw32; then \ $(RM) $(DEPDIR)/howto.Sd; \ $(SED) 's,\\\\,/,g' < $(DEPDIR)/howto.Std \ diff --git a/gr-howto-write-a-block/swig/howto.i b/gr-howto-write-a-block/swig/howto.i new file mode 100644 index 000000000..8dc502010 --- /dev/null +++ b/gr-howto-write-a-block/swig/howto.i @@ -0,0 +1,11 @@ +/* -*- c++ -*- */ + +%include "gnuradio.i" // the common stuff + +%{ +#include "howto_square_ff.h" +#include "howto_square2_ff.h" +%} + +%include "howto_square_ff.i" +%include "howto_square2_ff.i" diff --git a/gr-howto-write-a-block/swig/howto_square2_ff.i b/gr-howto-write-a-block/swig/howto_square2_ff.i new file mode 100644 index 000000000..683a93d61 --- /dev/null +++ b/gr-howto-write-a-block/swig/howto_square2_ff.i @@ -0,0 +1,9 @@ +GR_SWIG_BLOCK_MAGIC(howto,square2_ff); + +howto_square2_ff_sptr howto_make_square2_ff (); + +class howto_square2_ff : public gr_sync_block +{ +private: + howto_square2_ff (); +}; diff --git a/gr-howto-write-a-block/swig/howto_square_ff.i b/gr-howto-write-a-block/swig/howto_square_ff.i new file mode 100644 index 000000000..f8ae76986 --- /dev/null +++ b/gr-howto-write-a-block/swig/howto_square_ff.i @@ -0,0 +1,16 @@ +/* + * First arg is the package prefix. + * Second arg is the name of the class minus the prefix. + * + * This does some behind-the-scenes magic so we can + * access howto_square_ff from python as howto.square_ff + */ +GR_SWIG_BLOCK_MAGIC(howto,square_ff); + +howto_square_ff_sptr howto_make_square_ff (); + +class howto_square_ff : public gr_block +{ +private: + howto_square_ff (); +}; diff --git a/gr-howto-write-a-block/version.sh b/gr-howto-write-a-block/version.sh new file mode 100644 index 000000000..b2cad877d --- /dev/null +++ b/gr-howto-write-a-block/version.sh @@ -0,0 +1,4 @@ +MAJOR_VERSION=3 +API_COMPAT=3 +MINOR_VERSION=git +MAINT_VERSION= diff --git a/gr-msdd6000/src/.gitignore b/gr-msdd6000/src/.gitignore index 33061d3ab..ca4a54fb0 100644 --- a/gr-msdd6000/src/.gitignore +++ b/gr-msdd6000/src/.gitignore @@ -4,3 +4,5 @@ /.deps /msdd.cc /msdd.py +/msdd_rs.cc +/msdd_rs.py diff --git a/gr-msdd6000/src/Makefile.am b/gr-msdd6000/src/Makefile.am index 0865d40de..9ae4efb0a 100644 --- a/gr-msdd6000/src/Makefile.am +++ b/gr-msdd6000/src/Makefile.am @@ -28,26 +28,40 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ grinclude_HEADERS = \ msdd_source_simple.h \ msdd_buffer_copy_behaviors.h \ - msdd6000.h + msdd6000.h \ + msdd_rs_source_simple.h \ + msdd6000_rs.h -lib_LTLIBRARIES = libgnuradio-msdd6000.la +lib_LTLIBRARIES = libgnuradio-msdd6000.la \ + libgnuradio-msdd6000_rs.la libgnuradio_msdd6000_la_SOURCES = \ msdd_source_simple.cc \ msdd6000.cc + +libgnuradio_msdd6000_rs_la_SOURCES = \ + msdd_rs_source_simple.cc \ + msdd6000_rs.cc + libgnuradio_msdd6000_la_LIBADD = \ $(GNURADIO_CORE_LA) libgnuradio_msdd6000_la_LDFLAGS = \ $(NO_UNDEFINED) +libgnuradio_msdd6000_rs_la_LIBADD = \ + $(GNURADIO_CORE_LA) + +libgnuradio_msdd6000_rs_la_LDFLAGS = \ + $(NO_UNDEFINED) + if PYTHON ################################# # SWIG interface and library TOP_SWIG_IFILES = \ - msdd.i + msdd.i msdd_rs.i # Install so that they end up available as: # import gnuradio.msdd @@ -56,10 +70,16 @@ TOP_SWIG_IFILES = \ msdd_pythondir_category = \ gnuradio +msdd_rs_pythondir_category = \ + gnuradio + # additional libraries for linking with the SWIG-generated library msdd_la_swig_libadd = \ libgnuradio-msdd6000.la +msdd_rs_la_swig_libadd = \ + libgnuradio-msdd6000_rs.la + include $(top_srcdir)/Makefile.swig # add some of the variables generated inside the Makefile.swig.gen diff --git a/gr-msdd6000/src/Makefile.swig.gen b/gr-msdd6000/src/Makefile.swig.gen index 5c2920230..ced3979f7 100644 --- a/gr-msdd6000/src/Makefile.swig.gen +++ b/gr-msdd6000/src/Makefile.swig.gen @@ -33,14 +33,21 @@ ## this has to be done in the including Makefile.am -before- ## Makefile.swig is included. + msdd_pythondir_category ?= gnuradio/msdd msdd_pylibdir_category ?= $(msdd_pythondir_category) msdd_pythondir = $(pythondir)/$(msdd_pythondir_category) msdd_pylibdir = $(pyexecdir)/$(msdd_pylibdir_category) +msdd_rs_pythondir_category ?= gnuradio/msdd_rs +msdd_rs_pylibdir_category ?= $(msdd_rs_pythondir_category) +msdd_rs_pythondir = $(pythondir)/$(msdd_rs_pythondir_category) +msdd_rs_pylibdir = $(pyexecdir)/$(msdd_rs_pylibdir_category) + ## SWIG headers are always installed into the same directory. msdd_swigincludedir = $(swigincludedir) +msdd_rs_swigincludedir = $(swigincludedir) ## This is a template file for a "generated" Makefile addition (in ## this case, "Makefile.swig.gen"). By including the top-level @@ -63,6 +70,7 @@ msdd_swigincludedir = $(swigincludedir) ## the SWIG-generated files will be removed from the distribution. STAMPS += $(DEPDIR)/msdd-generate-* +STAMPS += $(DEPDIR)/msdd_rs-generate-* ## Other cleaned files: dependency files generated by SWIG or this Makefile @@ -72,27 +80,40 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S* ## .h file is sometimes built, but not always ... so that one has to ## be added manually by the including Makefile.am . -swig_built_sources += msdd.py msdd.cc +swig_built_sources += msdd.py msdd_rs.py msdd.cc msdd_rs.cc ## Various SWIG variables. These can be overloaded in the including ## Makefile.am by setting the variable value there, then including ## Makefile.swig . msdd_swiginclude_HEADERS = \ - msdd.i \ + msdd.i \ + msdd_rs.i \ $(msdd_swiginclude_headers) msdd_pylib_LTLIBRARIES = \ _msdd.la +msdd_rs_pylib_LTLIBRARIES = \ + _msdd_rs.la + _msdd_la_SOURCES = \ - msdd.cc \ + msdd.cc \ $(msdd_la_swig_sources) +_msdd_rs_la_SOURCES = \ + msdd_rs.cc \ + $(msdd_la_swig_sources) + + _msdd_la_LIBADD = \ $(STD_SWIG_LA_LIB_ADD) \ $(msdd_la_swig_libadd) +_msdd_rs_la_LIBADD = \ + $(STD_SWIG_LA_LIB_ADD) \ + $(msdd_rs_la_swig_libadd) + _msdd_la_LDFLAGS = \ $(STD_SWIG_LA_LD_FLAGS) \ $(msdd_la_swig_ldflags) @@ -101,10 +122,22 @@ _msdd_la_CXXFLAGS = \ $(STD_SWIG_CXX_FLAGS) \ $(msdd_la_swig_cxxflags) +_msdd_rs_la_LDFLAGS = \ + $(STD_SWIG_LA_LD_FLAGS) \ + $(msdd_rs_la_swig_ldflags) + +_msdd_rs_la_CXXFLAGS = \ + $(STD_SWIG_CXX_FLAGS) \ + $(msdd_rs_la_swig_cxxflags) + msdd_python_PYTHON = \ - msdd.py \ + msdd.py \ $(msdd_python) +msdd_rs_python_PYTHON = \ + msdd_rs.py \ + $(msdd_rs_python) + ## Entry rule for running SWIG msdd.h msdd.py msdd.cc: msdd.i @@ -251,9 +284,161 @@ $(DEPDIR)/msdd-generate-stamp: ## touch $(DEPDIR)/msdd-generate-stamp + + + + + +msdd_rs.h msdd_rs.py msdd_rs.cc: msdd_rs.i +## This rule will get called only when MAKE decides that one of the +## targets needs to be created or re-created, because: +## +## * The .i file is newer than any or all of the generated files; +## +## * Any or all of the .cc, .h, or .py files does not exist and is +## needed (in the case this file is not needed, the rule for it is +## ignored); or +## +## * Some SWIG-based dependecy of the .cc file isn't met and hence the +## .cc file needs be be regenerated. Explanation: Because MAKE +## knows how to handle dependencies for .cc files (regardless of +## their name or extension), then the .cc file is used as a target +## instead of the .i file -- but with the dependencies of the .i +## file. It is this last reason why the line: +## +## if test -f $@; then :; else +## +## cannot be used in this case: If a .i file dependecy is not met, +## then the .cc file needs to be rebuilt. But if the stamp is newer +## than the .cc file, and the .cc file exists, then in the original +## version (with the 'test' above) the internal MAKE call will not +## be issued and hence the .cc file will not be rebuilt. +## +## Once execution gets to here, it should always proceed no matter the +## state of a stamp (as discussed in link above). The +## $(DEPDIR)/msdd-generate stuff is used to allow for parallel +## builds to "do the right thing". The stamp has no relationship with +## either the target files or dependency file; it is used solely for +## the protection of multiple builds during a given call to MAKE. +## +## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM +## (15). At a caught signal, the quoted command will be issued before +## exiting. In this case, remove any stamp, whether temporary of not. +## The trap is valid until the process exits; the process includes all +## commands appended via "\"s. +## + trap 'rm -rf $(DEPDIR)/msdd_rs-generate-*' 1 2 13 15; \ +## +## Create a temporary directory, which acts as a lock. The first +## process to create the directory will succeed and issue the MAKE +## command to do the actual work, while all subsequent processes will +## fail -- leading them to wait for the first process to finish. +## + if mkdir $(DEPDIR)/msdd_rs-generate-lock 2>/dev/null; then \ +## +## This code is being executed by the first process to succeed in +## creating the directory lock. +## +## Remove the stamp associated with this filename. +## + rm -f $(DEPDIR)/msdd_rs-generate-stamp; \ +## +## Tell MAKE to run the rule for creating this stamp. +## + $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/msdd_rs-generate-stamp WHAT=$<; \ +## +## Now that the .cc, .h, and .py files have been (re)created from the +## .i file, future checking of this rule during the same MAKE +## execution will come back that the rule doesn't need to be executed +## because none of the conditions mentioned at the start of this rule +## will be positive. Remove the the directory lock, which frees up +## any waiting process(es) to continue. +## + rmdir $(DEPDIR)/msdd_rs-generate-lock; \ + else \ +## +## This code is being executed by any follower processes while the +## directory lock is in place. +## +## Wait until the first process is done, testing once per second. +## + while test -d $(DEPDIR)/msdd_rs-generate-lock; do \ + sleep 1; \ + done; \ +## +## Succeed if and only if the first process succeeded; exit this +## process returning the status of the generated stamp. +## + test -f $(DEPDIR)/msdd_rs-generate-stamp; \ + exit $$?; \ + fi; + +$(DEPDIR)/msdd_rs-generate-stamp: +## This rule will be called only by the first process issuing the +## above rule to succeed in creating the lock directory, after +## removing the actual stamp file in order to guarantee that MAKE will +## execute this rule. +## +## Call SWIG to generate the various output files; special +## post-processing on 'mingw32' host OS for the dependency file. +## + if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(msdd_rs_swig_args) \ + -MD -MF $(DEPDIR)/msdd_rs.Std \ + -module msdd_rs -o msdd_rs.cc $(WHAT); then \ + if test $(host_os) = mingw32; then \ + $(RM) $(DEPDIR)/msdd_rs.Sd; \ + $(SED) 's,\\\\,/,g' < $(DEPDIR)/msdd_rs.Std \ + > $(DEPDIR)/msdd_rs.Sd; \ + $(RM) $(DEPDIR)/msdd_rs.Std; \ + $(MV) $(DEPDIR)/msdd_rs.Sd $(DEPDIR)/msdd_rs.Std; \ + fi; \ + else \ + $(RM) $(DEPDIR)/msdd_rs.S*; exit 1; \ + fi; +## +## Mess with the SWIG output .Std dependency file, to create a +## dependecy file valid for the input .i file: Basically, simulate the +## dependency file created for libraries by GNU's libtool for C++, +## where all of the dependencies for the target are first listed, then +## each individual dependency is listed as a target with no further +## dependencies. +## +## (1) remove the current dependency file +## + $(RM) $(DEPDIR)/msdd_rs.d +## +## (2) Copy the whole SWIG file: +## + cp $(DEPDIR)/msdd_rs.Std $(DEPDIR)/msdd_rs.d +## +## (3) all a carriage return to the end of the dependency file. +## + echo "" >> $(DEPDIR)/msdd_rs.d +## +## (4) from the SWIG file, remove the first line (the target); remove +## trailing " \" and " " from each line. Append ":" to each line, +## followed by 2 carriage returns, then append this to the end of +## the dependency file. +## + $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/msdd_rs.Std | \ + awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/msdd_rs.d +## +## (5) remove the SWIG-generated file +## + $(RM) $(DEPDIR)/msdd_rs.Std +## +## Create the stamp for this filename generation, to signal success in +## executing this rule; allows other threads waiting on this process +## to continue. +## + touch $(DEPDIR)/msdd_rs-generate-stamp + # KLUDGE: Force runtime include of a SWIG dependency file. This is # not guaranteed to be portable, but will probably work. If it works, # we have accurate dependencies for our swig stuff, which is good. + @am__include@ @am__quote@./$(DEPDIR)/msdd.d@am__quote@ +@am__include@ @am__quote@./$(DEPDIR)/msdd_rs.d@am__quote@ + diff --git a/gr-msdd6000/src/msdd6000_rs.cc b/gr-msdd6000/src/msdd6000_rs.cc new file mode 100644 index 000000000..d78f2b4da --- /dev/null +++ b/gr-msdd6000/src/msdd6000_rs.cc @@ -0,0 +1,286 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include <msdd6000_rs.h> + +#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif + +#define DEBUG(A) printf("=debug=> %s\n", A) + +static void +optimize_socket(int socket); + +/* + * Holds types that need autoconf help. They're here and not in the .h file because + * here we've got access to config.h + */ +class MSDD6000_RS::detail { +public: + struct sockaddr_in d_sockaddr; +}; + + +MSDD6000_RS::MSDD6000_RS(char* addr) + : d_detail(new MSDD6000_RS::detail()) +{ + d_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); + + optimize_socket(d_sock); + + + // set up remote sockaddr +// int s = inet_aton(addr, &d_adx); + d_detail->d_sockaddr.sin_family = AF_INET; + d_detail->d_sockaddr.sin_port = htons(10000); + int s = inet_aton(addr, &d_detail->d_sockaddr.sin_addr); + + // set up local sockaddr + struct in_addr d_myadx; + struct sockaddr_in d_mysockaddr; + short int port = 10010; + d_myadx.s_addr = INADDR_ANY; + d_mysockaddr.sin_family = AF_INET; + d_mysockaddr.sin_port = htons(port); + memcpy(&d_mysockaddr.sin_addr.s_addr, &d_myadx.s_addr, sizeof(in_addr)); + //d_sockaddr.sin_addr = INADDR_ANY; + s = bind(d_sock, (const sockaddr*) &d_mysockaddr, sizeof(d_mysockaddr)); + + // set default values + //d_decim = 2; + d_ddc_gain = 2; + d_rf_attn = 0; + d_fc_mhz = 3500; + d_offset_hz = 0; + d_ddc_gain = 0; + d_ddc_sample_rate_khz = 25600; + d_ddc_bw_khz = 25600; + d_start = 0; + d_state = STATE_STOPPED; +} + +MSDD6000_RS::~MSDD6000_RS() +{ + //printf("MSDD6000_RS::Destructing\n"); + close(d_sock); +} + + +static void +optimize_socket(int socket){ +#define BANDWIDTH 1000000000/8 +#define DELAY 0.5 + int ret; + + int sock_buf_size = static_cast<int>(2*BANDWIDTH*DELAY); + char textbuf[512]; + snprintf(textbuf, sizeof(textbuf), "%d", sock_buf_size); + printf("sock_buf_size = %d\n", sock_buf_size); + + ret = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, + &sock_buf_size, sizeof(sock_buf_size)); + + ret = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, + &sock_buf_size, sizeof(sock_buf_size)); + + int uid = getuid(); + if(uid!=0){ + printf(" ****** COULD NOT OPTIMIZE SYSTEM NETWORK PARAMETERS BECAUSE YOU ARE NOT RUNNING AS ROOT *******\n ****** YOUR MSDD6000_RS RECIEVER PERFORMANCE IS GOING TO BE TERRIBLE *******\n"); + return; + } + + + // SET UP SOME SYSTEM WIDE TCP SOCKET PARAMETERS + // FIXME seems like kind of a big hammer. Are you sure you need this? + FILE* fd = fopen("/proc/sys/net/core/netdev_max_backlog", "w"); + if (fd){ + fwrite("10000", 1, strlen("10000"), fd); + fclose(fd); + } + + fd = fopen("/proc/sys/net/core/rmem_max", "w"); + if (fd){ + fwrite(textbuf, 1, strlen(textbuf), fd); + fclose(fd); + } + + fd = fopen("/proc/sys/net/core/wmem_max", "w"); + if (fd){ + fwrite(textbuf, 1, strlen(textbuf), fd); + fclose(fd); + } + + // just incase these were rejected before because of max sizes... + + ret = setsockopt( socket, SOL_SOCKET, SO_SNDBUF, + (char *)&sock_buf_size, sizeof(sock_buf_size) ); + + ret = setsockopt( socket, SOL_SOCKET, SO_RCVBUF, + (char *)&sock_buf_size, sizeof(sock_buf_size) ); + +} + + +//void MSDD6000_RS::set_decim(int decim_pow2){ +// DEBUG("SETTING NEW DECIM"); +// d_decim = decim_pow2; +// +// if(d_state==STATE_STARTED) +// send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); +//} + +void MSDD6000_RS::set_rf_attn(int attn){ + DEBUG("SETTING NEW RF ATTN"); + d_rf_attn = attn; + if(d_state==STATE_STARTED) + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); +} + +void MSDD6000_RS::set_ddc_gain(int gain){ + DEBUG("SETTING NEW DDC GAIN"); + d_ddc_gain = gain; + if(d_state==STATE_STARTED) + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); +} + +void MSDD6000_RS::set_fc(int center_mhz, int offset_hz){ + DEBUG("SETTING NEW FC"); + d_fc_mhz = center_mhz; + d_offset_hz = offset_hz; + + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); +// if(d_state==STATE_STARTED) +// send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); +// send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); +// +} + +void MSDD6000_RS::set_ddc_samp_rate(float sample_rate_khz){ + DEBUG("SETTING NEW SAMPLE RATE"); + d_ddc_sample_rate_khz = sample_rate_khz; + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); +} + +void MSDD6000_RS::set_ddc_bw(float bw_khz){ + DEBUG("SETTING NEW DDC BW"); + d_ddc_bw_khz = bw_khz; + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); +} + +void MSDD6000_RS::start(){ + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); + return; +} + +void MSDD6000_RS::stop(){ + // new request with 0 decim tells it to halt + stop_data(); +} + + +int MSDD6000_RS::start_data(){ + d_start = 1; + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); + d_state = STATE_STARTED; + return 0; + } + + +int MSDD6000_RS::stop_data(){ + // new request with 0 decim tells it to halt + d_start = 0; + send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); + d_state = STATE_STOPPED; + return 0; + } + +/* Query functions */ +float MSDD6000_RS::pull_ddc_samp_rate(){ + return d_ddc_sample_rate_khz; +} +float MSDD6000_RS::pull_ddc_bw(){ + return d_ddc_bw_khz; +} + +float MSDD6000_RS::pull_rx_freq(){ + return d_fc_mhz; +} +int MSDD6000_RS::pull_ddc_gain(){ + return d_ddc_gain; +} + +int MSDD6000_RS::pull_rf_atten(){ + return d_rf_attn; +} + + +void MSDD6000_RS::send_request(float freq_mhz, float rf_attn, float ddc_gain, float ddc_offset_hz, float ddc_samp_rate_khz, float ddc_input_bw_khz, float ddc_start){ + static char buff[512]; + // Send MSDD6000_RS control frame. + sprintf(buff, "%f %f %f %f %f %f %f\n",freq_mhz, rf_attn, ddc_gain, ddc_offset_hz, ddc_samp_rate_khz, ddc_input_bw_khz, ddc_start); //ddc_dec, ddc_offset_hz); + printf("sending: %s\n", buff); + int flags = 0; + sendto( d_sock, buff, strlen(buff)+1, flags, + (const sockaddr*)&(d_detail->d_sockaddr), sizeof(d_detail->d_sockaddr)); + } + + +int MSDD6000_RS::read(char* buf, int size){ + int flags = 0; + return recv(d_sock, buf, size, flags); + } + +int MSDD6000_RS::parse_control(char* buf, int size){ + //packet_len = sprintf(&txbuff[6], "%f %f %f %f %f %f %f",downsamp,ddc_dec_rate,ddc_step_int,ddc_step_frac,ddc_samp_rate_khz,ddc_input_bw_khz,ddc_start); + + float downsamp; + float ddc_dec_rate; + float ddc_step_int; + float ddc_step_frac; + float ddc_samp_rate_khz; + float ddc_input_bw_khz; + float ddc_start; + + sscanf(&buf[6],"%f %f %f %f %f %f %f",&downsamp,&ddc_dec_rate,&ddc_step_int,&ddc_step_frac,&ddc_samp_rate_khz,&ddc_input_bw_khz,&ddc_start); + + // pull off sample rate + d_ddc_sample_rate_khz = ddc_samp_rate_khz; + printf("Sample Rate %f\n",d_ddc_sample_rate_khz); + // pull off bw + d_ddc_bw_khz = ddc_input_bw_khz; + printf("BW %f\n", d_ddc_bw_khz); + return 0; +} + + diff --git a/gr-msdd6000/src/msdd6000_rs.h b/gr-msdd6000/src/msdd6000_rs.h new file mode 100644 index 000000000..4be4624be --- /dev/null +++ b/gr-msdd6000/src/msdd6000_rs.h @@ -0,0 +1,66 @@ +#ifndef MSDD_RS__RS_6000_H +#define MSDD_RS__RS_6000_H + +#include <boost/scoped_ptr.hpp> + +class MSDD6000_RS { + class detail; + + //! holds objects with system dependent types + boost::scoped_ptr<detail> d_detail; + +public: + + enum state { + STATE_STOPPED, STATE_STARTED + }; + + MSDD6000_RS(char* ip_addr); + ~MSDD6000_RS(); + + /* set functions -- sets digitizer parameters */ + + // void set_output(int mode, void* arg); + + void set_rf_attn(int attn); + void set_ddc_gain(int gain); + void set_fc(int center_mhz, int offset_hz); + void set_ddc_samp_rate(float sample_rate_khz); + void set_ddc_bw(float bw_khz); + + void start(); + void stop(); + + /* function starts the flow of data from the digitizer */ + int start_data(); + /* function stops the flow of data from the digitizer */ + int stop_data(); + + /* query functions -- queries digitizer 'actual' parameters */ + float pull_ddc_samp_rate(); + float pull_ddc_bw(); + float pull_rx_freq(); + int pull_ddc_gain(); + int pull_rf_atten(); + + void send_request(float,float,float,float,float,float,float); + int read(char*, int); + + int parse_control(char*, int); + +private: + // parameters for a receiver object. + int d_fc_mhz; + int d_offset_hz; + int d_rf_attn; + int d_ddc_gain; + float d_ddc_sample_rate_khz; + float d_ddc_bw_khz; + int d_start; + int d_sock; + state d_state; + +}; + + +#endif diff --git a/gr-msdd6000/src/msdd_rs.i b/gr-msdd6000/src/msdd_rs.i new file mode 100644 index 000000000..16a1bec1a --- /dev/null +++ b/gr-msdd6000/src/msdd_rs.i @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2009 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 "gnuradio.i" // the common stuff + +%{ +#include "msdd_rs_source_simple.h" +%} + + +GR_SWIG_BLOCK_MAGIC(msdd_rs,source_simple) + +msdd_rs_source_simple_sptr +msdd_rs_make_source_simple ( + const char *src, + unsigned short port_src + ); + +class msdd_rs_source_simple : public gr_sync_block { + protected: + msdd_rs_source_simple( + const char *src, + unsigned short port_src + ); + + public: + ~msdd_rs_source_c(); + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + bool start(); + bool stop(); + + /* function starts the flow of data */ + int start_data(); + + /* function stops the flow of data */ + int stop_data(); + + long pull_adc_freq(); + /* Request the current ddc sample rate */ + float pull_ddc_samp_rate(); + /* Request the current ddc bandwidth */ + float pull_ddc_bw(); + /* Request the current rx freq */ + float pull_rx_freq(); + /* Request current ddc gain */ + int pull_ddc_gain(); + /* Request current RF attenuation */ + int pull_rf_atten(); + + + /* int decim_rate(); */ + gr_vector_int gain_range(); + gr_vector_float freq_range(); + + /* Set Functions */ + /* bool set_decim_rate(unsigned int); */ + bool set_rx_freq(double); /* set_rx_freq(int,double); */ + /* bool set_pga(int,double); */ + + bool set_ddc_gain(double); + /* Set desired sample rate of MSDD6000 -- Note bounds checking is + done by the module and it will return the value actually used in the hardware. */ + bool set_ddc_samp_rate(double); + /* Set desired input BW of MSDD6000 -- Note bounds checking is + // done by the module and it will return the value actually used in the hardware. */ + bool set_ddc_bw(double); + + bool set_rf_atten(double); + + + }; diff --git a/gr-msdd6000/src/msdd_rs_source_simple.cc b/gr-msdd6000/src/msdd_rs_source_simple.cc new file mode 100644 index 000000000..2ffc64240 --- /dev/null +++ b/gr-msdd6000/src/msdd_rs_source_simple.cc @@ -0,0 +1,237 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <msdd_rs_source_simple.h> +#include <gr_io_signature.h> +#include <string.h> +#include <cstdio> + + +msdd_rs_source_simple_sptr +msdd_rs_make_source_simple ( const char *src, unsigned short port_src) +{ + return msdd_rs_source_simple_sptr (new msdd_rs_source_simple ( src, port_src)); +} + + +msdd_rs_source_simple::msdd_rs_source_simple ( + const char *src, + unsigned short port_src) + : gr_sync_block("MSDD_RS_SOURCE_SIMPLE", + gr_make_io_signature (0,0,0), + gr_make_io_signature (1, 1, sizeof (short))), + rcv(new MSDD6000_RS((char*) src)), d_lastseq(0) +{ +} + +msdd_rs_source_simple::~msdd_rs_source_simple () +{ +} + + +int +msdd_rs_source_simple::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + +#define BUF_LEN (366*sizeof(short)*2 + 6) + + float* out1 =(float*) output_items[0]; + + char buffer[BUF_LEN]; + /* Read a buffer out -- looking at UDP payload at this point.*/ + rcv->read( &buffer[0], BUF_LEN ); + + int seq = *((int*) &buffer[2]); + char type = buffer[0]; + //printf("Sequence %d\n",seq); + + // FIXME get rid of these magic 366's! + if(d_lastseq == -366) + { + if (type != 0){ + /* Received control packet -- parse and update locally stored parameters */ + printf("Parsing control Packet\n"); + rcv->parse_control(&buffer[0], seq); + } + else{ + // not started case + if(seq == 0){ + d_lastseq = 0; + } + else + { + // THROW AWAY SAMPLES WE ARE NOT STARTED YET! + return 0; + } + } + } + // Started case + else + { + if (type != 0){ + /* Received control packet -- parse and update locally stored parameters */ + printf("Parsing control Packet\n"); + rcv->parse_control(&buffer[0], seq); + } + + else { + int samples_missed = seq - d_lastseq - 366; + if(samples_missed > 0) + { + printf("dropped %d samples.\n", samples_missed); + } + d_lastseq = seq; + } + } + + if(noutput_items< 366*2){ + printf("NOT ENOUGH SPACE IN OUTPUT BUFFER!!! >:-(\n"); + } + + memcpy(&out1[0], &buffer[6], BUF_LEN - 6); + +// for(int i = 0; i < 366*2; i++){ +// out1[i] = (float) (*((short*) &buffer[6+2*i]) ); +// } + + return 366*2; +} + +//bool msdd_rs_source_simple::set_decim_rate(unsigned int rate) +//{ +// // FIXME seems buggy. How about a floor or ceil? +// rcv->set_decim((int) log2(rate)); +// return true; +//} + +bool msdd_rs_source_simple::set_rx_freq(double freq) +{ + long new_fc = (long)freq; + rcv->set_fc( new_fc/1000000, new_fc%1000000); + return true; +} + + +bool msdd_rs_source_simple::set_ddc_gain(double gain) +{ + if(gain < 0 || gain > 7){ // only 3 bits available. + printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n"); + return false; + } + //decimation gain + rcv->set_ddc_gain((int)gain); + return true; +} + +// Set desired sample rate of MSDD6000 -- Note bounds checking is +// done by the module and it will return the value actually used in the hardware. +bool msdd_rs_source_simple::set_ddc_samp_rate(double rate) +{ + rcv->set_ddc_samp_rate((float) rate); + return true; +} + +// Set desired input BW of MSDD6000 -- Note bounds checking is +// done by the module and it will return the value actually used in the hardware. +bool msdd_rs_source_simple::set_ddc_bw(double bw) +{ + rcv->set_ddc_bw((float) bw); + return true; +} + +bool msdd_rs_source_simple::set_rf_atten(double rf_atten) +{ + rcv->set_rf_attn((int) rf_atten); + return true; +} + +bool msdd_rs_source_simple::start() +{ + rcv->start(); + rcv->stop_data(); + return true; +} + +bool msdd_rs_source_simple::stop() +{ + rcv->stop(); + return true; +} + +int msdd_rs_source_simple::start_data() +{ + return rcv->start_data(); +} + +int msdd_rs_source_simple::stop_data() +{ + return rcv->stop_data(); +} + +/* Query functions */ +long msdd_rs_source_simple::pull_adc_freq(){ + return 102400000; +} + +/* Request the current ddc sample rate */ +float msdd_rs_source_simple::pull_ddc_samp_rate(){ + return(rcv->pull_ddc_samp_rate()); +} + +/* Request the current ddc bandwidth */ +float msdd_rs_source_simple::pull_ddc_bw(){ + return(rcv->pull_ddc_bw()); + +} + +/* Request the current rx freq */ +float msdd_rs_source_simple::pull_rx_freq(){ + return(rcv->pull_rx_freq()); +} + +/* Request current ddc gain */ +int msdd_rs_source_simple::pull_ddc_gain(){ + return(rcv->pull_ddc_gain()); +} + +/* Request current RF attenuation */ +int msdd_rs_source_simple::pull_rf_atten(){ + return(rcv->pull_rf_atten()); +} + +std::vector<int> msdd_rs_source_simple::gain_range(){ + static std::vector<int> r; + r.push_back(0); + r.push_back(12); + return r; +} + +std::vector<float> msdd_rs_source_simple::freq_range(){ + std::vector<float> r; + r.push_back(30.0*1000*1000); + r.push_back(6.0*1000*1000*1000); + return r; +} diff --git a/gr-msdd6000/src/msdd_rs_source_simple.h b/gr-msdd6000/src/msdd_rs_source_simple.h new file mode 100644 index 000000000..f320cbb4d --- /dev/null +++ b/gr-msdd6000/src/msdd_rs_source_simple.h @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_MSDD_RS_SOURCE_SIMPLE_H +#define INCLUDED_MSDD_RS_SOURCE_SIMPLE_H + +#include <gr_sync_block.h> +#include <msdd6000_rs.h> +#include <boost/scoped_ptr.hpp> + +class msdd_rs_source_simple; +typedef boost::shared_ptr<msdd_rs_source_simple> msdd_rs_source_simple_sptr; + + +// public shared_ptr constructor + +msdd_rs_source_simple_sptr msdd_rs_make_source_simple ( const char *src, unsigned short port_src); + + +class msdd_rs_source_simple : public gr_sync_block { + private: + friend msdd_rs_source_simple_sptr + msdd_rs_make_source_simple ( const char *src, unsigned short port_src); + + boost::scoped_ptr<MSDD6000_RS> rcv; + int d_lastseq; + + protected: + msdd_rs_source_simple (const char *src, unsigned short port_src); + + public: + ~msdd_rs_source_simple (); + bool stop(); + bool start(); + + /* function starts the flow of data from the digitizer */ + int start_data(); + /* function stops the flow of data from the digitizer */ + int stop_data(); + + // Do not need this // +// bool set_decim_rate(unsigned int); + /* Adding functions for setting the sample rate and + * receiver bandwidth + */ + + /* hardware commands -- change current state of digitizer */ + bool set_ddc_samp_rate(double); + bool set_ddc_bw(double); + + bool set_rx_freq(double); + bool set_ddc_gain(double); + bool set_rf_atten(double); + + int work(int, gr_vector_const_void_star&, gr_vector_void_star&); + + /* Query methods -- query current state of digitizer */ + long pull_adc_freq(); + float pull_ddc_samp_rate(); + float pull_ddc_bw(); + float pull_rx_freq(); + int pull_ddc_gain(); + int pull_rf_atten(); + + /* Pulling back gain and frequency ranges */ + std::vector<int> gain_range(); + std::vector<float> freq_range(); +}; + +#endif /* INCLUDED_MSDD_RS__RS__SOURCE_C_H */ diff --git a/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py b/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py new file mode 100755 index 000000000..4855375b8 --- /dev/null +++ b/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py @@ -0,0 +1,350 @@ +#!/usr/bin/env python +# +# Copyright 2009 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. +# + +from gnuradio import gr +from gnuradio import msdd_rs +from gnuradio import eng_notation +from gnuradio.eng_option import eng_option +from gnuradio.qtgui import qtgui +from optparse import OptionParser +import sys,time + +try: + from gnuradio.qtgui import qtgui + from PyQt4 import QtGui, QtCore + import sip +except ImportError: + print "Please install gr-qtgui." + sys.exit(1) + +try: + from msdd_display_qtgui import Ui_MainWindow +except ImportError: + print "Error: could not find msdd_display_qtgui.py:" + print "\t\"pyuic4 msdd_display_qtgui.ui -o msdd_display_qtgui.py\"" + sys.exit(1) + + +# //////////////////////////////////////////////////////////////////// +# Define the QT Interface and Control Dialog +# //////////////////////////////////////////////////////////////////// + + +class main_window(QtGui.QMainWindow): + def __init__(self, snk, fg, parent=None): + + QtGui.QWidget.__init__(self, parent) + self.gui = Ui_MainWindow() + self.gui.setupUi(self) + + self.fg = fg + + # Add the qtsnk widgets to the layout box + self.gui.sinkLayout.addWidget(snk) + + self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001)) + + # Connect up some signals + self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), + self.pauseFg) + self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), + self.frequencyEditText) + self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), + self.gainEditText) + self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), + self.bandwidthEditText) + self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), + self.amplifierEditText) + + self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), + self.saveData) + self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) + + self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"), + self.dcGainEditText) + self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"), + self.dcCancelClicked) + + def pauseFg(self): + if(self.gui.pauseButton.text() == "Pause"): + self.fg.stop() + self.fg.wait() + self.fg.stop_data() + self.gui.pauseButton.setText("Unpause") + else: + self.fg.start() + self.fg.start_data() + self.gui.pauseButton.setText("Pause") + + + # Functions to set the values in the GUI + def set_frequency(self, freq): + self.freq = freq + sfreq = eng_notation.num_to_str(self.freq) + self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) + + def set_gain(self, gain): + self.gain = gain + self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) + + def set_bandwidth(self, bw): + self.bw = bw + sbw = eng_notation.num_to_str(self.bw) + self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) + + def set_amplifier(self, amp): + self.amp = amp + self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) + + + # Functions called when signals are triggered in the GUI + def frequencyEditText(self): + try: + freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) + self.fg.set_frequency(freq) + self.freq = freq + except RuntimeError: + pass + + def gainEditText(self): + try: + gain = float(self.gui.gainEdit.text()) + self.fg.set_gain(gain) + self.gain = gain + except ValueError: + pass + + def bandwidthEditText(self): + try: + bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) + self.fg.set_bandwidth(bw) + self.bw = bw + except ValueError: + pass + + def amplifierEditText(self): + try: + amp = float(self.gui.amplifierEdit.text()) + self.fg.set_amplifier_gain(amp) + self.amp = amp + except ValueError: + pass + + def saveData(self): + fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); + if(len(fileName)): + self.fg.save_to_file(str(fileName)) + + def dcGainEditText(self): + gain = float(self.gui.dcGainEdit.text()) + self.fg.set_dc_gain(gain) + + def dcCancelClicked(self, state): + self.dcGainEditText() + self.fg.cancel_dc(state) + + + +class my_top_block(gr.top_block): + def __init__(self): + gr.top_block.__init__(self) + + parser = OptionParser(option_class=eng_option) + parser.add_option("-e", "--interface", type="string", default="eth0", + help="select Ethernet interface, default is eth0") + parser.add_option("-m", "--mac-addr", type="string", default="", + help="select USRP by MAC address, default is auto-select") + parser.add_option("-W", "--bw", type="float", default=1e6, + help="set bandwidth of receiver [default=%default]") + parser.add_option("-f", "--freq", type="eng_float", default="2.4G", + help="set frequency to FREQ", metavar="FREQ") + parser.add_option("-g", "--gain", type="eng_float", default=None, + help="set gain in dB (default is midpoint)") + parser.add_option("--fft-size", type="int", default=2048, + help="Set number of FFT bins [default=%default]") + (options, args) = parser.parse_args() + + if len(args) != 0: + parser.print_help() + sys.exit(1) + self.options = options + self.show_debug_info = True + + self.qapp = QtGui.QApplication(sys.argv) + +# self.u = usrp2.source_32fc(options.interface, options.mac_addr) + self.u = msdd_rs.source_simple("192.168.1.20", 10000); + self.conv = gr.interleaved_short_to_complex(); + self._adc_rate = self.u.pull_adc_freq() + self.set_bandwidth(options.bw) + + if options.gain is None: + # if no gain was specified, use the mid-point in dB +# g = self.u.gain_range() + g = [0, 10] + #options.gain = float(g[0]+g[1])/2 + options.gain = float(0) + self.set_gain(options.gain) + + if options.freq is None: + options.freq = 2.4e9; +# # if no frequency was specified, use the mid-point of the subdev +# f = self.u.freq_range() +# options.freq = float(f[0]+f[1])/2 + + self.set_frequency(options.freq) + + self._fftsize = options.fft_size + + + self._freq = options.freq; + self._bandwidth = 400; + + self.set_bandwidth(self._bandwidth); + + self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, + self._freq, self._bandwidth, + "USRP2 Display", + True, True, False, True, False) + + # Set up internal amplifier + self.amp = gr.multiply_const_cc(0.0) + self.set_amplifier_gain(0.01) + + # Create a single-pole IIR filter to remove DC + # but don't connect it yet + self.dc_gain = 0.001 + self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) + self.dc_sub = gr.sub_cc() + + self.agc = gr.agc2_cc(1e-3, 1e-5, 0.01, 0.01, 10); + + self.connect(self.u, self.conv, self.snk) + #self.connect(self.u, self.conv, self.amp, self.snk) + + if self.show_debug_info: + print "Decimation rate: ", self._decim + print "Bandwidth: ", self._bandwidth +# print "D'board: ", self.u.daughterboard_id() + + # Get the reference pointer to the SpectrumDisplayForm QWidget + # Wrap the pointer as a PyQt SIP object + # This can now be manipulated as a PyQt4.QtGui.QWidget + self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) + + self.main_win = main_window(self.pysink, self) + + self.main_win.set_frequency(self._freq) + self.main_win.set_gain(self._gain) + self.main_win.set_bandwidth(self._bandwidth) + self.main_win.set_amplifier(self._amp_value) + + self.main_win.show() + + + def save_to_file(self, name): + self.lock() + + # Add file sink to save data + self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) + self.connect(self.conv, self.file_sink) + + self.unlock() + + def set_gain(self, gain): + self._gain = gain + self.u.set_ddc_gain(self._gain) + + def set_frequency(self, freq): + self._freq = freq + r = self.u.set_rx_freq(freq) + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_bandwidth(self, bw): + self._bandwidth = bw + self._decim = int(self._adc_rate / self._bandwidth) +# self.u.set_decim_rate(self._decim) + r1 = self.u.set_ddc_samp_rate( bw ); + r2 = self.u.set_ddc_bw( bw ); + self.u.start_data(); + + print r1 + print r2; + + time.sleep(0.05); + bw = self.u.pull_ddc_bw(); + sr = self.u.pull_ddc_samp_rate(); + fc = self.u.pull_rx_freq(); + + #self.snk.d_bandwidth = sr; + + print bw; + print sr; + print fc; + +# sys.exit(-1); + + try: + self.snk.set_frequency_range(self._freq, self._bandwidth) + except: + pass + + def set_amplifier_gain(self, amp): + self._amp_value = amp + self.amp.set_k(self._amp_value) + + def set_dc_gain(self, gain): + self.dc.set_taps(gain) + + def cancel_dc(self, state): + self.lock() + + if(state): + self.disconnect(self.u, self.amp) + self.connect(self.u, (self.dc_sub,0)) + self.connect(self.u, self.dc, (self.dc_sub,1)) + self.connect(self.dc_sub, self.amp) + else: + self.disconnect(self.dc_sub, self.amp) + self.disconnect(self.dc, (self.dc_sub,1)) + self.disconnect(self.u, self.dc) + self.disconnect(self.u, (self.dc_sub,0)) + self.connect(self.u, self.amp) + + self.unlock() + +def main (): + tb = my_top_block() + tb.start() + tb.u.start_data(); + tb.snk.exec_(); + +if __name__ == '__main__': + try: + main () + except KeyboardInterrupt: + pass + diff --git a/gr-noaa/README b/gr-noaa/README index 29d11f593..f00d2d28d 100644 --- a/gr-noaa/README +++ b/gr-noaa/README @@ -40,7 +40,7 @@ be set in the configuration file prior to running. It has no command-line parameters, and works identically to the GUI scripts. -demod_hrpt_file.py +hrpt_demod_file.py ------------------ This non-GUI script will operate on a file generated with diff --git a/gr-noaa/apps/.gitignore b/gr-noaa/apps/.gitignore index 6bd1ab995..cd8d543cc 100644 --- a/gr-noaa/apps/.gitignore +++ b/gr-noaa/apps/.gitignore @@ -1,2 +1,3 @@ *.dat -*.txt
\ No newline at end of file +*.txt +*.hrpt diff --git a/gr-noaa/apps/Makefile.am b/gr-noaa/apps/Makefile.am index 961b09afa..e246ba76a 100644 --- a/gr-noaa/apps/Makefile.am +++ b/gr-noaa/apps/Makefile.am @@ -24,15 +24,17 @@ include $(top_srcdir)/Makefile.common if PYTHON dist_bin_SCRIPTS = \ - demod_hrpt_file.py \ + hrpt_decode.py \ + hrpt_demod.py \ file_rx_hrpt.py \ usrp_rx_hrpt.py \ usrp_rx_hrpt_nogui.py \ usrp_rx_lrit.py EXTRA_DIST = \ + hrpt_decode.grc \ + hrpt_demod.grc \ file_rx_hrpt.grc \ - demod_hrpt_file.grc \ usrp_rx_hrpt.grc \ usrp_rx_hrpt_nogui.grc \ usrp_rx_lrit.grc diff --git a/gr-noaa/apps/file_rx_hrpt.grc b/gr-noaa/apps/file_rx_hrpt.grc index f34143756..e3cccd393 100644 --- a/gr-noaa/apps/file_rx_hrpt.grc +++ b/gr-noaa/apps/file_rx_hrpt.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Nov 2 08:30:47 2009</timestamp> + <timestamp>Mon Nov 9 07:47:17 2009</timestamp> <block> <key>options</key> <param> @@ -60,29 +60,6 @@ <key>variable</key> <param> <key>id</key> - <value>max_carrier_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>2*math.pi*100e3/sample_rate</value> - </param> - <param> - <key>_coordinate</key> - <value>(575, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> <value>sym_rate</value> </param> <param> @@ -129,29 +106,6 @@ <key>variable</key> <param> <key>id</key> - <value>hs</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>int(sps/2.0)</value> - </param> - <param> - <key>_coordinate</key> - <value>(499, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> <value>sample_rate</value> </param> <param> @@ -172,103 +126,6 @@ </param> </block> <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(705, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>side</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>'A'</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'side'</value> - </param> - <param> - <key>writeback</key> - <value>side</value> - </param> - <param> - <key>_coordinate</key> - <value>(194, 253)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_file_sink</key> - <param> - <key>id</key> - <value>frame_sink</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>file</key> - <value>output_filename</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(973, 1024)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>virtual_source</key> <param> <key>id</key> @@ -491,25 +348,6 @@ </param> </block> <block> - <key>noaa_hrpt_decoder</key> - <param> - <key>id</key> - <value>decoder</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(974, 925)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>variable</key> <param> <key>id</key> @@ -614,22 +452,26 @@ </param> </block> <block> - <key>gr_throttle</key> + <key>gr_file_source</key> <param> <key>id</key> - <value>throttle</value> + <value>gr_file_source_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>file</key> + <value>input_filename</value> + </param> + <param> <key>type</key> <value>short</value> </param> <param> - <key>samples_per_second</key> - <value>sample_rate</value> + <key>repeat</key> + <value>False</value> </param> <param> <key>vlen</key> @@ -637,46 +479,183 @@ </param> <param> <key>_coordinate</key> - <value>(75, 679)</value> + <value>(76, 613)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>gr_file_source</key> + <key>notebook</key> <param> <key>id</key> - <value>gr_file_source_0</value> + <value>displays</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>file</key> - <value>input_filename</value> + <key>style</key> + <value>wx.NB_TOP</value> + </param> + <param> + <key>labels</key> + <value>['Spectrum','Demod']</value> + </param> + <param> + <key>grid_pos</key> + <value>1,0,1,2</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(12, 249)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>rx_fft</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> </param> <param> <key>type</key> - <value>short</value> + <value>complex</value> </param> <param> - <key>repeat</key> + <key>title</key> + <value>RX Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>sample_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>y_per_div</key> + <value>5</value> + </param> + <param> + <key>y_divs</key> + <value>8</value> + </param> + <param> + <key>ref_level</key> + <value>-5</value> + </param> + <param> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>peak_hold</key> <value>False</value> </param> <param> + <key>average</key> + <value>True</value> + </param> + <param> + <key>avg_alpha</key> + <value>0.1</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value>640, 360</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 0, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value>displays, 0</value> + </param> + <param> + <key>_coordinate</key> + <value>(471, 450)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_binary_slicer_fb</key> + <param> + <key>id</key> + <value>gr_binary_slicer_fb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(393, 975)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_throttle</key> + <param> + <key>id</key> + <value>throttle</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>short</value> + </param> + <param> + <key>samples_per_second</key> + <value>2*sample_rate</value> + </param> + <param> <key>vlen</key> <value>1</value> </param> <param> <key>_coordinate</key> - <value>(76, 613)</value> + <value>(75, 679)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> @@ -695,7 +674,7 @@ </param> <param> <key>value</key> - <value>'usrp.dat'</value> + <value>usrp.dat</value> </param> <param> <key>type</key> @@ -707,7 +686,7 @@ </param> <param> <key>_coordinate</key> - <value>(198, 107)</value> + <value>(196, 98)</value> </param> <param> <key>_rotation</key> @@ -730,7 +709,7 @@ </param> <param> <key>value</key> - <value>16</value> + <value>32</value> </param> <param> <key>type</key> @@ -742,7 +721,7 @@ </param> <param> <key>_coordinate</key> - <value>(308, 107)</value> + <value>(307, 98)</value> </param> <param> <key>_rotation</key> @@ -797,7 +776,7 @@ </param> <param> <key>_coordinate</key> - <value>(397, 108)</value> + <value>(397, 98)</value> </param> <param> <key>_rotation</key> @@ -852,7 +831,7 @@ </param> <param> <key>_coordinate</key> - <value>(539, 105)</value> + <value>(540, 98)</value> </param> <param> <key>_rotation</key> @@ -860,10 +839,10 @@ </param> </block> <block> - <key>variable_config</key> + <key>variable</key> <param> <key>id</key> - <value>saved_pll_alpha</value> + <value>hs</value> </param> <param> <key>_enabled</key> @@ -871,31 +850,11 @@ </param> <param> <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'pll_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>pll_alpha</value> + <value>int(sps/2.0)</value> </param> <param> <key>_coordinate</key> - <value>(363, 254)</value> + <value>(499, 19)</value> </param> <param> <key>_rotation</key> @@ -903,10 +862,10 @@ </param> </block> <block> - <key>variable_config</key> + <key>variable</key> <param> <key>id</key> - <value>saved_clock_alpha</value> + <value>max_carrier_offset</value> </param> <param> <key>_enabled</key> @@ -914,31 +873,34 @@ </param> <param> <key>value</key> - <value>0.05</value> + <value>2*math.pi*100e3/sample_rate</value> </param> <param> - <key>type</key> - <value>real</value> + <key>_coordinate</key> + <value>(575, 19)</value> </param> <param> - <key>config_file</key> - <value>config_filename</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> + <key>id</key> + <value>max_clock_offset</value> </param> <param> - <key>option</key> - <value>'clock_alpha'</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>writeback</key> - <value>clock_alpha</value> + <key>value</key> + <value>100e-6</value> </param> <param> <key>_coordinate</key> - <value>(527, 256)</value> + <value>(705, 19)</value> </param> <param> <key>_rotation</key> @@ -957,7 +919,7 @@ </param> <param> <key>value</key> - <value>'frames.dat'</value> + <value>'frames.hrpt'</value> </param> <param> <key>type</key> @@ -981,7 +943,7 @@ </param> <param> <key>_coordinate</key> - <value>(689, 257)</value> + <value>(521, 254)</value> </param> <param> <key>_rotation</key> @@ -989,34 +951,42 @@ </param> </block> <block> - <key>notebook</key> + <key>variable_config</key> <param> <key>id</key> - <value>displays</value> + <value>saved_pll_alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>style</key> - <value>wx.NB_TOP</value> + <key>value</key> + <value>0.01</value> </param> <param> - <key>labels</key> - <value>['Spectrum','Demod']</value> + <key>type</key> + <value>real</value> </param> <param> - <key>grid_pos</key> - <value>1,0,1,2</value> + <key>config_file</key> + <value>config_filename</value> </param> <param> - <key>notebook</key> - <value></value> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'pll_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>pll_alpha</value> </param> <param> <key>_coordinate</key> - <value>(12, 249)</value> + <value>(195, 253)</value> </param> <param> <key>_rotation</key> @@ -1024,86 +994,88 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>variable_config</key> <param> <key>id</key> - <value>rx_fft</value> + <value>saved_clock_alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>title</key> - <value>RX Spectrum</value> + <key>value</key> + <value>0.01</value> </param> <param> - <key>samp_rate</key> - <value>sample_rate</value> + <key>type</key> + <value>real</value> </param> <param> - <key>baseband_freq</key> - <value>0</value> + <key>config_file</key> + <value>config_filename</value> </param> <param> - <key>y_per_div</key> - <value>5</value> + <key>section</key> + <value>'usrp_rx_hrpt'</value> </param> <param> - <key>y_divs</key> - <value>8</value> + <key>option</key> + <value>'clock_alpha'</value> </param> <param> - <key>ref_level</key> - <value>-5</value> + <key>writeback</key> + <value>clock_alpha</value> </param> <param> - <key>ref_scale</key> - <value>2.0</value> + <key>_coordinate</key> + <value>(360, 255)</value> </param> <param> - <key>fft_size</key> - <value>1024</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>noaa_hrpt_deframer</key> <param> - <key>fft_rate</key> - <value>15</value> + <key>id</key> + <value>deframer</value> </param> <param> - <key>peak_hold</key> - <value>False</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>average</key> - <value>True</value> + <key>_coordinate</key> + <value>(579, 975)</value> </param> <param> - <key>avg_alpha</key> - <value>0.1</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> <param> - <key>win</key> - <value>None</value> + <key>id</key> + <value>decoder</value> </param> <param> - <key>win_size</key> - <value>640, 360</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>grid_pos</key> - <value>0, 0, 1, 1</value> + <key>verbose</key> + <value>True</value> </param> <param> - <key>notebook</key> - <value>displays, 0</value> + <key>output</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(471, 450)</value> + <value>(849, 925)</value> </param> <param> <key>_rotation</key> @@ -1111,37 +1083,30 @@ </param> </block> <block> - <key>gr_binary_slicer_fb</key> + <key>gr_file_sink</key> <param> <key>id</key> - <value>gr_binary_slicer_fb_0</value> + <value>frame_sink</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>_coordinate</key> - <value>(393, 975)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> + <key>file</key> + <value>output_filename</value> </param> - </block> - <block> - <key>noaa_hrpt_deframer</key> <param> - <key>id</key> - <value>deframer</value> + <key>type</key> + <value>short</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(762, 975)</value> + <value>(848, 1007)</value> </param> <param> <key>_rotation</key> diff --git a/gr-noaa/apps/file_rx_hrpt.py b/gr-noaa/apps/file_rx_hrpt.py index 1513141ec..13b887635 100755 --- a/gr-noaa/apps/file_rx_hrpt.py +++ b/gr-noaa/apps/file_rx_hrpt.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: USRP HRPT Receiver -# Generated: Mon Nov 2 08:30:47 2009 +# Generated: Mon Nov 9 07:47:17 2009 ################################################## from gnuradio import eng_notation @@ -22,7 +22,7 @@ import wx class file_rx_hrpt(grc_wxgui.top_block_gui): - def __init__(self, input_filename='usrp.dat', decim=16): + def __init__(self, input_filename="usrp.dat", decim=32): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## @@ -41,25 +41,20 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') - except: saved_pll_alpha = 0.05 + except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') - except: saved_clock_alpha = 0.05 + except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(config_filename) - try: side = self._side_config.get('usrp_rx_hrpt', 'side') - except: side = 'A' - self.side = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') - except: output_filename = 'frames.dat' + except: output_filename = 'frames.hrpt' self.output_filename = output_filename - self.max_clock_offset = max_clock_offset = 0.1 + self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self.clock_alpha = clock_alpha = saved_clock_alpha @@ -126,7 +121,7 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) - self.decoder = noaa.hrpt_decoder() + self.decoder = noaa.hrpt_decoder(True,False) self.deframer = noaa.hrpt_deframer() self.demod_scope = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), @@ -164,7 +159,7 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): size=(640, 360), ) self.displays.GetPage(0).GridAdd(self.rx_fft.win, 0, 0, 1, 1) - self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate) + self.throttle = gr.throttle(gr.sizeof_short*1, 2*sample_rate) ################################################## # Connections @@ -196,18 +191,18 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): def set_sample_rate(self, sample_rate): self.sample_rate = sample_rate - self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) self.set_sps(self.sample_rate/self.sym_rate) self.rx_fft.set_sample_rate(self.sample_rate) + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) def set_config_filename(self, config_filename): self.config_filename = config_filename - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) + self._output_filename_config = ConfigParser.ConfigParser() + self._output_filename_config.read(self.config_filename) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) + self._output_filename_config.write(open(self.config_filename, 'w')) self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(self.config_filename) if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'): @@ -220,17 +215,11 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self._saved_clock_alpha_config.add_section('usrp_rx_hrpt') self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._saved_clock_alpha_config.write(open(self.config_filename, 'w')) - self._output_filename_config = ConfigParser.ConfigParser() - self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('usrp_rx_hrpt'): - self._output_filename_config.add_section('usrp_rx_hrpt') - self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) - self._output_filename_config.write(open(self.config_filename, 'w')) def set_sps(self, sps): self.sps = sps - self.set_hs(int(self.sps/2.0)) self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0) + self.set_hs(int(self.sps/2.0)) def set_saved_pll_alpha(self, saved_pll_alpha): self.saved_pll_alpha = saved_pll_alpha @@ -240,15 +229,6 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self.saved_clock_alpha = saved_clock_alpha self.set_clock_alpha(self.saved_clock_alpha) - def set_side(self, side): - self.side = side - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) - def set_pll_alpha(self, pll_alpha): self.pll_alpha = pll_alpha self.pll.set_alpha(self.pll_alpha) @@ -297,9 +277,9 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") - parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default='usrp.dat', + parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat", help="Set usrp.dat [default=%default]") - parser.add_option("-d", "--decim", dest="decim", type="intx", default=16, + parser.add_option("-d", "--decim", dest="decim", type="intx", default=32, help="Set decim [default=%default]") (options, args) = parser.parse_args() tb = file_rx_hrpt(input_filename=options.input_filename, decim=options.decim) diff --git a/gr-noaa/apps/hrpt_decode.grc b/gr-noaa/apps/hrpt_decode.grc new file mode 100644 index 000000000..39fe195d1 --- /dev/null +++ b/gr-noaa/apps/hrpt_decode.grc @@ -0,0 +1,428 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Sun Nov 8 10:48:59 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>hrpt_decode</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>4096,4096</value> + </param> + <param> + <key>generate_options</key> + <value>no_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>run</value> + </param> + <param> + <key>run</key> + <value>True</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>variable</key> + <param> + <key>id</key> + <value>max_carrier_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>2*math.pi*100e3/sample_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(575, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>hs</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>int(sps/2.0)</value> + </param> + <param> + <key>_coordinate</key> + <value>(499, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sample_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>64e6/decim</value> + </param> + <param> + <key>_coordinate</key> + <value>(198, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import math, os</value> + </param> + <param> + <key>_coordinate</key> + <value>(11, 103)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100e-6</value> + </param> + <param> + <key>_coordinate</key> + <value>(710, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sym_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>600*1109</value> + </param> + <param> + <key>_coordinate</key> + <value>(307, 18)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sps</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>sample_rate/sym_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(400, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>decim</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>decim</value> + </param> + <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>type</key> + <value>intx</value> + </param> + <param> + <key>short_id</key> + <value>d</value> + </param> + <param> + <key>_coordinate</key> + <value>(202, 102)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>pll_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>pll_alpha</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>eng_float</value> + </param> + <param> + <key>short_id</key> + <value>p</value> + </param> + <param> + <key>_coordinate</key> + <value>(294, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>clock_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>clock_alpha</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>eng_float</value> + </param> + <param> + <key>short_id</key> + <value>s</value> + </param> + <param> + <key>_coordinate</key> + <value>(395, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_file_source</key> + <param> + <key>id</key> + <value>file_source</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>file</key> + <value>input_filename</value> + </param> + <param> + <key>type</key> + <value>short</value> + </param> + <param> + <key>repeat</key> + <value>False</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(231, 419)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> + <param> + <key>id</key> + <value>decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(462, 419)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>input_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>input_filename</value> + </param> + <param> + <key>value</key> + <value>frames.hrpt</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>F</value> + </param> + <param> + <key>_coordinate</key> + <value>(522, 100)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>file_source</source_block_id> + <sink_block_id>decoder</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-noaa/apps/hrpt_decode.py b/gr-noaa/apps/hrpt_decode.py new file mode 100755 index 000000000..158780b17 --- /dev/null +++ b/gr-noaa/apps/hrpt_decode.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Hrpt Decode +# Generated: Sun Nov 8 10:49:01 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import noaa +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from optparse import OptionParser +import math, os + +class hrpt_decode(gr.top_block): + + def __init__(self, decim=32, pll_alpha=0.01, clock_alpha=0.01, input_filename="frames.hrpt"): + gr.top_block.__init__(self, "Hrpt Decode") + + ################################################## + # Parameters + ################################################## + self.decim = decim + self.pll_alpha = pll_alpha + self.clock_alpha = clock_alpha + self.input_filename = input_filename + + ################################################## + # Variables + ################################################## + self.sym_rate = sym_rate = 600*1109 + self.sample_rate = sample_rate = 64e6/decim + self.sps = sps = sample_rate/sym_rate + self.max_clock_offset = max_clock_offset = 100e-6 + self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate + self.hs = hs = int(sps/2.0) + + ################################################## + # Blocks + ################################################## + self.decoder = noaa.hrpt_decoder(True,True) + self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False) + + ################################################## + # Connections + ################################################## + self.connect((self.file_source, 0), (self.decoder, 0)) + + def set_decim(self, decim): + self.decim = decim + self.set_sample_rate(64e6/self.decim) + + def set_pll_alpha(self, pll_alpha): + self.pll_alpha = pll_alpha + + def set_clock_alpha(self, clock_alpha): + self.clock_alpha = clock_alpha + + def set_input_filename(self, input_filename): + self.input_filename = input_filename + + def set_sym_rate(self, sym_rate): + self.sym_rate = sym_rate + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sample_rate(self, sample_rate): + self.sample_rate = sample_rate + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sps(self, sps): + self.sps = sps + self.set_hs(int(self.sps/2.0)) + + def set_max_clock_offset(self, max_clock_offset): + self.max_clock_offset = max_clock_offset + + def set_max_carrier_offset(self, max_carrier_offset): + self.max_carrier_offset = max_carrier_offset + + def set_hs(self, hs): + self.hs = hs + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + parser.add_option("-d", "--decim", dest="decim", type="intx", default=32, + help="Set decim [default=%default]") + parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set pll_alpha [default=%default]") + parser.add_option("-s", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set clock_alpha [default=%default]") + parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="frames.hrpt", + help="Set frames.hrpt [default=%default]") + (options, args) = parser.parse_args() + tb = hrpt_decode(decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha, input_filename=options.input_filename) + tb.run() + diff --git a/gr-noaa/apps/demod_hrpt_file.grc b/gr-noaa/apps/hrpt_demod.grc index 3c5e3efa4..8af3d82dd 100644 --- a/gr-noaa/apps/demod_hrpt_file.grc +++ b/gr-noaa/apps/hrpt_demod.grc @@ -1,11 +1,11 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Nov 2 07:06:57 2009</timestamp> + <timestamp>Sun Nov 8 10:41:07 2009</timestamp> <block> <key>options</key> <param> <key>id</key> - <value>demod_hrpt_file</value> + <value>hrpt_demod</value> </param> <param> <key>_enabled</key> @@ -83,7 +83,7 @@ <key>variable</key> <param> <key>id</key> - <value>sym_rate</value> + <value>hs</value> </param> <param> <key>_enabled</key> @@ -91,11 +91,11 @@ </param> <param> <key>value</key> - <value>600*1109</value> + <value>int(sps/2.0)</value> </param> <param> <key>_coordinate</key> - <value>(301, 19)</value> + <value>(499, 19)</value> </param> <param> <key>_rotation</key> @@ -106,7 +106,7 @@ <key>variable</key> <param> <key>id</key> - <value>sps</value> + <value>sample_rate</value> </param> <param> <key>_enabled</key> @@ -114,11 +114,11 @@ </param> <param> <key>value</key> - <value>sample_rate/sym_rate</value> + <value>64e6/decim</value> </param> <param> <key>_coordinate</key> - <value>(397, 19)</value> + <value>(198, 17)</value> </param> <param> <key>_rotation</key> @@ -126,22 +126,22 @@ </param> </block> <block> - <key>variable</key> + <key>import</key> <param> <key>id</key> - <value>hs</value> + <value>import_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>int(sps/2.0)</value> + <key>import</key> + <value>import math, os</value> </param> <param> <key>_coordinate</key> - <value>(499, 19)</value> + <value>(11, 103)</value> </param> <param> <key>_rotation</key> @@ -149,22 +149,34 @@ </param> </block> <block> - <key>variable</key> + <key>parameter</key> <param> <key>id</key> - <value>sample_rate</value> + <value>input_filename</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>label</key> + <value>input_filename</value> + </param> + <param> <key>value</key> - <value>64e6/decim</value> + <value>usrp.dat</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>F</value> </param> <param> <key>_coordinate</key> - <value>(198, 17)</value> + <value>(618, 102)</value> </param> <param> <key>_rotation</key> @@ -172,80 +184,69 @@ </param> </block> <block> - <key>variable</key> + <key>parameter</key> <param> <key>id</key> - <value>max_clock_offset</value> + <value>output_filename</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(710, 17)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> + <key>label</key> + <value>output_filename</value> </param> - </block> - <block> - <key>import</key> <param> - <key>id</key> - <value>import_0</value> + <key>value</key> + <value>frames.dat</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>type</key> + <value>string</value> </param> <param> - <key>import</key> - <value>import math, os</value> + <key>short_id</key> + <value>o</value> </param> <param> <key>_coordinate</key> - <value>(11, 103)</value> + <value>(726, 102)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> - <key>parameter</key> + <key>gr_file_source</key> <param> <key>id</key> - <value>decim</value> + <value>file_source</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>decim</value> + <key>file</key> + <value>input_filename</value> </param> <param> - <key>value</key> - <value>16</value> + <key>type</key> + <value>short</value> </param> <param> - <key>type</key> - <value>intx</value> + <key>repeat</key> + <value>False</value> </param> <param> - <key>short_id</key> - <value>d</value> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(202, 102)</value> + <value>(63, 277)</value> </param> <param> <key>_rotation</key> @@ -253,34 +254,18 @@ </param> </block> <block> - <key>parameter</key> + <key>gr_interleaved_short_to_complex</key> <param> <key>id</key> - <value>pll_alpha</value> + <value>cs2cf</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>pll_alpha</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>eng_float</value> - </param> - <param> - <key>short_id</key> - <value>p</value> - </param> - <param> <key>_coordinate</key> - <value>(294, 101)</value> + <value>(275, 289)</value> </param> <param> <key>_rotation</key> @@ -288,34 +273,38 @@ </param> </block> <block> - <key>parameter</key> + <key>gr_agc_xx</key> <param> <key>id</key> - <value>clock_alpha</value> + <value>agc</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>clock_alpha</value> + <key>type</key> + <value>complex</value> </param> <param> - <key>value</key> - <value>0.05</value> + <key>rate</key> + <value>1e-5</value> </param> <param> - <key>type</key> - <value>eng_float</value> + <key>reference</key> + <value>1.0</value> </param> <param> - <key>short_id</key> - <value>a</value> + <key>gain</key> + <value>1.0/32768.0</value> + </param> + <param> + <key>max_gain</key> + <value>1.0</value> </param> <param> <key>_coordinate</key> - <value>(395, 101)</value> + <value>(117, 394)</value> </param> <param> <key>_rotation</key> @@ -323,34 +312,30 @@ </param> </block> <block> - <key>parameter</key> + <key>noaa_hrpt_pll_cf</key> <param> <key>id</key> - <value>sync_alpha</value> + <value>pll</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>sync_alpha</value> - </param> - <param> - <key>value</key> - <value>0.05</value> + <key>alpha</key> + <value>pll_alpha</value> </param> <param> - <key>type</key> - <value>eng_float</value> + <key>beta</key> + <value>pll_alpha**2/4.0</value> </param> <param> - <key>short_id</key> - <value>s</value> + <key>max_offset</key> + <value>max_carrier_offset</value> </param> <param> <key>_coordinate</key> - <value>(508, 102)</value> + <value>(292, 402)</value> </param> <param> <key>_rotation</key> @@ -358,34 +343,34 @@ </param> </block> <block> - <key>parameter</key> + <key>gr_moving_average_xx</key> <param> <key>id</key> - <value>input_filename</value> + <value>gr_moving_average_xx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>input_filename</value> + <key>type</key> + <value>float</value> </param> <param> - <key>value</key> - <value>usrp.dat</value> + <key>length</key> + <value>hs</value> </param> <param> - <key>type</key> - <value>string</value> + <key>scale</key> + <value>1.0/hs</value> </param> <param> - <key>short_id</key> - <value>F</value> + <key>max_iter</key> + <value>4000</value> </param> <param> <key>_coordinate</key> - <value>(618, 102)</value> + <value>(504, 402)</value> </param> <param> <key>_rotation</key> @@ -393,69 +378,61 @@ </param> </block> <block> - <key>parameter</key> + <key>gr_clock_recovery_mm_xx</key> <param> <key>id</key> - <value>output_filename</value> + <value>gr_clock_recovery_mm_xx_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>label</key> - <value>output_filename</value> + <key>type</key> + <value>float</value> </param> <param> - <key>value</key> - <value>frames.dat</value> + <key>omega</key> + <value>sps/2.0</value> </param> <param> - <key>type</key> - <value>string</value> + <key>gain_omega</key> + <value>clock_alpha**2/4.0</value> </param> <param> - <key>short_id</key> - <value>o</value> + <key>mu</key> + <value>0.5</value> + </param> + <param> + <key>gain_mu</key> + <value>clock_alpha</value> + </param> + <param> + <key>omega_relative_limit</key> + <value>max_clock_offset</value> </param> <param> <key>_coordinate</key> - <value>(726, 102)</value> + <value>(703, 386)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>gr_file_source</key> + <key>noaa_hrpt_deframer</key> <param> <key>id</key> - <value>file_source</value> + <value>noaa_hrpt_deframer_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>file</key> - <value>input_filename</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>repeat</key> - <value>False</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> <key>_coordinate</key> - <value>(62, 306)</value> + <value>(1142, 422)</value> </param> <param> <key>_rotation</key> @@ -463,10 +440,10 @@ </param> </block> <block> - <key>gr_interleaved_short_to_complex</key> + <key>gr_binary_slicer_fb</key> <param> <key>id</key> - <value>cs2cf</value> + <value>gr_binary_slicer_fb_0</value> </param> <param> <key>_enabled</key> @@ -474,7 +451,7 @@ </param> <param> <key>_coordinate</key> - <value>(297, 318)</value> + <value>(960, 422)</value> </param> <param> <key>_rotation</key> @@ -482,38 +459,45 @@ </param> </block> <block> - <key>gr_agc_xx</key> + <key>variable</key> <param> <key>id</key> - <value>agc</value> + <value>max_clock_offset</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> + <key>value</key> + <value>100e-6</value> </param> <param> - <key>rate</key> - <value>1e-5</value> + <key>_coordinate</key> + <value>(710, 17)</value> </param> <param> - <key>reference</key> - <value>1.0</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>gain</key> - <value>1.0/32768.0</value> + <key>id</key> + <value>sym_rate</value> </param> <param> - <key>max_gain</key> - <value>1.0</value> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>600*1109</value> </param> <param> <key>_coordinate</key> - <value>(538, 290)</value> + <value>(307, 18)</value> </param> <param> <key>_rotation</key> @@ -521,30 +505,22 @@ </param> </block> <block> - <key>noaa_hrpt_pll_cf</key> + <key>variable</key> <param> <key>id</key> - <value>pll</value> + <value>sps</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>alpha</key> - <value>pll_alpha</value> - </param> - <param> - <key>beta</key> - <value>pll_alpha**2/4.0</value> - </param> - <param> - <key>max_offset</key> - <value>max_carrier_offset</value> + <key>value</key> + <value>sample_rate/sym_rate</value> </param> <param> <key>_coordinate</key> - <value>(720, 297)</value> + <value>(400, 17)</value> </param> <param> <key>_rotation</key> @@ -552,34 +528,34 @@ </param> </block> <block> - <key>gr_moving_average_xx</key> + <key>parameter</key> <param> <key>id</key> - <value>gr_moving_average_xx_0</value> + <value>decim</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>float</value> + <key>label</key> + <value>decim</value> </param> <param> - <key>length</key> - <value>hs</value> + <key>value</key> + <value>32</value> </param> <param> - <key>scale</key> - <value>1.0/hs</value> + <key>type</key> + <value>intx</value> </param> <param> - <key>max_iter</key> - <value>4000</value> + <key>short_id</key> + <value>d</value> </param> <param> <key>_coordinate</key> - <value>(949, 297)</value> + <value>(202, 102)</value> </param> <param> <key>_rotation</key> @@ -587,42 +563,34 @@ </param> </block> <block> - <key>gr_clock_recovery_mm_xx</key> + <key>parameter</key> <param> <key>id</key> - <value>gr_clock_recovery_mm_xx_0</value> + <value>pll_alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>omega</key> - <value>sps/2.0</value> - </param> - <param> - <key>gain_omega</key> - <value>clock_alpha**2/4.0</value> + <key>label</key> + <value>pll_alpha</value> </param> <param> - <key>mu</key> - <value>0.5</value> + <key>value</key> + <value>0.01</value> </param> <param> - <key>gain_mu</key> - <value>clock_alpha</value> + <key>type</key> + <value>eng_float</value> </param> <param> - <key>omega_relative_limit</key> - <value>max_clock_offset</value> + <key>short_id</key> + <value>p</value> </param> <param> <key>_coordinate</key> - <value>(1158, 281)</value> + <value>(294, 101)</value> </param> <param> <key>_rotation</key> @@ -630,30 +598,34 @@ </param> </block> <block> - <key>gr_file_sink</key> + <key>parameter</key> <param> <key>id</key> - <value>gr_file_sink_0</value> + <value>clock_alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>file</key> - <value>output_filename</value> + <key>label</key> + <value>clock_alpha</value> + </param> + <param> + <key>value</key> + <value>0.01</value> </param> <param> <key>type</key> - <value>short</value> + <value>eng_float</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>short_id</key> + <value>s</value> </param> <param> <key>_coordinate</key> - <value>(732, 615)</value> + <value>(395, 101)</value> </param> <param> <key>_rotation</key> @@ -664,57 +636,58 @@ <key>noaa_hrpt_decoder</key> <param> <key>id</key> - <value>noaa_hrpt_decoder_0</value> + <value>decoder</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>False</value> + </param> + <param> <key>_coordinate</key> - <value>(730, 537)</value> + <value>(1150, 341)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> - <key>gr_binary_slicer_fb</key> + <key>gr_file_sink</key> <param> <key>id</key> - <value>gr_binary_slicer_fb_0</value> + <value>gr_file_sink_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>_coordinate</key> - <value>(112, 537)</value> + <key>file</key> + <value>output_filename</value> </param> <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>noaa_hrpt_deframer</key> - <param> - <key>id</key> - <value>noaa_hrpt_deframer_0</value> + <key>type</key> + <value>short</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(536, 537)</value> + <value>(1144, 489)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <connection> @@ -761,7 +734,7 @@ </connection> <connection> <source_block_id>noaa_hrpt_deframer_0</source_block_id> - <sink_block_id>noaa_hrpt_decoder_0</sink_block_id> + <sink_block_id>decoder</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-noaa/apps/demod_hrpt_file.py b/gr-noaa/apps/hrpt_demod.py index d86650171..38d031686 100755 --- a/gr-noaa/apps/demod_hrpt_file.py +++ b/gr-noaa/apps/hrpt_demod.py @@ -1,8 +1,8 @@ #!/usr/bin/env python ################################################## # Gnuradio Python Flow Graph -# Title: Demod Hrpt File -# Generated: Mon Nov 2 07:06:57 2009 +# Title: Hrpt Demod +# Generated: Sun Nov 8 10:41:08 2009 ################################################## from gnuradio import eng_notation @@ -13,20 +13,19 @@ from gnuradio.gr import firdes from optparse import OptionParser import math, os -class demod_hrpt_file(gr.top_block): +class hrpt_demod(gr.top_block): - def __init__(self, decim=16, pll_alpha=0.05, clock_alpha=0.05, sync_alpha=0.05, input_filename="usrp.dat", output_filename="frames.dat"): - gr.top_block.__init__(self, "Demod Hrpt File") + def __init__(self, input_filename="usrp.dat", output_filename="frames.dat", decim=32, pll_alpha=0.01, clock_alpha=0.01): + gr.top_block.__init__(self, "Hrpt Demod") ################################################## # Parameters ################################################## + self.input_filename = input_filename + self.output_filename = output_filename self.decim = decim self.pll_alpha = pll_alpha self.clock_alpha = clock_alpha - self.sync_alpha = sync_alpha - self.input_filename = input_filename - self.output_filename = output_filename ################################################## # Variables @@ -34,7 +33,7 @@ class demod_hrpt_file(gr.top_block): self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim self.sps = sps = sample_rate/sym_rate - self.max_clock_offset = max_clock_offset = 0.1 + self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) @@ -43,12 +42,12 @@ class demod_hrpt_file(gr.top_block): ################################################## self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) self.cs2cf = gr.interleaved_short_to_complex() + self.decoder = noaa.hrpt_decoder(True,False) self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) - self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder() self.noaa_hrpt_deframer_0 = noaa.hrpt_deframer() self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) @@ -62,9 +61,15 @@ class demod_hrpt_file(gr.top_block): self.connect((self.cs2cf, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0, 0)) - self.connect((self.noaa_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) + self.connect((self.noaa_hrpt_deframer_0, 0), (self.decoder, 0)) self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0)) + def set_input_filename(self, input_filename): + self.input_filename = input_filename + + def set_output_filename(self, output_filename): + self.output_filename = output_filename + def set_decim(self, decim): self.decim = decim self.set_sample_rate(64e6/self.decim) @@ -79,15 +84,6 @@ class demod_hrpt_file(gr.top_block): self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) - def set_sync_alpha(self, sync_alpha): - self.sync_alpha = sync_alpha - - def set_input_filename(self, input_filename): - self.input_filename = input_filename - - def set_output_filename(self, output_filename): - self.output_filename = output_filename - def set_sym_rate(self, sym_rate): self.sym_rate = sym_rate self.set_sps(self.sample_rate/self.sym_rate) @@ -115,19 +111,17 @@ class demod_hrpt_file(gr.top_block): if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") - parser.add_option("-d", "--decim", dest="decim", type="intx", default=16, - help="Set decim [default=%default]") - parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), - help="Set pll_alpha [default=%default]") - parser.add_option("-a", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), - help="Set clock_alpha [default=%default]") - parser.add_option("-s", "--sync-alpha", dest="sync_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), - help="Set sync_alpha [default=%default]") parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat", help="Set usrp.dat [default=%default]") parser.add_option("-o", "--output-filename", dest="output_filename", type="string", default="frames.dat", help="Set frames.dat [default=%default]") + parser.add_option("-d", "--decim", dest="decim", type="intx", default=32, + help="Set decim [default=%default]") + parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set pll_alpha [default=%default]") + parser.add_option("-s", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set clock_alpha [default=%default]") (options, args) = parser.parse_args() - tb = demod_hrpt_file(decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha, sync_alpha=options.sync_alpha, input_filename=options.input_filename, output_filename=options.output_filename) + tb = hrpt_demod(input_filename=options.input_filename, output_filename=options.output_filename, decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha) tb.run() diff --git a/gr-noaa/apps/usrp_rx_hrpt.grc b/gr-noaa/apps/usrp_rx_hrpt.grc index ac7a87a16..990855f69 100644 --- a/gr-noaa/apps/usrp_rx_hrpt.grc +++ b/gr-noaa/apps/usrp_rx_hrpt.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Nov 2 08:31:09 2009</timestamp> + <timestamp>Mon Nov 9 07:56:11 2009</timestamp> <block> <key>options</key> <param> @@ -543,72 +543,6 @@ </param> </block> <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>output_filename</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>'frames.dat'</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'filename'</value> - </param> - <param> - <key>writeback</key> - <value>output_filename</value> - </param> - <param> - <key>_coordinate</key> - <value>(1139, 259)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(705, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>variable_slider</key> <param> <key>id</key> @@ -667,135 +601,6 @@ <key>variable_config</key> <param> <key>id</key> - <value>saved_pll_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'pll_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>pll_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(823, 258)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>saved_clock_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'clock_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>clock_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(981, 258)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>decim</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>16</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'decim'</value> - </param> - <param> - <key>writeback</key> - <value>decim</value> - </param> - <param> - <key>_coordinate</key> - <value>(351, 255)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> <value>side</value> </param> <param> @@ -1124,25 +929,6 @@ </param> </block> <block> - <key>noaa_hrpt_decoder</key> - <param> - <key>id</key> - <value>decoder</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(974, 925)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> <key>gr_agc_xx</key> <param> <key>id</key> @@ -1365,6 +1151,228 @@ <value>0</value> </param> </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>decim</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'decim'</value> + </param> + <param> + <key>writeback</key> + <value>decim</value> + </param> + <param> + <key>_coordinate</key> + <value>(351, 255)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_pll_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'pll_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>pll_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(823, 258)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_clock_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'clock_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>clock_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(981, 258)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>output_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>'frames.hrpt'</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'filename'</value> + </param> + <param> + <key>writeback</key> + <value>output_filename</value> + </param> + <param> + <key>_coordinate</key> + <value>(1139, 259)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> + <param> + <key>id</key> + <value>decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(974, 925)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100e-6</value> + </param> + <param> + <key>_coordinate</key> + <value>(705, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> <source_block_id>virtual_source_0</source_block_id> <sink_block_id>gr_binary_slicer_fb_0</sink_block_id> diff --git a/gr-noaa/apps/usrp_rx_hrpt.py b/gr-noaa/apps/usrp_rx_hrpt.py index a5f9a8e94..48c5f9d29 100755 --- a/gr-noaa/apps/usrp_rx_hrpt.py +++ b/gr-noaa/apps/usrp_rx_hrpt.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: USRP HRPT Receiver -# Generated: Mon Nov 2 08:31:10 2009 +# Generated: Mon Nov 9 07:56:11 2009 ################################################## from gnuradio import eng_notation @@ -33,7 +33,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') - except: decim = 16 + except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim @@ -46,7 +46,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') - except: saved_pll_alpha = 0.05 + except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) @@ -61,16 +61,16 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') - except: saved_clock_alpha = 0.05 + except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha self.side_text = side_text = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') - except: output_filename = 'frames.dat' + except: output_filename = 'frames.hrpt' self.output_filename = output_filename - self.max_clock_offset = max_clock_offset = 0.1 + self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self.gain = gain = saved_gain @@ -187,7 +187,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) - self.decoder = noaa.hrpt_decoder() + self.decoder = noaa.hrpt_decoder(True,True) self.deframer = noaa.hrpt_deframer() self.demod_scope = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), @@ -256,12 +256,18 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_gain_config.add_section('usrp_rx_hrpt') self._saved_gain_config.set('usrp_rx_hrpt', 'gain', str(self.gain)) self._saved_gain_config.write(open(self.config_filename, 'w')) - self._output_filename_config = ConfigParser.ConfigParser() - self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('usrp_rx_hrpt'): - self._output_filename_config.add_section('usrp_rx_hrpt') - self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) - self._output_filename_config.write(open(self.config_filename, 'w')) + self._side_config = ConfigParser.ConfigParser() + self._side_config.read(self.config_filename) + if not self._side_config.has_section('usrp_rx_hrpt'): + self._side_config.add_section('usrp_rx_hrpt') + self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) + self._side_config.write(open(self.config_filename, 'w')) + self._decim_config = ConfigParser.ConfigParser() + self._decim_config.read(self.config_filename) + if not self._decim_config.has_section('usrp_rx_hrpt'): + self._decim_config.add_section('usrp_rx_hrpt') + self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) + self._decim_config.write(open(self.config_filename, 'w')) self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(self.config_filename) if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'): @@ -274,30 +280,24 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_clock_alpha_config.add_section('usrp_rx_hrpt') self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._saved_clock_alpha_config.write(open(self.config_filename, 'w')) - self._decim_config = ConfigParser.ConfigParser() - self._decim_config.read(self.config_filename) - if not self._decim_config.has_section('usrp_rx_hrpt'): - self._decim_config.add_section('usrp_rx_hrpt') - self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) - self._decim_config.write(open(self.config_filename, 'w')) - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) + self._output_filename_config = ConfigParser.ConfigParser() + self._output_filename_config.read(self.config_filename) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) + self._output_filename_config.write(open(self.config_filename, 'w')) def set_decim(self, decim): self.decim = decim self.set_sample_rate(64e6/self.decim) self.set_decim_text(self.decim) + self.usrp_source.set_decim_rate(self.decim) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) if not self._decim_config.has_section('usrp_rx_hrpt'): self._decim_config.add_section('usrp_rx_hrpt') self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) - self.usrp_source.set_decim_rate(self.decim) def set_sym_rate(self, sym_rate): self.sym_rate = sym_rate @@ -349,14 +349,14 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.pll_alpha = pll_alpha self._pll_alpha_slider.set_value(self.pll_alpha) self._pll_alpha_text_box.set_value(self.pll_alpha) + self.pll.set_alpha(self.pll_alpha) + self.pll.set_beta(self.pll_alpha**2/4.0) self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(self.config_filename) if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'): self._saved_pll_alpha_config.add_section('usrp_rx_hrpt') self._saved_pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) self._saved_pll_alpha_config.write(open(self.config_filename, 'w')) - self.pll.set_alpha(self.pll_alpha) - self.pll.set_beta(self.pll_alpha**2/4.0) def set_output_filename(self, output_filename): self.output_filename = output_filename @@ -410,14 +410,14 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.clock_alpha = clock_alpha self._clock_alpha_slider.set_value(self.clock_alpha) self._clock_alpha_text_box.set_value(self.clock_alpha) + self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) + self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(self.config_filename) if not self._saved_clock_alpha_config.has_section('usrp_rx_hrpt'): self._saved_clock_alpha_config.add_section('usrp_rx_hrpt') self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._saved_clock_alpha_config.write(open(self.config_filename, 'w')) - self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) - self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc index 02d509f08..22bd3bdc3 100644 --- a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Nov 2 08:31:35 2009</timestamp> + <timestamp>Mon Nov 9 08:03:25 2009</timestamp> <block> <key>options</key> <param> @@ -175,29 +175,6 @@ <key>variable</key> <param> <key>id</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(705, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> <value>config_filename</value> </param> <param> @@ -244,49 +221,6 @@ <key>variable_config</key> <param> <key>id</key> - <value>clock_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'clock_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>clock_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(986, 101)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> <value>gain</value> </param> <param> @@ -373,135 +307,6 @@ <key>variable_config</key> <param> <key>id</key> - <value>decim</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>16</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'decim'</value> - </param> - <param> - <key>writeback</key> - <value>decim</value> - </param> - <param> - <key>_coordinate</key> - <value>(355, 97)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>output_filename</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>'frames.dat'</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'filename'</value> - </param> - <param> - <key>writeback</key> - <value>output_filename</value> - </param> - <param> - <key>_coordinate</key> - <value>(1143, 101)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>pll_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'pll_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>pll_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(827, 100)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> <value>side</value> </param> <param> @@ -826,10 +631,10 @@ </param> </block> <block> - <key>noaa_hrpt_decoder</key> + <key>gr_binary_slicer_fb</key> <param> <key>id</key> - <value>decoder</value> + <value>gr_binary_slicer_fb_0</value> </param> <param> <key>_enabled</key> @@ -837,7 +642,7 @@ </param> <param> <key>_coordinate</key> - <value>(1027, 623)</value> + <value>(446, 673)</value> </param> <param> <key>_rotation</key> @@ -845,10 +650,10 @@ </param> </block> <block> - <key>gr_binary_slicer_fb</key> + <key>noaa_hrpt_deframer</key> <param> <key>id</key> - <value>gr_binary_slicer_fb_0</value> + <value>deframer</value> </param> <param> <key>_enabled</key> @@ -856,7 +661,7 @@ </param> <param> <key>_coordinate</key> - <value>(446, 673)</value> + <value>(815, 673)</value> </param> <param> <key>_rotation</key> @@ -864,18 +669,221 @@ </param> </block> <block> - <key>noaa_hrpt_deframer</key> + <key>variable_config</key> <param> <key>id</key> - <value>deframer</value> + <value>decim</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'decim'</value> + </param> + <param> + <key>writeback</key> + <value>decim</value> + </param> + <param> <key>_coordinate</key> - <value>(815, 673)</value> + <value>(355, 97)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>pll_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'pll_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>pll_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(827, 100)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>clock_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'clock_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>clock_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(986, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>output_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>'frames.hrpt'</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'filename'</value> + </param> + <param> + <key>writeback</key> + <value>output_filename</value> + </param> + <param> + <key>_coordinate</key> + <value>(1143, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100e-6</value> + </param> + <param> + <key>_coordinate</key> + <value>(705, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> + <param> + <key>id</key> + <value>decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(1027, 623)</value> </param> <param> <key>_rotation</key> diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.py b/gr-noaa/apps/usrp_rx_hrpt_nogui.py index 4dc32dbda..1b510bdb2 100755 --- a/gr-noaa/apps/usrp_rx_hrpt_nogui.py +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: Usrp Rx Hrpt Nogui -# Generated: Mon Nov 2 08:31:35 2009 +# Generated: Mon Nov 9 08:03:25 2009 ################################################## from gnuradio import eng_notation @@ -27,7 +27,7 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') - except: decim = 16 + except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim @@ -40,14 +40,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(config_filename) try: pll_alpha = self._pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') - except: pll_alpha = 0.05 + except: pll_alpha = 0.01 self.pll_alpha = pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') - except: output_filename = 'frames.dat' + except: output_filename = 'frames.hrpt' self.output_filename = output_filename - self.max_clock_offset = max_clock_offset = 0.1 + self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self._gain_config = ConfigParser.ConfigParser() @@ -63,14 +63,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._clock_alpha_config = ConfigParser.ConfigParser() self._clock_alpha_config.read(config_filename) try: clock_alpha = self._clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') - except: clock_alpha = 0.05 + except: clock_alpha = 0.01 self.clock_alpha = clock_alpha ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) - self.decoder = noaa.hrpt_decoder() + self.decoder = noaa.hrpt_decoder(True,True) self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() @@ -96,12 +96,6 @@ class usrp_rx_hrpt_nogui(gr.top_block): def set_config_filename(self, config_filename): self.config_filename = config_filename - self._clock_alpha_config = ConfigParser.ConfigParser() - self._clock_alpha_config.read(self.config_filename) - if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): - self._clock_alpha_config.add_section('usrp_rx_hrpt') - self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) - self._clock_alpha_config.write(open(self.config_filename, 'w')) self._gain_config = ConfigParser.ConfigParser() self._gain_config.read(self.config_filename) if not self._gain_config.has_section('usrp_rx_hrpt'): @@ -114,41 +108,47 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._freq_config.add_section('usrp_rx_hrpt') self._freq_config.set('usrp_rx_hrpt', 'freq', str(self.freq)) self._freq_config.write(open(self.config_filename, 'w')) + self._side_config = ConfigParser.ConfigParser() + self._side_config.read(self.config_filename) + if not self._side_config.has_section('usrp_rx_hrpt'): + self._side_config.add_section('usrp_rx_hrpt') + self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) + self._side_config.write(open(self.config_filename, 'w')) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) if not self._decim_config.has_section('usrp_rx_hrpt'): self._decim_config.add_section('usrp_rx_hrpt') self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) - self._output_filename_config = ConfigParser.ConfigParser() - self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('usrp_rx_hrpt'): - self._output_filename_config.add_section('usrp_rx_hrpt') - self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) - self._output_filename_config.write(open(self.config_filename, 'w')) self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(self.config_filename) if not self._pll_alpha_config.has_section('usrp_rx_hrpt'): self._pll_alpha_config.add_section('usrp_rx_hrpt') self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) self._pll_alpha_config.write(open(self.config_filename, 'w')) - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) + self._clock_alpha_config = ConfigParser.ConfigParser() + self._clock_alpha_config.read(self.config_filename) + if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): + self._clock_alpha_config.add_section('usrp_rx_hrpt') + self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) + self._clock_alpha_config.write(open(self.config_filename, 'w')) + self._output_filename_config = ConfigParser.ConfigParser() + self._output_filename_config.read(self.config_filename) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) + self._output_filename_config.write(open(self.config_filename, 'w')) def set_decim(self, decim): self.decim = decim self.set_sample_rate(64e6/self.decim) + self.usrp_source.set_decim_rate(self.decim) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) if not self._decim_config.has_section('usrp_rx_hrpt'): self._decim_config.add_section('usrp_rx_hrpt') self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) - self.usrp_source.set_decim_rate(self.decim) def set_sym_rate(self, sym_rate): self.sym_rate = sym_rate @@ -175,14 +175,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): def set_pll_alpha(self, pll_alpha): self.pll_alpha = pll_alpha + self.pll.set_alpha(self.pll_alpha) + self.pll.set_beta(self.pll_alpha**2/4.0) self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(self.config_filename) if not self._pll_alpha_config.has_section('usrp_rx_hrpt'): self._pll_alpha_config.add_section('usrp_rx_hrpt') self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) self._pll_alpha_config.write(open(self.config_filename, 'w')) - self.pll.set_alpha(self.pll_alpha) - self.pll.set_beta(self.pll_alpha**2/4.0) def set_output_filename(self, output_filename): self.output_filename = output_filename @@ -226,14 +226,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): def set_clock_alpha(self, clock_alpha): self.clock_alpha = clock_alpha + self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) + self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) self._clock_alpha_config = ConfigParser.ConfigParser() self._clock_alpha_config.read(self.config_filename) if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): self._clock_alpha_config.add_section('usrp_rx_hrpt') self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._clock_alpha_config.write(open(self.config_filename, 'w')) - self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) - self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") diff --git a/gr-noaa/grc/noaa_hrpt_decoder.xml b/gr-noaa/grc/noaa_hrpt_decoder.xml index 183d72aba..2d6e98c53 100644 --- a/gr-noaa/grc/noaa_hrpt_decoder.xml +++ b/gr-noaa/grc/noaa_hrpt_decoder.xml @@ -4,7 +4,20 @@ <key>noaa_hrpt_decoder</key> <category>NOAA</category> <import>from gnuradio import noaa</import> - <make>noaa.hrpt_decoder()</make> + <make>noaa.hrpt_decoder($verbose,$output)</make> + + <param> + <name>Verbose</name> + <key>verbose</key> + <type>bool</type> + </param> + + <param> + <name>Output Files</name> + <key>output</key> + <type>bool</type> + </param> + <sink> <name>in</name> <type>short</type> diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 4ef4eb87b..f01bbfab8 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -33,6 +33,9 @@ libgnuradio_noaa_la_SOURCES = \ noaa_hrpt_deframer.cc \ noaa_hrpt_pll_cf.cc +noinst_HEADERS = \ + noaa_hrpt.h + libgnuradio_noaa_la_LIBADD = \ $(GNURADIO_CORE_LA) diff --git a/gr-noaa/lib/noaa_hrpt.h b/gr-noaa/lib/noaa_hrpt.h new file mode 100644 index 000000000..3812e9368 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt.h @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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_NOAA_HRPT_H +#define INCLUDED_NOAA_HRPT_H + +#define HRPT_SYNC1 0x0284 +#define HRPT_SYNC2 0x016F +#define HRPT_SYNC3 0x035C +#define HRPT_SYNC4 0x019D +#define HRPT_SYNC5 0x020F +#define HRPT_SYNC6 0x0095 + +#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL + +#define HRPT_SYNC_WORDS 6 +#define HRPT_MINOR_FRAME_WORDS 11090 +#define HRPT_BITS_PER_WORD 10 + +#endif /* INCLUDED_NOAA_HRPT_H */ diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc index 8cfaa913c..243310089 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.cc +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -25,27 +25,52 @@ #endif #include <noaa_hrpt_decoder.h> +#include <noaa_hrpt.h> #include <gr_io_signature.h> +#include <cstdio> -#define SYNC1 0x0284 -#define SYNC2 0x016F -#define SYNC3 0x035C -#define SYNC4 0x019D -#define SYNC5 0x020F -#define SYNC6 0x0095 +static const char *hrpt_ids[] = { + "000000", + "NOAA11", + "000002", + "NOAA16", + "000004", + "000005", + "000006", + "NOAA15", + "000008", + "NOAA12", + "000010", + "NOAA17", + "000012", + "NOAA18", + "000014", + "NOAA19" +}; noaa_hrpt_decoder_sptr -noaa_make_hrpt_decoder() +noaa_make_hrpt_decoder(bool verbose, bool output_files) { - return gnuradio::get_initial_sptr(new noaa_hrpt_decoder()); + return gnuradio::get_initial_sptr(new noaa_hrpt_decoder(verbose, output_files)); } -noaa_hrpt_decoder::noaa_hrpt_decoder() +noaa_hrpt_decoder::noaa_hrpt_decoder(bool verbose, bool output_files) : gr_sync_block("noaa_hrpt_decoder", gr_make_io_signature(1, 1, sizeof(short)), - gr_make_io_signature(0, 0, 0)) + gr_make_io_signature(0, 0, 0)), + d_verbose(verbose), + d_output_files(output_files), + d_word_num(0), + d_frames_seen(0), + d_current_mfnum(0), + d_expected_mfnum(0), + d_seq_errs(0), + d_address(0), + d_day_of_year(0), + d_milliseconds(0), + d_last_time(0) { - d_word_count = 0; + // Start of capture processing here } int @@ -57,21 +82,119 @@ noaa_hrpt_decoder::work(int noutput_items, int i = 0; while (i < noutput_items) { - unsigned short word = in[i++]; - d_word_count++; - //fprintf(stderr, "%5u: ", d_word_count); - for (int pos = 0; pos < 10; pos++) { - char ch = (word & (1 << 9)) ? '1' : '0'; - word = word << 1; - //fprintf(stderr, "%c ", ch); + d_current_word = in[i++] & 0x3FF; + d_word_num++; + + // Per HRPT word processing here + + switch (d_word_num) { + case 7: + process_mfnum(); + process_address(); + break; + + case 9: + process_day_of_year(); + break; + + case 10: + process_milli1(); + break; + + case 11: + process_milli2(); + break; + + case 12: + process_milli3(); + break; + + default: + break; } - //fprintf(stderr, "\n"); - if (d_word_count == 11090) { - d_word_count = 0; - //fprintf(stderr, "\n"); + if (d_word_num == HRPT_MINOR_FRAME_WORDS) { + + // End of minor frame processing here + d_frames_seen++; + d_word_num = 0; + fprintf(stderr, "\n"); } } return i; } + +void +noaa_hrpt_decoder::process_mfnum() +{ + d_current_mfnum = (d_current_word & 0x180) >> 7; + + if (d_verbose) + fprintf(stderr, "MF:"); + + if (d_current_mfnum != d_expected_mfnum && d_frames_seen > 0) { + d_seq_errs++; + + if (d_verbose) + fprintf(stderr, "*"); + } + else + if (d_verbose) + fprintf(stderr, " "); + + if (d_verbose) + fprintf(stderr, "%i ", d_current_mfnum); + d_expected_mfnum = (d_current_mfnum == 3) ? 1 : d_current_mfnum+1; +} + +void +noaa_hrpt_decoder::process_address() +{ + d_address = ((d_current_word & 0x078) >> 3) & 0x000F; + + if (d_verbose) + fprintf(stderr, "SA: %s ", hrpt_ids[d_address]); +} + +void +noaa_hrpt_decoder::process_day_of_year() +{ + d_day_of_year = d_current_word >> 1; + + if (d_verbose) + fprintf(stderr, "DOY: %3i ", d_day_of_year); +} + +void +noaa_hrpt_decoder::process_milli1() +{ + d_milliseconds = (d_current_word & 0x7F) << 20; +} + +void +noaa_hrpt_decoder::process_milli2() +{ + d_milliseconds |= (d_current_word << 10); +} + +void +noaa_hrpt_decoder::process_milli3() +{ + d_milliseconds |= d_current_word; + int delta = d_milliseconds - d_last_time; + d_last_time = d_milliseconds; + + if (d_verbose) + fprintf(stderr, "MS: %8i DT: %8i", d_milliseconds, delta); +} + +noaa_hrpt_decoder::~noaa_hrpt_decoder() +{ + // End of capture processing here + + if (d_verbose) { + fprintf(stderr, "Frames seen: %10i\n", d_frames_seen); + fprintf(stderr, "Sequence errors: %10i\n", d_seq_errs); + } +} diff --git a/gr-noaa/lib/noaa_hrpt_decoder.h b/gr-noaa/lib/noaa_hrpt_decoder.h index 305243b09..9d67d7108 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.h +++ b/gr-noaa/lib/noaa_hrpt_decoder.h @@ -29,16 +29,45 @@ class noaa_hrpt_decoder; typedef boost::shared_ptr<noaa_hrpt_decoder> noaa_hrpt_decoder_sptr; noaa_hrpt_decoder_sptr -noaa_make_hrpt_decoder(); +noaa_make_hrpt_decoder(bool verbose, bool output_files); class noaa_hrpt_decoder : public gr_sync_block { - friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(); - noaa_hrpt_decoder(); + friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(bool verbose, bool output_files); + noaa_hrpt_decoder(bool verbose, bool output_files); + + // Configuration + bool d_verbose; + bool d_output_files; + + // Frame-level state + unsigned short d_current_word; + unsigned int d_word_num; + int d_frames_seen; + + // Minor frame number + int d_current_mfnum; + int d_expected_mfnum; + int d_seq_errs; + + // Spacecraft address + int d_address; + + // Minor frame timestamp + int d_day_of_year; + int d_milliseconds; + int d_last_time; + + void process_mfnum(); + void process_address(); + void process_day_of_year(); + void process_milli1(); + void process_milli2(); + void process_milli3(); - unsigned int d_word_count; - public: + ~noaa_hrpt_decoder(); + int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc index e79894869..1a2af6c37 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -26,23 +26,13 @@ #include <noaa_hrpt_deframer.h> #include <gr_io_signature.h> +#include <noaa_hrpt.h> #include <cstring> #include <cstdio> #define ST_IDLE 0 #define ST_SYNCED 1 -#define SYNC1 0x0284 -#define SYNC2 0x016F -#define SYNC3 0x035C -#define SYNC4 0x019D -#define SYNC5 0x020F -#define SYNC6 0x0095 - -#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL - -static int frames_seen = 0; - noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer() { @@ -98,13 +88,12 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_shifter = (d_shifter << 1) | bit; // MSB transmitted first if ((d_shifter & 0x0FFFFFFFFFFFFFFFLL) == HRPT_MINOR_FRAME_SYNC) { - fprintf(stderr, "SYNC #%i", frames_seen++); - out[j++] = SYNC1; - out[j++] = SYNC2; - out[j++] = SYNC3; - out[j++] = SYNC4; - out[j++] = SYNC5; - out[j++] = SYNC6; + out[j++] = HRPT_SYNC1; + out[j++] = HRPT_SYNC2; + out[j++] = HRPT_SYNC3; + out[j++] = HRPT_SYNC4; + out[j++] = HRPT_SYNC5; + out[j++] = HRPT_SYNC6; enter_synced(); } break; @@ -116,7 +105,6 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_word = 0; d_bit_count = HRPT_BITS_PER_WORD; if (--d_word_count == 0) { - fprintf(stderr, "...done\n"); enter_idle(); } } diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h index 43abba0e9..b11d0fa2b 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.h +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -23,10 +23,6 @@ #ifndef INCLUDED_NOAA_HRPT_DEFRAMER_H #define INCLUDED_NOAA_HRPT_DEFRAMER_H -#define HRPT_SYNC_WORDS 6 -#define HRPT_MINOR_FRAME_WORDS 11090 -#define HRPT_BITS_PER_WORD 10 - #include <gr_block.h> class noaa_hrpt_deframer; diff --git a/gr-noaa/oct/frames_to_ppm.m b/gr-noaa/oct/frames_to_ppm.m index aeb22faac..73842f0a9 100644 --- a/gr-noaa/oct/frames_to_ppm.m +++ b/gr-noaa/oct/frames_to_ppm.m @@ -23,7 +23,7 @@ % Extract AVHRR images from HRPT frames.dat clear -fid = fopen('frames.dat'); +fid = fopen('frames.hrpt'); dat = fread(fid, 'uint16'); frame_len = 11090; diff --git a/gr-noaa/swig/noaa_hrpt_decoder.i b/gr-noaa/swig/noaa_hrpt_decoder.i index ddf181c28..220a5714d 100644 --- a/gr-noaa/swig/noaa_hrpt_decoder.i +++ b/gr-noaa/swig/noaa_hrpt_decoder.i @@ -23,7 +23,7 @@ GR_SWIG_BLOCK_MAGIC(noaa,hrpt_decoder) noaa_hrpt_decoder_sptr -noaa_make_hrpt_decoder(); +noaa_make_hrpt_decoder(bool verbose, bool output_files); class noaa_hrpt_decoder : public gr_sync_block { diff --git a/gr-pager/apps/Makefile.am b/gr-pager/apps/Makefile.am index 0e9f1215b..7b495fd2b 100644 --- a/gr-pager/apps/Makefile.am +++ b/gr-pager/apps/Makefile.am @@ -26,10 +26,11 @@ if PYTHON dist_bin_SCRIPTS = \ usrp_flex.py \ usrp_flex_all.py \ - usrp_flex_band.py \ + usrp_flex_band.py + +noinst_PYTHON = \ usrp_rx_flex.py endif EXTRA_DIST = \ usrp_rx_flex.grc - diff --git a/gr-pager/lib/Makefile.am b/gr-pager/lib/Makefile.am index 42053eb17..1d8a43b3c 100644 --- a/gr-pager/lib/Makefile.am +++ b/gr-pager/lib/Makefile.am @@ -21,8 +21,6 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = run_tests.in - AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) # These headers get installed in ${prefix}/include/gnuradio diff --git a/grc/base/Block.py b/grc/base/Block.py index b2015cc40..42eb6b3fb 100644 --- a/grc/base/Block.py +++ b/grc/base/Block.py @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from . import odict from Element import Element -from Param import Param -from Port import Port from Cheetah.Template import Template from UserDict import UserDict diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py index 7c51ef42a..b4ac8fc3a 100644 --- a/grc/base/FlowGraph.py +++ b/grc/base/FlowGraph.py @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from . import odict from Element import Element -from Block import Block -from Connection import Connection from .. gui import Messages class FlowGraph(Element): diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am index e436cc764..9c91af543 100644 --- a/grc/blocks/Makefile.am +++ b/grc/blocks/Makefile.am @@ -34,6 +34,8 @@ dist_ourdata_DATA = \ blks2_cvsd_decode.xml \ blks2_dxpsk_demod.xml \ blks2_dxpsk_mod.xml \ + blks2_dxpsk2_demod.xml \ + blks2_dxpsk2_mod.xml \ blks2_error_rate.xml \ blks2_fm_deemph.xml \ blks2_fm_demod_cf.xml \ diff --git a/grc/blocks/blks2_dxpsk2_demod.xml b/grc/blocks/blks2_dxpsk2_demod.xml new file mode 100644 index 000000000..ce8305c50 --- /dev/null +++ b/grc/blocks/blks2_dxpsk2_demod.xml @@ -0,0 +1,145 @@ +<?xml version="1.0"?> +<!-- +################################################### +##DPSK2 Demod - 2, 4 +################################################### + --> +<block> + <name>DPSK2 Demod</name> + <key>blks2_dxpsk2_demod</key> + <import>from gnuradio import blks2</import> + <make>blks2.$(type)2_demod( + samples_per_symbol=$samples_per_symbol, + excess_bw=$excess_bw, + costas_alpha=$costas_alpha, + timing_alpha=$timing_alpha, + timing_max_dev=$timing_max_dev, + gray_code=$gray_code, + verbose=$verbose, + log=$log, + sync_out=$sync_out, +)</make> + <callback>clock_recov.set_alpha($costas_alpha)</callback> + <callback>clock_recov.set_beta(0.25*$costas_alpha**2)</callback> + <callback>time_recov.set_alpha($timing_alpha)</callback> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>DBPSK</name> + <key>dbpsk</key> + </option> + <option> + <name>DQPSK</name> + <key>dqpsk</key> + </option> + </param> + <param> + <name>Samples/Symbol</name> + <key>samples_per_symbol</key> + <value>2</value> + <type>int</type> + </param> + <param> + <name>Excess BW</name> + <key>excess_bw</key> + <value>0.35</value> + <type>real</type> + </param> + <param> + <name>Costas Alpha</name> + <key>costas_alpha</key> + <value>0.175</value> + <type>real</type> + </param> + <param> + <name>Timing Alpha</name> + <key>timing_alpha</key> + <value>0.100</value> + <type>real</type> + </param> + <param> + <name>Timing Max Dev</name> + <key>timing_max_dev</key> + <value>1.5</value> + <type>real</type> + </param> + <param> + <name>Omega Relative Limit</name> + <key>omega_relative_limit</key> + <value>0.005</value> + <type>real</type> + </param> + <param> + <name>Gray Code</name> + <key>gray_code</key> + <value>True</value> + <type>bool</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <param> + <name>Verbose</name> + <key>verbose</key> + <value>False</value> + <type>bool</type> + <hide>#if str($verbose) == 'False' then 'part' else 'none'#</hide> + <option> + <name>On</name> + <key>True</key> + </option> + <option> + <name>Off</name> + <key>False</key> + </option> + </param> + <param> + <name>Logging</name> + <key>log</key> + <value>False</value> + <type>bool</type> + <hide>#if str($log) == 'False' then 'part' else 'none'#</hide> + <option> + <name>On</name> + <key>True</key> + </option> + <option> + <name>Off</name> + <key>False</key> + </option> + </param> + <param> + <name>Sync Out</name> + <key>sync_out</key> + <value>False</value> + <type>bool</type> + <option> + <name>On</name> + <key>True</key> + </option> + <option> + <name>Off</name> + <key>False</key> + </option> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> + <source> + <name>sync</name> + <type>complex</type> + <optional>1</optional> + </source> +</block> diff --git a/grc/blocks/blks2_dxpsk2_mod.xml b/grc/blocks/blks2_dxpsk2_mod.xml new file mode 100644 index 000000000..bf292be17 --- /dev/null +++ b/grc/blocks/blks2_dxpsk2_mod.xml @@ -0,0 +1,95 @@ +<?xml version="1.0"?> +<!-- +################################################### +##DPSK2 Mod - 2, 4 +################################################### + --> +<block> + <name>DPSK2 Mod</name> + <key>blks2_dxpsk2_mod</key> + <import>from gnuradio import blks2</import> + <make>blks2.$(type)2_mod( + samples_per_symbol=$samples_per_symbol, + excess_bw=$excess_bw, + gray_code=$gray_code, + verbose=$verbose, + log=$log, +)</make> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>DBPSK</name> + <key>dbpsk</key> + </option> + <option> + <name>DQPSK</name> + <key>dqpsk</key> + </option> + </param> + <param> + <name>Samples/Symbol</name> + <key>samples_per_symbol</key> + <value>2</value> + <type>int</type> + </param> + <param> + <name>Excess BW</name> + <key>excess_bw</key> + <value>0.35</value> + <type>real</type> + </param> + <param> + <name>Gray Code</name> + <key>gray_code</key> + <value>True</value> + <type>bool</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <param> + <name>Verbose</name> + <key>verbose</key> + <value>False</value> + <type>bool</type> + <hide>#if str($verbose) == 'False' then 'part' else 'none'#</hide> + <option> + <name>On</name> + <key>True</key> + </option> + <option> + <name>Off</name> + <key>False</key> + </option> + </param> + <param> + <name>Logging</name> + <key>log</key> + <value>False</value> + <type>bool</type> + <hide>#if str($log) == 'False' then 'part' else 'none'#</hide> + <option> + <name>On</name> + <key>True</key> + </option> + <option> + <name>Off</name> + <key>False</key> + </option> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/grc/blocks/blks2_dxpsk_demod.xml b/grc/blocks/blks2_dxpsk_demod.xml index 4c13b3415..1c96b6cec 100644 --- a/grc/blocks/blks2_dxpsk_demod.xml +++ b/grc/blocks/blks2_dxpsk_demod.xml @@ -76,7 +76,7 @@ <name>Gray Code</name> <key>gray_code</key> <value>True</value> - <type>enum</type> + <type>bool</type> <option> <name>Yes</name> <key>True</key> diff --git a/grc/blocks/blks2_dxpsk_mod.xml b/grc/blocks/blks2_dxpsk_mod.xml index 28fd742fa..77505d8ad 100644 --- a/grc/blocks/blks2_dxpsk_mod.xml +++ b/grc/blocks/blks2_dxpsk_mod.xml @@ -48,7 +48,7 @@ <name>Gray Code</name> <key>gray_code</key> <value>True</value> - <type>enum</type> + <type>bool</type> <option> <name>Yes</name> <key>True</key> diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index fc074cb69..57703f6d6 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -225,6 +225,9 @@ <block>blks2_dxpsk_mod</block> <block>blks2_dxpsk_demod</block> + <block>blks2_dxpsk2_mod</block> + <block>blks2_dxpsk2_demod</block> + <block>blks2_gmsk_mod</block> <block>blks2_gmsk_demod</block> diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml index 734526793..2e9495260 100644 --- a/grc/blocks/pad_sink.xml +++ b/grc/blocks/pad_sink.xml @@ -9,10 +9,10 @@ <key>pad_sink</key> <make></make> <param> - <name>Num Inputs</name> - <key>nports</key> - <value>1</value> - <type>int</type> + <name>Label</name> + <key>label</key> + <value>out</value> + <type>string</type> </param> <param> <name>Input Type</name> @@ -51,15 +51,14 @@ <type>int</type> </param> <check>$vlen > 0</check> - <check>0 < $nports</check> <sink> <name>in</name> <type>$type</type> <vlen>$vlen</vlen> - <nports>$nports</nports> </sink> <doc> -The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. \ -Limit one sink pad block per flow graph. +The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. + +Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0. </doc> </block> diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml index f44d96238..7b2210cbb 100644 --- a/grc/blocks/pad_source.xml +++ b/grc/blocks/pad_source.xml @@ -9,10 +9,10 @@ <key>pad_source</key> <make></make> <param> - <name>Num Outputs</name> - <key>nports</key> - <value>1</value> - <type>int</type> + <name>Label</name> + <key>label</key> + <value>in</value> + <type>string</type> </param> <param> <name>Output Type</name> @@ -51,16 +51,14 @@ <type>int</type> </param> <check>$vlen > 0</check> - <check>0 < $nports</check> <source> <name>out</name> <type>$type</type> <vlen>$vlen</vlen> - <nports>$nports</nports> </source> <doc> -The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. \ -Limit one source pad block per flow graph. \ -The "pad sink id" will be ignored in this mode. +The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. + +Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0. </doc> </block> diff --git a/grc/freedesktop/grc_setup_freedesktop.in b/grc/freedesktop/grc_setup_freedesktop.in index 33fc4e1ac..db6506452 100644 --- a/grc/freedesktop/grc_setup_freedesktop.in +++ b/grc/freedesktop/grc_setup_freedesktop.in @@ -20,11 +20,12 @@ case "$1" in echo "Begin freedesktop install..." for size in ${ICON_SIZES}; do \ echo "Install icon: ${size}x${size}" - xdg-icon-resource install --context mimetypes --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \ - xdg-icon-resource install --context mimetypes --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \ - xdg-icon-resource install --context apps --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \ - xdg-icon-resource install --context apps --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \ + xdg-icon-resource install --noupdate --context mimetypes --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \ + xdg-icon-resource install --noupdate --context mimetypes --size ${size} ${SRCDIR}/grc-icon-${size}.png application-gnuradio-grc; \ + xdg-icon-resource install --noupdate --context apps --theme gnome --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \ + xdg-icon-resource install --noupdate --context apps --size ${size} ${SRCDIR}/grc-icon-${size}.png gnuradio-grc; \ done + xdg-icon-resource forceupdate echo "Install mime type" xdg-mime install ${SRCDIR}/gnuradio-grc.xml echo "Install menu items" diff --git a/grc/grc_gnuradio/usrp/dual_usrp.py b/grc/grc_gnuradio/usrp/dual_usrp.py index 3692e1760..b26dbddd4 100644 --- a/grc/grc_gnuradio/usrp/dual_usrp.py +++ b/grc/grc_gnuradio/usrp/dual_usrp.py @@ -19,7 +19,7 @@ # import common -from gnuradio import gr, usrp +from gnuradio import gr #################################################################### # Dual USRP Source diff --git a/grc/grc_gnuradio/usrp/simple_usrp.py b/grc/grc_gnuradio/usrp/simple_usrp.py index fc4c75bf0..fb7a39570 100644 --- a/grc/grc_gnuradio/usrp/simple_usrp.py +++ b/grc/grc_gnuradio/usrp/simple_usrp.py @@ -19,7 +19,7 @@ # import common -from gnuradio import gr, usrp +from gnuradio import gr #################################################################### # Simple USRP Source diff --git a/grc/grc_gnuradio/wxgui/top_block_gui.py b/grc/grc_gnuradio/wxgui/top_block_gui.py index 998575897..333ccf1c1 100644 --- a/grc/grc_gnuradio/wxgui/top_block_gui.py +++ b/grc/grc_gnuradio/wxgui/top_block_gui.py @@ -19,7 +19,6 @@ # import wx -import sys, os from gnuradio import gr import panel diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index ee3e19a6c..108e23a23 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -29,7 +29,6 @@ import Preferences from threading import Thread import Messages from .. base import ParseXML -import random from MainWindow import MainWindow from PropsDialog import PropsDialog import Dialogs diff --git a/grc/gui/Block.py b/grc/gui/Block.py index 8c65bf06f..27143e070 100644 --- a/grc/gui/Block.py +++ b/grc/gui/Block.py @@ -29,6 +29,7 @@ from Constants import \ import pygtk pygtk.require('2.0') import gtk +import pango BLOCK_MARKUP_TMPL="""\ #set $foreground = $block.is_valid() and 'black' or 'red' @@ -130,8 +131,11 @@ class Block(Element): layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self)) self.label_width, self.label_height = layout.get_pixel_size() #display the params - for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()): - layout = param.get_layout() + markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')] + if markups: + layout = gtk.DrawingArea().create_pango_layout('') + layout.set_spacing(LABEL_SEPARATION*pango.SCALE) + layout.set_markup('\n'.join(markups)) layouts.append(layout) w,h = layout.get_pixel_size() self.label_width = max(w, self.label_width) @@ -151,12 +155,11 @@ class Block(Element): else: w_off = 0 pixmap.draw_layout(gc, w_off, h_off, layout) h_off = h + h_off + LABEL_SEPARATION - #create vertical and horizontal images - self.horizontal_label = image = pixmap.get_image(0, 0, width, height) + #create vertical and horizontal pixmaps + self.horizontal_label = pixmap if self.is_vertical(): - self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), height, width) - for i in range(width): - for j in range(height): vimage.put_pixel(j, width-i-1, image.get_pixel(i, j)) + self.vertical_label = self.get_parent().new_pixmap(height, width) + Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label) #calculate width and height needed self.W = self.label_width + 2*BLOCK_LABEL_PADDING self.H = max(*( @@ -179,9 +182,9 @@ class Block(Element): ) #draw label image if self.is_horizontal(): - window.draw_image(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1) + window.draw_drawable(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1) elif self.is_vertical(): - window.draw_image(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1) + window.draw_drawable(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1) #draw ports for port in self.get_ports(): port.draw(gc, window) diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py index af40f47c0..473c796af 100644 --- a/grc/gui/Dialogs.py +++ b/grc/gui/Dialogs.py @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import pygtk pygtk.require('2.0') import gtk -import Preferences import Utils class TextDisplay(gtk.TextView): diff --git a/grc/gui/Element.py b/grc/gui/Element.py index f0518ee12..e020c5caa 100644 --- a/grc/gui/Element.py +++ b/grc/gui/Element.py @@ -17,9 +17,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ -import pygtk -pygtk.require('2.0') -import gtk from Constants import LINE_SELECT_SENSITIVITY from Constants import POSSIBLE_ROTATIONS diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py index 8feb171f1..5adecccc1 100644 --- a/grc/gui/FlowGraph.py +++ b/grc/gui/FlowGraph.py @@ -22,7 +22,6 @@ import Actions import Colors import Utils from Element import Element -from .. base import FlowGraph as _FlowGraph import pygtk pygtk.require('2.0') import gtk diff --git a/grc/gui/Param.py b/grc/gui/Param.py index 4464a57ab..b3018dab2 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -38,6 +38,7 @@ class InputParam(gtk.HBox): #connect events self.connect('show', self._update_gui) def set_color(self, color): pass + def set_tooltip_text(self, text): pass def _update_gui(self, *args): """ @@ -51,8 +52,7 @@ class InputParam(gtk.HBox): #set the color self.set_color(self.param.get_color()) #set the tooltip - if self.tp: self.tp.set_tip( - self.entry, + self.set_tooltip_text( Utils.parse_template(TIP_MARKUP_TMPL, param=self.param).strip(), ) #show/hide @@ -77,16 +77,13 @@ class EntryParam(InputParam): def __init__(self, *args, **kwargs): InputParam.__init__(self, *args, **kwargs) - self.entry = input = gtk.Entry() - input.set_text(self.param.get_value()) - input.connect('changed', self._handle_changed) - self.pack_start(input, True) - self.get_text = input.get_text - #tool tip - self.tp = gtk.Tooltips() - self.tp.set_tip(self.entry, '') - self.tp.enable() - def set_color(self, color): self.entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) + self._input = gtk.Entry() + self._input.set_text(self.param.get_value()) + self._input.connect('changed', self._handle_changed) + self.pack_start(self._input, True) + def get_text(self): return self._input.get_text() + def set_color(self, color): self._input.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) + def set_tooltip_text(self, text): self._input.set_tooltip_text(text) class EnumParam(InputParam): """Provide an entry box for Enum types with a drop down menu.""" @@ -99,6 +96,7 @@ class EnumParam(InputParam): self._input.connect('changed', self._handle_changed) self.pack_start(self._input, False) def get_text(self): return self.param.get_option_keys()[self._input.get_active()] + def set_tooltip_text(self, text): self._input.set_tooltip_text(text) class EnumEntryParam(InputParam): """Provide an entry box and drop down menu for Raw Enum types.""" @@ -117,6 +115,10 @@ class EnumEntryParam(InputParam): def get_text(self): if self._input.get_active() == -1: return self._input.get_child().get_text() return self.param.get_option_keys()[self._input.get_active()] + def set_tooltip_text(self, text): + if self._input.get_active() == -1: #custom entry + self._input.get_child().set_tooltip_text(text) + else: self._input.set_tooltip_text(text) def set_color(self, color): if self._input.get_active() == -1: #custom entry, use color self._input.get_child().modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) @@ -163,11 +165,9 @@ class Param(Element): if self.get_options(): return EnumEntryParam(self, *args, **kwargs) return EntryParam(self, *args, **kwargs) - def get_layout(self): + def get_markup(self): """ - Create a layout based on the current markup. - @return the pango layout + Get the markup for this param. + @return a pango markup string """ - layout = gtk.DrawingArea().create_pango_layout('') - layout.set_markup(Utils.parse_template(PARAM_MARKUP_TMPL, param=self)) - return layout + return Utils.parse_template(PARAM_MARKUP_TMPL, param=self) diff --git a/grc/gui/Port.py b/grc/gui/Port.py index 6763f6cbd..2896d04c1 100644 --- a/grc/gui/Port.py +++ b/grc/gui/Port.py @@ -97,12 +97,11 @@ class Port(Element): gc.set_foreground(self._bg_color) pixmap.draw_rectangle(gc, True, 0, 0, self.w, self.h) pixmap.draw_layout(gc, 0, 0, layout) - #create the images - self.horizontal_label = image = pixmap.get_image(0, 0, self.w, self.h) + #create vertical and horizontal pixmaps + self.horizontal_label = pixmap if self.is_vertical(): - self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), self.h, self.w) - for i in range(self.w): - for j in range(self.h): vimage.put_pixel(j, self.w-i-1, image.get_pixel(i, j)) + self.vertical_label = self.get_parent().get_parent().new_pixmap(self.h, self.w) + Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label) def draw(self, gc, window): """ @@ -117,9 +116,9 @@ class Port(Element): X,Y = self.get_coordinate() (x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place the labels if self.is_horizontal(): - window.draw_image(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1) + window.draw_drawable(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1) elif self.is_vertical(): - window.draw_image(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1) + window.draw_drawable(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1) def get_connector_coordinate(self): """ diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py index 83036a4b8..b5489d56e 100644 --- a/grc/gui/Utils.py +++ b/grc/gui/Utils.py @@ -19,8 +19,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA from Constants import POSSIBLE_ROTATIONS from Cheetah.Template import Template +import pygtk +pygtk.require('2.0') +import gtk import gobject +def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE): + """ + Load the destination pixmap with a rotated version of the source pixmap. + The source pixmap will be loaded into a pixbuf, rotated, and drawn to the destination pixmap. + The pixbuf is a client-side drawable, where a pixmap is a server-side drawable. + @param gc the graphics context + @param src_pixmap the source pixmap + @param dst_pixmap the destination pixmap + @param angle the angle to rotate by + """ + width, height = src_pixmap.get_size() + pixbuf = gtk.gdk.Pixbuf( + colorspace=gtk.gdk.COLORSPACE_RGB, + has_alpha=False, bits_per_sample=8, + width=width, height=height, + ) + pixbuf.get_from_drawable(src_pixmap, src_pixmap.get_colormap(), 0, 0, 0, 0, -1, -1) + pixbuf = pixbuf.rotate_simple(angle) + dst_pixmap.draw_pixbuf(gc, pixbuf, 0, 0, 0, 0) + def get_rotated_coordinate(coor, rotation): """ Rotate the coordinate by the given rotation. diff --git a/grc/python/Constants.py b/grc/python/Constants.py index 439a52420..e661c3927 100644 --- a/grc/python/Constants.py +++ b/grc/python/Constants.py @@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ import os -import sys import stat from gnuradio import gr diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py index 4dd18a81f..b2d406bbd 100644 --- a/grc/python/FlowGraph.py +++ b/grc/python/FlowGraph.py @@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import expr_utils from .. base.FlowGraph import FlowGraph as _FlowGraph from .. gui.FlowGraph import FlowGraph as _GUIFlowGraph -from Block import Block -from Connection import Connection import re _variable_matcher = re.compile('^(variable\w*)$') @@ -50,44 +48,36 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): #return from cache return self._eval_cache[my_hash] - def _get_io_signature(self, pad_key): + def _get_io_signaturev(self, pad_key): """ - Get an io signature for this flow graph. + Get a list of io signatures for this flow graph. The pad key determines the directionality of the io signature. @param pad_key a string of pad_source or pad_sink - @return a dict with: type, nports, vlen, size + @return a list of dicts with: type, label, vlen, size """ pads = filter(lambda b: b.get_key() == pad_key, self.get_enabled_blocks()) - if not pads: return { - 'nports': '0', - 'type': '', - 'vlen': '0', - 'size': '0', - } - pad = pads[0] #take only the first, user should not have more than 1 + sorted_pads = sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id())) #load io signature - return { - 'nports': str(pad.get_param('nports').get_evaluated()), + return [{ + 'label': str(pad.get_param('label').get_evaluated()), 'type': str(pad.get_param('type').get_evaluated()), 'vlen': str(pad.get_param('vlen').get_evaluated()), 'size': pad.get_param('type').get_opt('size'), - } + } for pad in sorted_pads] - def get_input_signature(self): + def get_input_signaturev(self): """ Get the io signature for the input side of this flow graph. - The io signature with be "0", "0" if no pad source is present. - @return a string tuple of type, num_ports, port_size + @return a list of io signature structures """ - return self._get_io_signature('pad_source') + return self._get_io_signaturev('pad_source') - def get_output_signature(self): + def get_output_signaturev(self): """ Get the io signature for the output side of this flow graph. - The io signature with be "0", "0" if no pad sink is present. - @return a string tuple of type, num_ports, port_size + @return a list of io signature structures """ - return self._get_io_signature('pad_sink') + return self._get_io_signaturev('pad_sink') def get_imports(self): """ diff --git a/grc/python/Param.py b/grc/python/Param.py index 81fb6ba7a..febb112ad 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ -import expr_utils from .. base.Param import Param as _Param from .. gui.Param import Param as _GUIParam from .. gui.Param import EntryParam diff --git a/grc/python/convert_hier.py b/grc/python/convert_hier.py index bdafbcbc1..befddccea 100644 --- a/grc/python/convert_hier.py +++ b/grc/python/convert_hier.py @@ -23,8 +23,8 @@ from .. base import odict def convert_hier(flow_graph, python_file): #extract info from the flow graph - input_sig = flow_graph.get_input_signature() - output_sig = flow_graph.get_output_signature() + input_sigs = flow_graph.get_input_signaturev() + output_sigs = flow_graph.get_output_signaturev() parameters = flow_graph.get_parameters() block_key = flow_graph.get_option('id') block_name = flow_graph.get_option('title') @@ -56,20 +56,18 @@ def convert_hier(flow_graph, python_file): params_n.append(param_n) block_n['param'] = params_n #sink data - if int(input_sig['nports']): + for input_sig in input_sigs: sink_n = odict() - sink_n['name'] = 'in' + sink_n['name'] = input_sig['label'] sink_n['type'] = input_sig['type'] sink_n['vlen'] = input_sig['vlen'] - sink_n['nports'] = input_sig['nports'] block_n['sink'] = sink_n #source data - if int(output_sig['nports']): + for output_sig in output_sigs: source_n = odict() - source_n['name'] = 'out' + source_n['name'] = output_sig['label'] source_n['type'] = output_sig['type'] source_n['vlen'] = output_sig['vlen'] - source_n['nports'] = output_sig['nports'] block_n['source'] = source_n #doc data block_n['doc'] = "%s\n%s\n%s"%(block_author, block_desc, python_file) diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl index ab764006c..a1a9308aa 100644 --- a/grc/python/flow_graph.tmpl +++ b/grc/python/flow_graph.tmpl @@ -65,15 +65,25 @@ class $(class_name)(gr.top_block): def __init__($param_str): gr.top_block.__init__(self, "$title") #elif $generate_options == 'hb' - #set $in_sig = $flow_graph.get_input_signature() - #set $out_sig = $flow_graph.get_output_signature() + #set $in_sigs = $flow_graph.get_input_signaturev() + #set $out_sigs = $flow_graph.get_output_signaturev() class $(class_name)(gr.hier_block2): +#def make_io_sig($io_sigs) + #set $size_strs = ['%s*%s'%(io_sig['size'], io_sig['vlen']) for io_sig in $io_sigs] + #if len($io_sigs) == 0 +gr.io_signature(0, 0, 0)#slurp + #elif len($io_sigs) == 1 +gr.io_signature(1, 1, $size_strs[0])#slurp + #else +gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])#slurp + #end if +#end def def __init__($param_str): gr.hier_block2.__init__( self, "$title", - gr.io_signature($in_sig.nports, $in_sig.nports, $in_sig.size*$in_sig.vlen), - gr.io_signature($out_sig.nports, $out_sig.nports, $out_sig.size*$out_sig.vlen), + $make_io_sig($in_sigs), + $make_io_sig($out_sigs), ) #end if ######################################################## diff --git a/usrp/firmware/include/usrp_ids.h b/usrp/firmware/include/usrp_ids.h index 4f9ac4f9d..dd5daed01 100644 --- a/usrp/firmware/include/usrp_ids.h +++ b/usrp/firmware/include/usrp_ids.h @@ -54,6 +54,7 @@ #define USB_PID_FSF_BDALE_7 0x0011 // Bdale Garbee <bdale@gag.com> #define USB_PID_FSF_BDALE_8 0x0012 // Bdale Garbee <bdale@gag.com> #define USB_PID_FSF_BDALE_9 0x0013 // Bdale Garbee <bdale@gag.com> +#define USB_PID_FSF_HPSDR_HERMES 0x0014 // HPSDR Hermes #define USB_PID_FSF_LBNL_UXO 0x0018 // http://recycle.lbl.gov/~ldoolitt/uxo/ diff --git a/usrp/host/lib/db_xcvr2450.cc b/usrp/host/lib/db_xcvr2450.cc index 72367286c..ce9d1f4e8 100644 --- a/usrp/host/lib/db_xcvr2450.cc +++ b/usrp/host/lib/db_xcvr2450.cc @@ -322,8 +322,8 @@ xcvr2450::set_reg_lpf() { d_reg_lpf = ( (d_rssi_hbw<<15) | - (d_txlpf_bw<<10) | - (d_rxlpf_bw<<9) | + (d_txlpf_bw<<9) | + (d_rxlpf_bw<<7) | (d_rxlpf_fine<<4) | 7); send_reg(d_reg_lpf); } diff --git a/usrp/host/lib/usrp_prims_libusb0.cc b/usrp/host/lib/usrp_prims_libusb0.cc index 4d1fd78c9..4fbfabea9 100644 --- a/usrp/host/lib/usrp_prims_libusb0.cc +++ b/usrp/host/lib/usrp_prims_libusb0.cc @@ -83,7 +83,7 @@ _usb_control_transfer (struct usb_dev_handle *udh, int request_type, ret = usb_control_msg (udh, request_type,request, value, index, (char*) data, length, (int) timeout); if (ret < 0) - fprintf (stderr, "usrp: usb_claim_interface failed: %s\n", usb_strerror()); + fprintf (stderr, "usrp: usb_control_msg failed: %s\n", usb_strerror()); return ret; } diff --git a/usrp2/firmware/apps/app_common_v2.c b/usrp2/firmware/apps/app_common_v2.c index 67cccd53b..2d131bda7 100644 --- a/usrp2/firmware/apps/app_common_v2.c +++ b/usrp2/firmware/apps/app_common_v2.c @@ -152,7 +152,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, memset(&tune_result, 0, sizeof(tune_result)); bool ok = true; - + if (p->valid & CFGV_GAIN){ ok &= db_set_gain(tx_dboard, p->gain); } @@ -161,7 +161,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, bool was_streaming = is_streaming(); if (was_streaming) stop_rx_cmd(); - + u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo); bool tune_ok = db_tune(tx_dboard, f, &tune_result); ok &= tune_ok; @@ -185,7 +185,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, hb1 = 1; interp = interp >> 1; } - + if (interp < MIN_CIC_INTERP || interp > MAX_CIC_INTERP) ok = false; else { @@ -215,7 +215,7 @@ config_tx_v2_cmd(const op_config_tx_v2_t *p, } static size_t -config_rx_v2_cmd(const op_config_rx_v2_t *p, +config_rx_v2_cmd(const op_config_rx_v2_t *p, void *reply_payload, size_t reply_payload_space) { op_config_rx_reply_v2_t *r = (op_config_rx_reply_v2_t *) reply_payload; @@ -226,7 +226,7 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p, memset(&tune_result, 0, sizeof(tune_result)); bool ok = true; - + if (p->valid & CFGV_GAIN){ ok &= db_set_gain(rx_dboard, p->gain); } @@ -235,7 +235,7 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p, bool was_streaming = is_streaming(); if (was_streaming) stop_rx_cmd(); - + u2_fxpt_freq_t f = u2_fxpt_freq_from_hilo(p->freq_hi, p->freq_lo); bool tune_ok = db_tune(rx_dboard, f, &tune_result); ok &= tune_ok; @@ -249,17 +249,17 @@ config_rx_v2_cmd(const op_config_rx_v2_t *p, int decim = p->decim; int hb1 = 0; int hb2 = 0; - + if(!(decim & 1)) { hb2 = 1; decim = decim >> 1; } - + if(!(decim & 1)) { hb1 = 1; decim = decim >> 1; } - + if (decim < MIN_CIC_DECIM || decim > MAX_CIC_DECIM) ok = false; else { @@ -294,7 +294,7 @@ read_time_cmd(const op_generic_t *p, void *reply_payload, size_t reply_payload_space) { op_read_time_reply_t *r = (op_read_time_reply_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room r->opcode = OP_READ_TIME_REPLY; @@ -323,7 +323,7 @@ dboard_info_cmd(const op_generic_t *p, void *reply_payload, size_t reply_payload_space) { op_dboard_info_reply_t *r = (op_dboard_info_reply_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room r->opcode = OP_DBOARD_INFO_REPLY; @@ -411,14 +411,14 @@ generic_reply(const op_generic_t *p, bool ok) { op_generic_t *r = (op_generic_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room - + r->opcode = p->opcode | OP_REPLY_BIT; r->len = sizeof(*r); r->rid = p->rid; r->ok = ok; - + return r->len; } @@ -426,14 +426,14 @@ static size_t add_eop(void *reply_payload, size_t reply_payload_space) { op_generic_t *r = (op_generic_t *) reply_payload; - if (reply_payload_space < sizeof(*r)) + if (reply_payload_space < sizeof(*r)) return 0; // no room - + r->opcode = OP_EOP; r->len = sizeof(*r); r->rid = 0; r->ok = 0; - + return r->len; } @@ -443,15 +443,15 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) unsigned char reply[sizeof(u2_eth_packet_t) + 4 * sizeof(u2_subpkt_t)] _AL4; unsigned char *reply_payload = &reply[sizeof(u2_eth_packet_t)]; int reply_payload_space = sizeof(reply) - sizeof(u2_eth_packet_t); - + // initialize reply memset(reply, 0, sizeof(reply)); set_reply_hdr((u2_eth_packet_t *) reply, pkt); - + // point to beginning of payload (subpackets) unsigned char *payload = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t); int payload_len = len - sizeof(u2_eth_packet_t); - + size_t subpktlen = 0; bool ok = false; @@ -468,7 +468,7 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) case OP_ID: subpktlen = op_id_cmd(gp, reply_payload, reply_payload_space); break; - + case OP_CONFIG_TX_V2: subpktlen = config_tx_v2_cmd((op_config_tx_v2_t *) payload, reply_payload, reply_payload_space); break; @@ -478,15 +478,18 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) break; case OP_START_RX_STREAMING: - start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload); + if (pkt->fixed.timestamp == -1) // Start now (default) + start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload); + else + start_rx_streaming_at_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *)payload, pkt->fixed.timestamp); ok = true; goto generic_reply; - + case OP_STOP_RX: stop_rx_cmd(); ok = true; goto generic_reply; - + case OP_BURN_MAC_ADDR: ok = ethernet_set_mac_addr(&((op_burn_mac_addr_t *)payload)->addr); goto generic_reply; @@ -532,8 +535,8 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) case OP_GPIO_SET_DDR: ok = true; - hal_gpio_set_ddr(((op_gpio_t *)payload)->bank, - ((op_gpio_t *)payload)->value, + hal_gpio_set_ddr(((op_gpio_t *)payload)->bank, + ((op_gpio_t *)payload)->value, ((op_gpio_t *)payload)->mask); goto generic_reply; @@ -549,8 +552,8 @@ handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) case OP_GPIO_WRITE: ok = true; - hal_gpio_write(((op_gpio_t *)payload)->bank, - ((op_gpio_t *)payload)->value, + hal_gpio_write(((op_gpio_t *)payload)->bank, + ((op_gpio_t *)payload)->value, ((op_gpio_t *)payload)->mask); goto generic_reply; diff --git a/usrp2/firmware/apps/app_common_v2.h b/usrp2/firmware/apps/app_common_v2.h index 5058661ad..ff1baec06 100644 --- a/usrp2/firmware/apps/app_common_v2.h +++ b/usrp2/firmware/apps/app_common_v2.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,8 +55,10 @@ print_tune_result(char *msg, bool tune_ok, void start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p); +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time); void stop_rx_cmd(void); void restart_streaming(void); +void restart_streaming_at(uint32_t time); bool is_streaming(void); void handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len); diff --git a/usrp2/firmware/apps/factory_test.c b/usrp2/firmware/apps/factory_test.c index a4bc06d58..e7dde524a 100644 --- a/usrp2/firmware/apps/factory_test.c +++ b/usrp2/firmware/apps/factory_test.c @@ -1,5 +1,5 @@ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -154,7 +154,7 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -187,6 +187,11 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) } +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{} +void restart_streaming_at(uint32_t time) +{} + void stop_rx_cmd(void) { @@ -224,7 +229,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); @@ -259,22 +264,22 @@ int test_ram() { int i,j,k; output_regs->ram_page = 1<<10; - + extram[0] = 0xDEADBEEF; extram[1] = 0xF00D1234; extram[7] = 0x76543210; - + output_regs->ram_page = 2<<10; extram[7] = 0x55555555; extram[1] = 0xaaaaaaaa; extram[0] = 0xeeeeeeee; - + output_regs->ram_page = 1<<10; - + i = extram[0]; k = extram[1]; j = extram[7]; - + if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) { puts("RAM FAIL1!\n"); puthex32_nl(i); @@ -282,7 +287,7 @@ int test_ram() puthex32_nl(k); return 0; } - + output_regs->ram_page = 2<<10; j = extram[7]; @@ -306,7 +311,7 @@ int test_sd() puts("FAILED INIT of Card\n"); return 0; } - + unsigned char buf[512]; i = sd_read_block(2048,buf); if(i == 0) { diff --git a/usrp2/firmware/apps/mimo_tx_slave.c b/usrp2/firmware/apps/mimo_tx_slave.c index e7da984c5..4c284b7c9 100644 --- a/usrp2/firmware/apps/mimo_tx_slave.c +++ b/usrp2/firmware/apps/mimo_tx_slave.c @@ -160,7 +160,7 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -192,6 +192,10 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) restart_streaming(); } +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{} +void restart_streaming_at(uint32_t time) +{} void stop_rx_cmd(void) @@ -230,7 +234,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); @@ -310,7 +314,7 @@ main(void) //output_regs->flush_icache = 1; - + // initialize double buffering state machine for DSP RX -> Ethernet if (FW_SETS_SEQNO){ diff --git a/usrp2/firmware/apps/serdes_txrx.c b/usrp2/firmware/apps/serdes_txrx.c index 7816f7a65..aa4a3f33c 100644 --- a/usrp2/firmware/apps/serdes_txrx.c +++ b/usrp2/firmware/apps/serdes_txrx.c @@ -152,7 +152,7 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -184,6 +184,10 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) restart_streaming(); } +void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{} +void restart_streaming_at(uint32_t time) +{} void stop_rx_cmd(void) @@ -222,7 +226,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); @@ -302,7 +306,7 @@ main(void) //output_regs->flush_icache = 1; - + // initialize double buffering state machine for DSP RX -> Ethernet if (FW_SETS_SEQNO){ diff --git a/usrp2/firmware/apps/txrx.c b/usrp2/firmware/apps/txrx.c index b2487ed89..975f314bd 100644 --- a/usrp2/firmware/apps/txrx.c +++ b/usrp2/firmware/apps/txrx.c @@ -1,5 +1,5 @@ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2009 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -152,7 +152,35 @@ restart_streaming(void) dsp_rx_regs->rx_command = MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, streaming_items_per_frame, - 1, 1); + 1, 1); + + dsp_rx_regs->rx_time = 0; // enqueue second command +} + +void +restart_streaming_at(uint32_t time) +{ + // setup RX DSP regs + dsp_rx_regs->clear_state = 1; // reset + + streaming_p = true; + streaming_frame_count = FRAMES_PER_CMD; + + dsp_rx_regs->rx_command = + MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, + streaming_items_per_frame, + 0, 1); // set "chain" bit + + // kick off the state machine + dbsm_start(&dsp_rx_sm); + + dsp_rx_regs->rx_time = time; // enqueue first of two commands + + // make sure this one and the rest have the "now" and "chain" bits set. + dsp_rx_regs->rx_command = + MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame, + streaming_items_per_frame, + 1, 1); dsp_rx_regs->rx_time = 0; // enqueue second command } @@ -184,6 +212,33 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p) restart_streaming(); } +void +start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time) +{ + host_mac_addr = *host; // remember who we're sending to + + /* + * Construct ethernet header and word0 and preload into two buffers + */ + u2_eth_packet_t pkt; + memset(&pkt, 0, sizeof(pkt)); + pkt.ehdr.dst = *host; + pkt.ehdr.src = *ethernet_mac_addr(); + pkt.ehdr.ethertype = U2_ETHERTYPE; + u2p_set_word0(&pkt.fixed, 0, 0); + // DSP RX will fill in timestamp + + memcpy_wa(buffer_ram(DSP_RX_BUF_0), &pkt, sizeof(pkt)); + memcpy_wa(buffer_ram(DSP_RX_BUF_1), &pkt, sizeof(pkt)); + + + if (FW_SETS_SEQNO) + fw_seqno = 0; + + streaming_items_per_frame = p->items_per_frame; + restart_streaming_at(time); +} + void stop_rx_cmd(void) @@ -222,7 +277,7 @@ setup_tx() * that we didn't handle the packet. A bit of a kludge * but it should work. */ -bool +bool fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false { uint32_t *p = buffer_ram(buf_this); diff --git a/usrp2/firmware/config/grc_usrp2_firmware.m4 b/usrp2/firmware/config/grc_usrp2_firmware.m4 index 7f1f9a796..53ff03ce4 100644 --- a/usrp2/firmware/config/grc_usrp2_firmware.m4 +++ b/usrp2/firmware/config/grc_usrp2_firmware.m4 @@ -17,6 +17,12 @@ dnl along with GNU Radio; see the file COPYING. If not, write to dnl the Free Software Foundation, Inc., 51 Franklin Street, dnl Boston, MA 02110-1301, USA. +dnl Fix 2.64 cross compile detection for AVR and RTEMS +dnl by not trying to compile fopen. +m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64], + [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77], + [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])]) + AC_DEFUN([GRC_USRP2_FIRMWARE],[ dnl we use --enable-usrp2-firmware to enable this GRC_ENABLE(usrp2-firmware) diff --git a/usrp2/firmware/lib/db_init.c b/usrp2/firmware/lib/db_init.c index 925a34f39..a0bfc5cfb 100644 --- a/usrp2/firmware/lib/db_init.c +++ b/usrp2/firmware/lib/db_init.c @@ -69,7 +69,9 @@ struct db_base *all_dboards[] = { &db_rfx_2400_tx, &db_rfx_2400_rx, &db_tvrx1, +#if 0 &db_tvrx2, +#endif &db_tvrx3, &db_dbsrx, &db_xcvr2450_tx, diff --git a/usrp2/firmware/lib/db_tvrx.c b/usrp2/firmware/lib/db_tvrx.c index ba70b6402..49bf75883 100644 --- a/usrp2/firmware/lib/db_tvrx.c +++ b/usrp2/firmware/lib/db_tvrx.c @@ -28,7 +28,7 @@ bool tvrx_set_freq(struct db_base *db, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc); bool tvrx_set_gain(struct db_base *db, u2_fxpt_gain_t gain); #define I2C_ADDR 0x60 -#define ref_freq (U2_DOUBLE_TO_FXPT_FREQ(4e6)/640*8) +#define REF_FREQ (U2_DOUBLE_TO_FXPT_FREQ(4e6)/640*8) #define ref_div 640 /* choices are 640, 512, 1024 */ @@ -101,6 +101,7 @@ struct db_tvrx1 db_tvrx1 = { .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(5.75e6), }; +#if 0 struct db_tvrx2 db_tvrx2 = { .base.dbid = 0x000c, .base.is_tx = false, @@ -113,7 +114,7 @@ struct db_tvrx2 db_tvrx2 = { .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(1), .base.is_quadrature = false, .base.i_and_q_swapped = false, - .base.spectrum_inverted = true, + .base.spectrum_inverted = false, .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = tvrx_init, .base.set_freq = tvrx_set_freq, @@ -125,8 +126,9 @@ struct db_tvrx2 db_tvrx2 = { // .base.atr_tx_delay = // .base.atr_rx_delay = .common.first_if = U2_DOUBLE_TO_FXPT_FREQ(44e6), - .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(44e6), + .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(56e6), // Fs - 44e6 }; +#endif struct db_tvrx3 db_tvrx3 = { .base.dbid = 0x0040, @@ -140,7 +142,7 @@ struct db_tvrx3 db_tvrx3 = { .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(1), .base.is_quadrature = false, .base.i_and_q_swapped = false, - .base.spectrum_inverted = true, + .base.spectrum_inverted = false, .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), .base.init = tvrx_init, .base.set_freq = tvrx_set_freq, @@ -152,7 +154,7 @@ struct db_tvrx3 db_tvrx3 = { // .base.atr_tx_delay = // .base.atr_rx_delay = .common.first_if = U2_DOUBLE_TO_FXPT_FREQ(44e6), - .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(44e6), + .common.second_if = U2_DOUBLE_TO_FXPT_FREQ(56e6), // Fs - 44e6 }; bool @@ -173,25 +175,25 @@ tvrx_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc) struct db_tvrx_dummy *db = (struct db_tvrx_dummy *) dbb; u2_fxpt_freq_t target_lo_freq = freq + db->common.first_if; - int N_DIV = u2_fxpt_freq_round_to_int(((1LL<<20) * target_lo_freq)/ref_freq); + int n_div = u2_fxpt_freq_round_to_int(((1LL<<20) * target_lo_freq)/REF_FREQ); - u2_fxpt_freq_t actual_lo_freq = ref_freq * N_DIV; + u2_fxpt_freq_t actual_lo_freq = REF_FREQ * n_div; u2_fxpt_freq_t actual_freq = actual_lo_freq - db->common.first_if; - if(N_DIV > 32767) + if(n_div > 32767) return false; if (0) - printf("N_DIV = %d, actual_freq = %d, actual_lo_freq = %d\n", - N_DIV, u2_fxpt_freq_round_to_int(actual_freq), + printf("n_div = %d, actual_freq = %d, actual_lo_freq = %d\n", + n_div, u2_fxpt_freq_round_to_int(actual_freq), u2_fxpt_freq_round_to_int(actual_lo_freq)); unsigned char buf[4]; - buf[0] = (N_DIV>>8) & 0xff; - buf[1] = N_DIV & 0xff; + buf[0] = (n_div>>8) & 0xff; + buf[1] = n_div & 0xff; buf[2] = control_byte_1; - buf[3] = (freq < U2_DOUBLE_TO_FXPT_FREQ(158e6)) ? 0xa8 : // VHF LOW - (freq < U2_DOUBLE_TO_FXPT_FREQ(464e6)) ? 0x98 : // VHF HIGH - 0x38; // UHF + buf[3] = ((actual_freq < U2_DOUBLE_TO_FXPT_FREQ(158e6)) ? 0xa8 : // VHF LOW + (actual_freq < U2_DOUBLE_TO_FXPT_FREQ(464e6)) ? 0x98 : // VHF HIGH + 0x38); // UHF *dc = actual_freq - db->common.second_if; return i2c_write(I2C_ADDR,buf,4); diff --git a/usrp2/firmware/lib/db_xcvr2450.c b/usrp2/firmware/lib/db_xcvr2450.c index ffdf8d660..a48af9035 100644 --- a/usrp2/firmware/lib/db_xcvr2450.c +++ b/usrp2/firmware/lib/db_xcvr2450.c @@ -250,8 +250,8 @@ static void set_reg_lpf(struct db_xcvr2450_dummy *db){ int reg_lpf = ( (db->common->d_rssi_hbw<<15) | - (db->common->d_txlpf_bw<<10) | - (db->common->d_rxlpf_bw<<9) | + (db->common->d_txlpf_bw<<9) | + (db->common->d_rxlpf_bw<<7) | (db->common->d_rxlpf_fine<<4) | 7); send_reg(reg_lpf); } diff --git a/usrp2/firmware/lib/memory_map.h b/usrp2/firmware/lib/memory_map.h index 78a4330d2..0d0cf04f6 100644 --- a/usrp2/firmware/lib/memory_map.h +++ b/usrp2/firmware/lib/memory_map.h @@ -175,6 +175,10 @@ typedef struct { volatile uint32_t last_line[NBUFFERS]; // last line xfer'd in buffer volatile uint32_t status; // error and done flags volatile uint32_t hw_config; // see below + volatile uint32_t dummy[3]; + volatile uint32_t irqs; + volatile uint32_t pri_enc_bp_status; + volatile uint32_t cycle_count; } buffer_pool_status_t; #define buffer_pool_status ((buffer_pool_status_t *) BUFFER_POOL_STATUS_BASE) diff --git a/usrp2/fpga/control_lib/pic.v b/usrp2/fpga/control_lib/pic.v new file mode 100644 index 000000000..9b9944d4a --- /dev/null +++ b/usrp2/fpga/control_lib/pic.v @@ -0,0 +1,183 @@ + +// Heavily modified by M. Ettus, 2009, little original code remains +// Modified by M. Ettus, 2008 for 32 bit width + +///////////////////////////////////////////////////////////////////// +//// //// +//// OpenCores Simple Programmable Interrupt Controller //// +//// //// +//// Author: Richard Herveille //// +//// richard@asics.ws //// +//// www.asics.ws //// +//// //// +///////////////////////////////////////////////////////////////////// +//// //// +//// Copyright (C) 2002 Richard Herveille //// +//// richard@asics.ws //// +//// //// +//// This source file may be used and distributed without //// +//// restriction provided that this copyright statement is not //// +//// removed from the file and that any derivative work contains //// +//// the original copyright notice and the associated disclaimer.//// +//// //// +//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY //// +//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED //// +//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS //// +//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR //// +//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, //// +//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES //// +//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE //// +//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR //// +//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF //// +//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT //// +//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT //// +//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE //// +//// POSSIBILITY OF SUCH DAMAGE. //// +//// //// +///////////////////////////////////////////////////////////////////// +// +// This is a simple Programmable Interrupt Controller. +// The number of interrupts is depending on the databus size. +// There's one interrupt input per databit (i.e. 16 interrupts for a 16 +// bit databus). +// All attached devices share the same CPU priority level. +// +// +// +// Registers: +// +// 0x00: EdgeEnable Register +// bits 7:0 R/W Edge Enable '1' = edge triggered interrupt source +// '0' = level triggered interrupt source +// 0x01: PolarityRegister +// bits 7:0 R/W Polarity '1' = high level / rising edge +// '0' = low level / falling edge +// 0x02: MaskRegister +// bits 7:0 R/W Mask '1' = interrupt masked (disabled) +// '0' = interrupt not masked (enabled) +// 0x03: PendingRegister +// bits 7:0 R/W Pending '1' = interrupt pending +// '0' = no interrupt pending +// +// A CPU interrupt is generated when an interrupt is pending and its +// MASK bit is cleared. +// +// +// +// HOWTO: +// +// Clearing pending interrupts: +// Writing a '1' to a bit in the interrupt pending register clears the +// interrupt. Make sure to clear the interrupt at the source before +// writing to the interrupt pending register. Otherwise the interrupt +// will be set again. +// +// Priority based interrupts: +// Upon reception of an interrupt, check the interrupt register and +// determine the highest priority interrupt. Mask all interrupts from the +// current level to the lowest level. This negates the interrupt line, and +// makes sure only interrupts with a higher level are triggered. After +// completion of the interrupt service routine, clear the interrupt source, +// the interrupt bit in the pending register, and restore the MASK register +// to it's previous state. +// +// Addapt the core for fewer interrupt sources: +// If less than 8 interrupt sources are required, than the 'is' parameter +// can be set to the amount of required interrupts. Interrupts are mapped +// starting at the LSBs. So only the 'is' LSBs per register are valid. All +// other bits (i.e. the 8-'is' MSBs) are set to zero '0'. +// Codesize is approximately linear to the amount of interrupts. I.e. using +// 4 instead of 8 interrupt sources reduces the size by approx. half. +// + + +module pic + (input clk_i, input rst_i, input cyc_i, input stb_i, + input [2:0] adr_i, + input we_i, + input [31:0] dat_i, + output reg [31:0] dat_o, + output reg ack_o, + output reg int_o, + input [31:0] irq + ); + + reg [31:0] pol, edgen, pending, mask; // register bank + reg [31:0] lirq, dirq; // latched irqs, delayed latched irqs + + // latch interrupt inputs + always @(posedge clk_i) + lirq <= irq; + + // generate delayed latched irqs + always @(posedge clk_i) + dirq <= lirq; + + // generate actual triggers + function trigger; + input edgen, pol, lirq, dirq; + reg edge_irq, level_irq; + begin + edge_irq = pol ? (lirq & ~dirq) : (dirq & ~lirq); + level_irq = pol ? lirq : ~lirq; + trigger = edgen ? edge_irq : level_irq; + end + endfunction + + reg [31:0] irq_event; + integer n; + always @(posedge clk_i) + for(n = 0; n < 32; n = n+1) + irq_event[n] <= trigger(edgen[n], pol[n], lirq[n], dirq[n]); + + // generate wishbone register bank writes + wire wb_acc = cyc_i & stb_i; // WISHBONE access + wire wb_wr = wb_acc & we_i; // WISHBONE write access + + always @(posedge clk_i) + if (rst_i) + begin + pol <= 0; // clear polarity register + edgen <= 0; // clear edge enable register + mask <= 0; // mask all interrupts + end + else if(wb_wr) // wishbone write cycle?? + case (adr_i) // synopsys full_case parallel_case + 3'd0 : edgen <= dat_i; // EDGE-ENABLE register + 3'd1 : pol <= dat_i; // POLARITY register + 3'd2 : mask <= dat_i; // MASK register + 3'd3 : ; // PENDING register is a special case (see below) + 3'd4 : ; // Priority encoded live (pending & ~mask) + endcase + + // pending register is a special case + always @(posedge clk_i) + if (rst_i) + pending <= 0; // clear all pending interrupts + else if ( wb_wr & (adr_i == 3'd3) ) + pending <= (pending & ~dat_i) | irq_event; + else + pending <= pending | irq_event; + + wire [31:0] live_enc; + priority_enc priority_enc ( .in(pending & ~mask), .out(live_enc) ); + + always @(posedge clk_i) + case (adr_i) // synopsys full_case parallel_case + 3'd0 : dat_o <= edgen; + 3'd1 : dat_o <= pol; + 3'd2 : dat_o <= mask; + 3'd3 : dat_o <= pending; + 3'd4 : dat_o <= live_enc; + endcase + + always @(posedge clk_i) + ack_o <= wb_acc & !ack_o; + + always @(posedge clk_i) + if(rst_i) + int_o <= 0; + else + int_o <= |(pending & ~mask); + +endmodule diff --git a/usrp2/fpga/control_lib/priority_enc.v b/usrp2/fpga/control_lib/priority_enc.v new file mode 100644 index 000000000..916192445 --- /dev/null +++ b/usrp2/fpga/control_lib/priority_enc.v @@ -0,0 +1,44 @@ + +module priority_enc + (input [31:0] in, + output reg [31:0] out); + + always @* + casex(in) + 32'b1xxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 31; + 32'b01xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 30; + 32'b001x_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 29; + 32'b0001_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 28; + 32'b0000_1xxx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 27; + 32'b0000_01xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 26; + 32'b0000_001x_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 25; + 32'b0000_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 24; + 32'b0000_0000_1xxx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 23; + 32'b0000_0000_01xx_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 22; + 32'b0000_0000_001x_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 21; + 32'b0000_0000_0001_xxxx_xxxx_xxxx_xxxx_xxxx : out <= 20; + 32'b0000_0000_0000_1xxx_xxxx_xxxx_xxxx_xxxx : out <= 19; + 32'b0000_0000_0000_01xx_xxxx_xxxx_xxxx_xxxx : out <= 18; + 32'b0000_0000_0000_001x_xxxx_xxxx_xxxx_xxxx : out <= 17; + 32'b0000_0000_0000_0001_xxxx_xxxx_xxxx_xxxx : out <= 16; + 32'b0000_0000_0000_0000_1xxx_xxxx_xxxx_xxxx : out <= 15; + 32'b0000_0000_0000_0000_01xx_xxxx_xxxx_xxxx : out <= 14; + 32'b0000_0000_0000_0000_001x_xxxx_xxxx_xxxx : out <= 13; + 32'b0000_0000_0000_0000_0001_xxxx_xxxx_xxxx : out <= 12; + 32'b0000_0000_0000_0000_0000_1xxx_xxxx_xxxx : out <= 11; + 32'b0000_0000_0000_0000_0000_01xx_xxxx_xxxx : out <= 10; + 32'b0000_0000_0000_0000_0000_001x_xxxx_xxxx : out <= 9; + 32'b0000_0000_0000_0000_0000_0001_xxxx_xxxx : out <= 8; + 32'b0000_0000_0000_0000_0000_0000_1xxx_xxxx : out <= 7; + 32'b0000_0000_0000_0000_0000_0000_01xx_xxxx : out <= 6; + 32'b0000_0000_0000_0000_0000_0000_001x_xxxx : out <= 5; + 32'b0000_0000_0000_0000_0000_0000_0001_xxxx : out <= 4; + 32'b0000_0000_0000_0000_0000_0000_0000_1xxx : out <= 3; + 32'b0000_0000_0000_0000_0000_0000_0000_01xx : out <= 2; + 32'b0000_0000_0000_0000_0000_0000_0000_001x : out <= 1; + 32'b0000_0000_0000_0000_0000_0000_0000_0001 : out <= 0; + 32'b0000_0000_0000_0000_0000_0000_0000_0000 : out <= 32'hFFFF_FFFF; + default : out <= 32'hFFFF_FFFF; + endcase // casex (in) + +endmodule // priority_enc diff --git a/usrp2/fpga/top/u2_core/u2_core.v b/usrp2/fpga/top/u2_core/u2_core.v index 03016e9b3..fd17a10a7 100755 --- a/usrp2/fpga/top/u2_core/u2_core.v +++ b/usrp2/fpga/top/u2_core/u2_core.v @@ -158,6 +158,7 @@ module u2_core wire serdes_link_up; wire epoch; + wire [31:0] irq; // /////////////////////////////////////////////////////////////////////////////////////////////// // Wishbone Single Master INTERCON @@ -278,6 +279,7 @@ module u2_core .wb_we_o(ram_loader_we),.wb_ack_i(ram_loader_ack), .ram_loader_done_o(ram_loader_done)); + // ///////////////////////////////////////////////////////////////////////// // Processor aeMB_core_BE #(.ISIZ(16),.DSIZ(16),.MUL(0),.BSF(1)) aeMB (.sys_clk_i(wb_clk), .sys_rst_i(wb_rst), @@ -292,6 +294,7 @@ module u2_core assign bus_error = m0_err | m0_rty; + // ///////////////////////////////////////////////////////////////////////// // Dual Ported RAM -- D-Port is Slave #0 on main Wishbone // I-port connects directly to processor and ram loader @@ -314,6 +317,7 @@ module u2_core setting_reg #(.my_addr(7)) sr_icache (.clk(wb_clk),.rst(wb_rst),.strobe(set_stb),.addr(set_addr), .in(set_data),.out(),.changed(flush_icache)); + // ///////////////////////////////////////////////////////////////////////// // Buffer Pool, slave #1 wire rd0_ready_i, rd0_ready_o; wire rd1_ready_i, rd1_ready_o; @@ -353,6 +357,10 @@ module u2_core .rd3_data_o(rd3_dat), .rd3_flags_o(rd3_flags), .rd3_ready_i(rd3_ready_i), .rd3_ready_o(rd3_ready_o) ); + wire [31:0] status_enc; + priority_enc priority_enc (.in({16'b0,status[15:0]}), .out(status_enc)); + + // ///////////////////////////////////////////////////////////////////////// // SPI -- Slave #2 spi_top shared_spi (.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),.wb_adr_i(s2_adr[4:0]),.wb_dat_i(s2_dat_o), @@ -361,6 +369,7 @@ module u2_core .ss_pad_o({sen_tx_db,sen_tx_adc,sen_tx_dac,sen_rx_db,sen_rx_adc,sen_rx_dac,sen_dac,sen_clk}), .sclk_pad_o(sclk),.mosi_pad_o(mosi),.miso_pad_i(miso) ); + // ///////////////////////////////////////////////////////////////////////// // I2C -- Slave #3 i2c_master_top #(.ARST_LVL(1)) i2c (.wb_clk_i(wb_clk),.wb_rst_i(wb_rst),.arst_i(1'b0), @@ -372,6 +381,7 @@ module u2_core assign s3_dat_i[31:8] = 24'd0; + // ///////////////////////////////////////////////////////////////////////// // GPIOs -- Slave #4 nsgpio nsgpio(.clk_i(wb_clk),.rst_i(wb_rst), .cyc_i(s4_cyc),.stb_i(s4_stb),.adr_i(s4_adr[3:0]),.we_i(s4_we), @@ -379,19 +389,24 @@ module u2_core .atr(atr_lines),.debug_0(debug_gpio_0),.debug_1(debug_gpio_1), .gpio( {io_tx,io_rx} ) ); - // Buffer Pool Status -- Slave #5 + // ///////////////////////////////////////////////////////////////////////// + // Buffer Pool Status -- Slave #5 + + reg [31:0] cycle_count; + always @(posedge wb_clk) + if(wb_rst) + cycle_count <= 0; + else + cycle_count <= cycle_count + 1; + wb_readback_mux buff_pool_status - (.wb_clk_i(wb_clk), - .wb_rst_i(wb_rst), - .wb_stb_i(s5_stb), - .wb_adr_i(s5_adr), - .wb_dat_o(s5_dat_i), - .wb_ack_o(s5_ack), + (.wb_clk_i(wb_clk), .wb_rst_i(wb_rst), .wb_stb_i(s5_stb), + .wb_adr_i(s5_adr), .wb_dat_o(s5_dat_i), .wb_ack_o(s5_ack), .word00(status_b0),.word01(status_b1),.word02(status_b2),.word03(status_b3), .word04(status_b4),.word05(status_b5),.word06(status_b6),.word07(status_b7), .word08(status),.word09({sim_mode,27'b0,clock_divider[3:0]}),.word10(32'b0), - .word11(32'b0),.word12(32'b0),.word13(32'b0),.word14(32'b0),.word15(32'b0) + .word11(32'b0),.word12(32'b0),.word13(irq),.word14(status_enc),.word15(cycle_count) ); // ///////////////////////////////////////////////////////////////////////// @@ -457,13 +472,14 @@ module u2_core // ///////////////////////////////////////////////////////////////////////// // Interrupt Controller, Slave #8 - wire [15:0] irq={{4'b0, clk_status, serdes_link_up, uart_tx_int, uart_rx_int}, - {pps_int,overrun,underrun,PHY_INTn,i2c_int,spi_int,timer_int,buffer_int}}; + assign irq= {{8'b0}, + {8'b0}, + {4'b0, clk_status, serdes_link_up, uart_tx_int, uart_rx_int}, + {pps_int,overrun,underrun,PHY_INTn,i2c_int,spi_int,timer_int,buffer_int}}; - simple_pic #(.is(16),.dwidth(32)) simple_pic - (.clk_i(wb_clk),.rst_i(wb_rst),.cyc_i(s8_cyc),.stb_i(s8_stb),.adr_i(s8_adr[3:2]), - .we_i(s8_we),.dat_i(s8_dat_o),.dat_o(s8_dat_i),.ack_o(s8_ack),.int_o(proc_int), - .irq(irq) ); + pic pic(.clk_i(wb_clk),.rst_i(wb_rst),.cyc_i(s8_cyc),.stb_i(s8_stb),.adr_i(s8_adr[3:2]), + .we_i(s8_we),.dat_i(s8_dat_o),.dat_o(s8_dat_i),.ack_o(s8_ack),.int_o(proc_int), + .irq(irq) ); // ///////////////////////////////////////////////////////////////////////// // Master Timer, Slave #9 diff --git a/usrp2/fpga/top/u2_rev3/Makefile b/usrp2/fpga/top/u2_rev3/Makefile index 94681f6cd..4358d7c56 100644 --- a/usrp2/fpga/top/u2_rev3/Makefile +++ b/usrp2/fpga/top/u2_rev3/Makefile @@ -82,6 +82,8 @@ control_lib/sd_spi.v \ control_lib/sd_spi_wb.v \ control_lib/wb_bridge_16_32.v \ control_lib/reset_sync.v \ +control_lib/priority_enc.v \ +control_lib/pic.v \ simple_gemac/simple_gemac_wrapper.v \ simple_gemac/simple_gemac.v \ simple_gemac/simple_gemac_wb.v \ @@ -132,7 +134,6 @@ opencores/i2c/rtl/verilog/i2c_master_byte_ctrl.v \ opencores/i2c/rtl/verilog/i2c_master_defines.v \ opencores/i2c/rtl/verilog/i2c_master_top.v \ opencores/i2c/rtl/verilog/timescale.v \ -opencores/simple_pic/rtl/simple_pic.v \ opencores/spi/rtl/verilog/spi_clgen.v \ opencores/spi/rtl/verilog/spi_defines.v \ opencores/spi/rtl/verilog/spi_shift.v \ diff --git a/usrp2/host/include/usrp2/usrp2.h b/usrp2/host/include/usrp2/usrp2.h index 7a612f945..2d9e2a4b0 100644 --- a/usrp2/host/include/usrp2/usrp2.h +++ b/usrp2/host/include/usrp2/usrp2.h @@ -60,7 +60,7 @@ namespace usrp2 { * * \returns a vector of properties, 1 entry for each matching USRP2 found. */ - props_vector_t find(const std::string &ifc, const std::string &mac_addr=""); + props_vector_t find(const std::string &ifc, const std::string &mac_addr=""); class tune_result; @@ -79,10 +79,10 @@ namespace usrp2 { /*! * Shared pointer to this class - */ + */ typedef boost::shared_ptr<usrp2> sptr; - - /*! + + /*! * Static function to return an instance of usrp2 as a shared pointer * * \param ifc Network interface name, e.g., "eth0" @@ -96,7 +96,7 @@ namespace usrp2 { /*! * Class destructor */ - ~usrp2(); + ~usrp2(); /*! * Returns the MAC address associated with this USRP @@ -120,10 +120,10 @@ namespace usrp2 { */ bool set_rx_gain(double gain); - //! return minimum Rx gain + //! return minimum Rx gain double rx_gain_min(); - //! return maximum Rx gain + //! return maximum Rx gain double rx_gain_max(); //! return Rx gain db_per_step @@ -160,7 +160,7 @@ namespace usrp2 { /*! * Set received sample format - * + * * domain: complex or real * type: floating, fixed point, or raw * depth: bits per sample @@ -172,12 +172,33 @@ namespace usrp2 { /*! * Start streaming receive mode. USRP2 will send a continuous stream of * DSP pipeline samples to host. Call rx_samples(...) to access. - * + * * \param channel Stream channel number (0-30) * \param items_per_frame Number of 32-bit items per frame. */ bool start_rx_streaming(unsigned int channel=0, unsigned int items_per_frame=0); - + + /*! + * Start streaming receive mode at specified timestamp. USRP2 will send a + * continuous stream of DSP pipeline samples to host. Call rx_samples(...) + * to access. + * + * \param channel Stream channel number (0-30) + * \param items_per_frame Number of 32-bit items per frame. + * \param time Timestamp to start streaming at + */ + bool start_rx_streaming_at(unsigned int channel=0, unsigned int items_per_frame=0, unsigned int time=0); + + /*! + * Sync to PPS and start streaming receive mode at specified timestamp. + * Just like calling sync_to_pps() and start_rx_streaming_at(). + * + * \param channel Stream channel number (0-30) + * \param items_per_frame Number of 32-bit items per frame. + * \param time Timestamp to start streaming at + */ + bool sync_and_start_rx_streaming_at(unsigned int channel=0, unsigned int items_per_frame=0, uint32_t time=0); + /*! * Stop streaming receive mode. */ @@ -193,7 +214,7 @@ namespace usrp2 { * Returns number of times receive overruns have occurred */ unsigned int rx_overruns(); - + /*! * Returns total number of missing frames from overruns. */ @@ -210,10 +231,10 @@ namespace usrp2 { */ bool set_tx_gain(double gain); - //! return minimum Tx gain + //! return minimum Tx gain double tx_gain_min(); - //! return maximum Tx gain + //! return maximum Tx gain double tx_gain_max(); //! return Tx gain db_per_step @@ -255,7 +276,7 @@ namespace usrp2 { /*! * Set transmit sample format - * + * * domain: complex or real * type: floating, fixed point, or raw * depth: bits per sample @@ -272,7 +293,7 @@ namespace usrp2 { * \param nsamples is the number of samples to transmit * \param metadata provides the timestamp and flags * - * The complex<float> samples are converted to the appropriate + * The complex<float> samples are converted to the appropriate * "on the wire" representation, depending on the current USRP2 * configuration. Typically, this is big-endian 16-bit I & Q. */ @@ -400,12 +421,12 @@ namespace usrp2 { * * \param addr 32-bit aligned address. Only the lower 16-bits are significant. * \param words Number of 32-bit words - * + * * \returns Vector of 32-bit read values * * WARNING: Attempts to read memory from addresses that do not correspond to RAM or * memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle. - * + * */ std::vector<uint32_t> peek32(uint32_t addr, uint32_t words); @@ -419,7 +440,7 @@ namespace usrp2 { * * WARNING: Attempts to read memory from addresses that do not correspond to RAM or * memory-mapped peripherals may cause the USRP2 to hang, requiring a power cycle. - * + * */ bool poke32(uint32_t addr, const std::vector<uint32_t> &data); @@ -587,7 +608,7 @@ namespace usrp2 { // Only class members can instantiate this class usrp2(const std::string &ifc, props *p, size_t rx_bufsize); - + // All private state is held in opaque pointer std::auto_ptr<impl> d_impl; }; diff --git a/usrp2/host/lib/control.h b/usrp2/host/lib/control.h index 8769e4522..46ce791ea 100644 --- a/usrp2/host/lib/control.h +++ b/usrp2/host/lib/control.h @@ -33,27 +33,35 @@ namespace usrp2 { /*! * OP_CONFIG_RX_V2 command packet */ - struct op_config_rx_v2_cmd + struct op_config_rx_v2_cmd { u2_eth_packet_t h; op_config_rx_v2_t op; op_generic_t eop; }; - struct op_start_rx_streaming_cmd + struct op_start_rx_streaming_cmd { u2_eth_packet_t h; op_start_rx_streaming_t op; op_generic_t eop; }; - + + struct op_sync_and_start_rx_streaming_cmd + { + u2_eth_packet_t h; + op_generic_t sync_op; + op_start_rx_streaming_t rx_op; + op_generic_t eop; + }; + struct op_stop_rx_cmd { u2_eth_packet_t h; op_generic_t op; op_generic_t eop; }; - struct op_config_tx_v2_cmd + struct op_config_tx_v2_cmd { u2_eth_packet_t h; op_config_tx_v2_t op; @@ -67,7 +75,7 @@ namespace usrp2 { op_generic_t eop; }; - struct op_burn_mac_addr_cmd + struct op_burn_mac_addr_cmd { u2_eth_packet_t h; op_burn_mac_addr_t op; @@ -113,20 +121,20 @@ namespace usrp2 { /*! * Control mechanism to allow API calls to block waiting for reply packets - */ + */ class pending_reply { private: unsigned int d_rid; void *d_buffer; size_t d_len; - + // d_mutex is used with d_cond and also protects d_complete omni_mutex d_mutex; omni_condition d_cond; bool d_complete; - public: + public: /*! * Construct a pending reply from the reply ID, response packet * buffer, and buffer length. @@ -165,7 +173,7 @@ namespace usrp2 { */ size_t len() const { return d_len; } }; - + } // namespace usrp2 #endif /* INCLUDED_CONTROL_H */ diff --git a/usrp2/host/lib/usrp2.cc b/usrp2/host/lib/usrp2.cc index a2a9ecc11..801a436a3 100644 --- a/usrp2/host/lib/usrp2.cc +++ b/usrp2/host/lib/usrp2.cc @@ -62,7 +62,7 @@ namespace usrp2 { else { if (key == p->key) // found it return usrp2::sptr(p->value); - else + else ++p; // keep looking } } @@ -90,15 +90,15 @@ namespace usrp2 { p.addr[3] = 0x85; p.addr[4] = 0x30; p.addr[5] = 0x00; - + int len = s.size(); switch (len) { - + case 5: if (sscanf(s.c_str(), "%hhx:%hhx", &p.addr[4], &p.addr[5]) != 2) return false; break; - + case 17: if (sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &p.addr[0], &p.addr[1], &p.addr[2], @@ -109,7 +109,7 @@ namespace usrp2 { default: return false; } - + char buf[128]; snprintf(buf, sizeof(buf), "%02x:%02x:%02x:%02x:%02x:%02x", @@ -148,13 +148,13 @@ namespace usrp2 { { // NOP } - + // Public class destructor. d_impl will auto-delete. usrp2::~usrp2() { // NOP } - + std::string usrp2::mac_addr() { @@ -169,12 +169,12 @@ namespace usrp2 { // Receive - bool + bool usrp2::set_rx_gain(double gain) { return d_impl->set_rx_gain(gain); } - + double usrp2::rx_gain_min() { @@ -204,7 +204,7 @@ namespace usrp2 { { return d_impl->set_rx_center_freq(frequency, result); } - + double usrp2::rx_freq_min() { @@ -222,7 +222,7 @@ namespace usrp2 { { return d_impl->set_rx_decim(decimation_factor); } - + int usrp2::rx_decim() { @@ -234,13 +234,25 @@ namespace usrp2 { { return d_impl->set_rx_scale_iq(scale_i, scale_q); } - + bool usrp2::start_rx_streaming(unsigned int channel, unsigned int items_per_frame) { return d_impl->start_rx_streaming(channel, items_per_frame); } - + + bool + usrp2::start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time) + { + return d_impl->start_rx_streaming_at(channel, items_per_frame,time); + } + + bool + usrp2::sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time) + { + return d_impl->sync_and_start_rx_streaming_at(channel, items_per_frame, time); + } + bool usrp2::rx_samples(unsigned int channel, rx_sample_handler *handler) { @@ -258,7 +270,7 @@ namespace usrp2 { { return d_impl->rx_overruns(); } - + unsigned int usrp2::rx_missing() { @@ -267,12 +279,12 @@ namespace usrp2 { // Transmit - bool + bool usrp2::set_tx_gain(double gain) { return d_impl->set_tx_gain(gain); } - + double usrp2::tx_gain_min() { @@ -302,7 +314,7 @@ namespace usrp2 { { return d_impl->set_tx_center_freq(frequency, result); } - + double usrp2::tx_freq_min() { @@ -321,7 +333,7 @@ namespace usrp2 { { return d_impl->set_tx_interp(interpolation_factor); } - + int usrp2::tx_interp() { @@ -339,7 +351,7 @@ namespace usrp2 { { return d_impl->set_tx_scale_iq(scale_i, scale_q); } - + bool usrp2::tx_32fc(unsigned int channel, const std::complex<float> *samples, @@ -404,7 +416,7 @@ namespace usrp2 { { return d_impl->rx_daughterboard_id(dbid); } - + // low level methods diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc index 3d0304324..a74707634 100644 --- a/usrp2/host/lib/usrp2_impl.cc +++ b/usrp2/host/lib/usrp2_impl.cc @@ -106,7 +106,7 @@ namespace usrp2 { //assert((((uintptr_t) p) % 4) == 0); // must be 4-byte aligned u2_fixed_hdr_t *fh = static_cast<u2_fixed_hdr_t *>(p); - + // FIXME unaligned loads! md->word0 = u2p_word0(fh); md->timestamp = u2p_timestamp(fh); @@ -131,13 +131,13 @@ namespace usrp2 { usrp2::impl::impl(const std::string &ifc, props *p, size_t rx_bufsize) : d_eth_buf(new eth_buffer(rx_bufsize)), d_interface_name(ifc), d_pf(0), d_bg_thread(0), d_bg_running(false), d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0), - d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0), d_num_rx_bytes(0), + d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0), d_num_rx_bytes(0), d_num_enqueued(0), d_enqueued_mutex(), d_bg_pending_cond(&d_enqueued_mutex), d_channel_rings(NCHANS), d_tx_interp(0), d_rx_decim(0), d_dont_enqueue(true) { if (!d_eth_buf->open(ifc, htons(U2_ETHERTYPE))) throw std::runtime_error("Unable to register USRP2 protocol"); - + d_addr = p->addr; // Create a packet filter for U2_ETHERTYPE packets sourced from target USRP2 @@ -146,7 +146,7 @@ namespace usrp2 { d_pf = pktfilter::make_ethertype_inbound_target(U2_ETHERTYPE, (const unsigned char*)&(usrp_mac.addr)); if (!d_pf || !d_eth_buf->attach_pktfilter(d_pf)) throw std::runtime_error("Unable to attach packet filter."); - + if (USRP2_IMPL_DEBUG) std::cerr << "usrp2 constructor: using USRP2 at " << d_addr << std::endl; @@ -199,12 +199,12 @@ namespace usrp2 { if (!set_rx_decim(12)) std::cerr << "usrp2::ctor set_rx_decim failed\n"; - + // set workable defaults for scaling if (!set_rx_scale_iq(DEFAULT_RX_SCALE, DEFAULT_RX_SCALE)) std::cerr << "usrp2::ctor set_rx_scale_iq failed\n"; } - + usrp2::impl::~impl() { stop_bg(); @@ -212,17 +212,17 @@ namespace usrp2 { delete d_pf; d_eth_buf->close(); delete d_eth_buf; - + if (USRP2_IMPL_DEBUG) { std::cerr << std::endl - << "usrp2 destructor: received " << d_num_rx_frames + << "usrp2 destructor: received " << d_num_rx_frames << " frames, with " << d_num_rx_missing << " lost (" << (d_num_rx_frames == 0 ? 0 : (int)(100.0*d_num_rx_missing/d_num_rx_frames)) << "%), totaling " << d_num_rx_bytes << " bytes" << std::endl; } } - + bool usrp2::impl::parse_mac_addr(const std::string &s, u2_mac_addr_t *p) { @@ -232,14 +232,14 @@ namespace usrp2 { p->addr[3] = 0x85; p->addr[4] = 0x30; p->addr[5] = 0x00; - + int len = s.size(); - + switch (len){ - + case 5: return sscanf(s.c_str(), "%hhx:%hhx", &p->addr[4], &p->addr[5]) == 2; - + case 17: return sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &p->addr[0], &p->addr[1], &p->addr[2], @@ -248,36 +248,36 @@ namespace usrp2 { return false; } } - + void usrp2::impl::init_et_hdrs(u2_eth_packet_t *p, const std::string &dst) { p->ehdr.ethertype = htons(U2_ETHERTYPE); - parse_mac_addr(dst, &p->ehdr.dst); + parse_mac_addr(dst, &p->ehdr.dst); memcpy(&p->ehdr.src, d_eth_buf->mac(), 6); p->thdr.flags = 0; // FIXME transport header values? p->thdr.seqno = d_tx_seqno++; p->thdr.ack = 0; } - - void + + void usrp2::impl::init_etf_hdrs(u2_eth_packet_t *p, const std::string &dst, int word0_flags, int chan, uint32_t timestamp) { init_et_hdrs(p, dst); u2p_set_word0(&p->fixed, word0_flags, chan); u2p_set_timestamp(&p->fixed, timestamp); - + if (chan == CONTROL_CHAN) { // no sequence numbers, back it out p->thdr.seqno = 0; d_tx_seqno--; } } - + void usrp2::impl::init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd) { - memset(cmd, 0, sizeof(*cmd)); + memset(cmd, 0, sizeof(*cmd)); init_etf_hdrs(&cmd->h, d_addr, 0, CONTROL_CHAN, -1); cmd->op.opcode = OP_CONFIG_RX_V2; cmd->op.len = sizeof(cmd->op); @@ -289,7 +289,7 @@ namespace usrp2 { void usrp2::impl::init_config_tx_v2_cmd(op_config_tx_v2_cmd *cmd) { - memset(cmd, 0, sizeof(*cmd)); + memset(cmd, 0, sizeof(*cmd)); init_etf_hdrs(&cmd->h, d_addr, 0, CONTROL_CHAN, -1); cmd->op.opcode = OP_CONFIG_TX_V2; cmd->op.len = sizeof(cmd->op); @@ -320,7 +320,7 @@ namespace usrp2 { usrp2::impl::transmit_cmd_and_wait(void *cmd, size_t len, pending_reply *p, double secs) { d_pending_replies[p->rid()] = p; - + if (!transmit_cmd(cmd, len)){ d_pending_replies[p->rid()] = 0; return false; @@ -340,11 +340,11 @@ namespace usrp2 { { d_bg_running = false; d_bg_pending_cond.signal(); - + void *dummy_status; - d_bg_thread->join(&dummy_status); + d_bg_thread->join(&dummy_status); } - + void usrp2::impl::bg_loop() { @@ -356,10 +356,10 @@ namespace usrp2 { // rings, and signal blocked API threads int res = d_eth_buf->rx_frames(this, 100); // FIXME magic timeout if (res == eth_buffer::EB_ERROR) - break; + break; // Wait for user API thread(s) to process all enqueued packets. - // The channel ring thread that decrements d_num_enqueued to zero + // The channel ring thread that decrements d_num_enqueued to zero // will signal this thread to continue. { omni_mutex_lock l(d_enqueued_mutex); @@ -369,7 +369,7 @@ namespace usrp2 { } d_bg_running = false; } - + // // passed to eth_buffer::rx_frames // @@ -401,11 +401,11 @@ namespace usrp2 { { // point to beginning of payload (subpackets) unsigned char *p = (unsigned char *)base + sizeof(u2_eth_packet_t); - + // FIXME (p % 4) == 2. Not good. Must watch for unaligned loads. // FIXME iterate over payload, handling more than a single subpacket. - + int opcode = p[0]; unsigned int oplen = p[1]; unsigned int rid = p[2]; @@ -417,8 +417,8 @@ namespace usrp2 { std::cerr << "usrp2: mismatched command reply length (expected: " << buflen << " got: " << oplen << "). " << "op = " << opcode_to_string(opcode) << std::endl; - } - + } + // Copy reply into caller's buffer memcpy(rp->buffer(), p, std::min(oplen, buflen)); rp->notify_completion(); @@ -430,26 +430,26 @@ namespace usrp2 { DEBUG_LOG("l"); return data_handler::RELEASE; } - + data_handler::result usrp2::impl::handle_data_packet(const void *base, size_t len) { u2_eth_samples_t *pkt = (u2_eth_samples_t *)base; d_num_rx_frames++; d_num_rx_bytes += len; - + /* --- FIXME start of fake transport layer handler --- */ if (d_rx_seqno != -1) { int expected_seqno = (d_rx_seqno + 1) & 0xFF; - int seqno = pkt->hdrs.thdr.seqno; - + int seqno = pkt->hdrs.thdr.seqno; + if (seqno != expected_seqno) { ::write(2, "S", 1); // missing sequence number int missing = seqno - expected_seqno; if (missing < 0) missing += 256; - + d_num_rx_overruns++; d_num_rx_missing += missing; } @@ -469,9 +469,9 @@ namespace usrp2 { DEBUG_LOG("!"); return data_handler::RELEASE; // discard packet, no channel handler } - + // Strip off ethernet header and transport header and enqueue the rest - + size_t offset = offsetof(u2_eth_samples_t, hdrs.fixed); if (d_channel_rings[chan]->enqueue(&pkt->hdrs.fixed, len-offset)) { inc_enqueued(); @@ -481,7 +481,7 @@ namespace usrp2 { else { DEBUG_LOG("!"); return data_handler::RELEASE; // discard, no room in channel ring - } + } return data_handler::RELEASE; } } @@ -491,7 +491,7 @@ namespace usrp2 { // Receive // ---------------------------------------------------------------- - bool + bool usrp2::impl::set_rx_gain(double gain) { op_config_rx_v2_cmd cmd; @@ -500,7 +500,7 @@ namespace usrp2 { init_config_rx_v2_cmd(&cmd); cmd.op.valid = htons(CFGV_GAIN); cmd.op.gain = htons(u2_double_to_fxpt_gain(gain)); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -508,7 +508,7 @@ namespace usrp2 { bool success = (ntohx(reply.ok) == 1); return success; } - + bool usrp2::impl::set_rx_lo_offset(double frequency) { @@ -527,7 +527,7 @@ namespace usrp2 { cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -547,7 +547,7 @@ namespace usrp2 { u2_fxpt_freq_t fxpt = u2_double_to_fxpt_freq(frequency); cmd.op.freq_hi = htonl(u2_fxpt_freq_hi(fxpt)); cmd.op.freq_lo = htonl(u2_fxpt_freq_lo(fxpt)); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -555,18 +555,18 @@ namespace usrp2 { bool success = (ntohx(reply.ok) == 1); if (result && success) { result->baseband_freq = - u2_fxpt_freq_to_double( - u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi), + u2_fxpt_freq_to_double( + u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi), ntohl(reply.baseband_freq_lo))); result->dxc_freq = - u2_fxpt_freq_to_double( - u2_fxpt_freq_from_hilo(ntohl(reply.ddc_freq_hi), + u2_fxpt_freq_to_double( + u2_fxpt_freq_from_hilo(ntohl(reply.ddc_freq_hi), ntohl(reply.ddc_freq_lo))); result->residual_freq = - u2_fxpt_freq_to_double( - u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi), + u2_fxpt_freq_to_double( + u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi), ntohl(reply.residual_freq_lo))); result->spectrum_inverted = (bool)(ntohx(reply.inverted) == 1); @@ -574,7 +574,7 @@ namespace usrp2 { return success; } - + bool usrp2::impl::set_rx_decim(int decimation_factor) { @@ -584,7 +584,7 @@ namespace usrp2 { init_config_rx_v2_cmd(&cmd); cmd.op.valid = htons(CFGV_INTERP_DECIM); cmd.op.decim = htonl(decimation_factor); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -594,7 +594,7 @@ namespace usrp2 { d_rx_decim = decimation_factor; return success; } - + bool usrp2::impl::set_rx_scale_iq(int scale_i, int scale_q) { @@ -604,7 +604,7 @@ namespace usrp2 { init_config_rx_v2_cmd(&cmd); cmd.op.valid = htons(CFGV_SCALE_IQ); cmd.op.scale_iq = htonl(((scale_i & 0xffff) << 16) | (scale_q & 0xffff)); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -612,7 +612,7 @@ namespace usrp2 { bool success = (ntohx(reply.ok) == 1); return success; } - + bool usrp2::impl::start_rx_streaming(unsigned int channel, unsigned int items_per_frame) { @@ -635,10 +635,10 @@ namespace usrp2 { << " already streaming" << std::endl; return false; } - + if (items_per_frame == 0) items_per_frame = U2_MAX_SAMPLES; // minimize overhead - + op_start_rx_streaming_cmd cmd; op_generic_t reply; @@ -650,13 +650,13 @@ namespace usrp2 { cmd.op.items_per_frame = htonl(items_per_frame); cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + d_dont_enqueue = false; bool success = false; pending_reply p(cmd.op.rid, &reply, sizeof(reply)); success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT); success = success && (ntohx(reply.ok) == 1); - + if (success) d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames())); else @@ -666,7 +666,111 @@ namespace usrp2 { return success; } } - + + bool + usrp2::impl::start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time) + { + if (channel > MAX_CHAN) { + std::cerr << "usrp2: invalid channel number (" << channel + << ")" << std::endl; + return false; + } + + if (channel > 0) { // until firmware supports multiple streams + std::cerr << "usrp2: channel " << channel + << " not implemented" << std::endl; + return false; + } + + { + omni_mutex_lock l(d_channel_rings_mutex); + if (d_channel_rings[channel]) { + std::cerr << "usrp2: channel " << channel + << " already streaming" << std::endl; + return false; + } + + if (items_per_frame == 0) + items_per_frame = U2_MAX_SAMPLES; // minimize overhead + + op_start_rx_streaming_cmd cmd; + op_generic_t reply; + + memset(&cmd, 0, sizeof(cmd)); + init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, time); + cmd.op.opcode = OP_START_RX_STREAMING; + cmd.op.len = sizeof(cmd.op); + cmd.op.rid = d_next_rid++; + cmd.op.items_per_frame = htonl(items_per_frame); + cmd.eop.opcode = OP_EOP; + cmd.eop.len = sizeof(cmd.eop); + + bool success = false; + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); + success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT); + success = success && (ntohx(reply.ok) == 1); + + if (success) + d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames())); + + return success; + } + } + + bool + usrp2::impl::sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time) + { + + if (channel > MAX_CHAN) { + std::cerr << "usrp2: invalid channel number (" << channel + << ")" << std::endl; + return false; + } + + if (channel > 0) { // until firmware supports multiple streams + std::cerr << "usrp2: channel " << channel + << " not implemented" << std::endl; + return false; + } + + { + omni_mutex_lock l(d_channel_rings_mutex); + if (d_channel_rings[channel]) { + std::cerr << "usrp2: channel " << channel + << " already streaming" << std::endl; + return false; + } + + if (items_per_frame == 0) + items_per_frame = U2_MAX_SAMPLES; // minimize overhead + + op_sync_and_start_rx_streaming_cmd cmd; + op_generic_t reply; + + memset(&cmd, 0, sizeof(cmd)); + init_etf_hdrs(&cmd.h, d_addr, 0, CONTROL_CHAN, time); + cmd.sync_op.opcode = OP_SYNC_TO_PPS; + cmd.sync_op.len = sizeof(cmd.sync_op); + cmd.sync_op.rid = d_next_rid++; + cmd.rx_op.opcode = OP_START_RX_STREAMING; + cmd.rx_op.len = sizeof(cmd.rx_op); + cmd.rx_op.rid = d_next_rid++; + cmd.rx_op.items_per_frame = htonl(items_per_frame); + cmd.eop.opcode = OP_EOP; + cmd.eop.len = sizeof(cmd.eop); + + bool success = false; + pending_reply p(cmd.sync_op.rid, &reply, sizeof(reply)); + success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT); + success = success && (ntohx(reply.ok) == 1); + + if (success) + d_channel_rings[channel] = ring_sptr(new ring(d_eth_buf->max_frames())); + + return success; + } + } + bool usrp2::impl::stop_rx_streaming(unsigned int channel) { @@ -698,7 +802,7 @@ namespace usrp2 { cmd.op.rid = d_next_rid++; cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + bool success = false; pending_reply p(cmd.op.rid, &reply, sizeof(reply)); success = transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT); @@ -717,25 +821,25 @@ namespace usrp2 { << " )" << std::endl; return false; } - + if (channel > 0) { std::cerr << "usrp2: channel " << channel << " not implemented" << std::endl; return false; } - + ring_sptr rp = d_channel_rings[channel]; if (!rp){ std::cerr << "usrp2: channel " << channel << " not receiving" << std::endl; return false; } - + // Wait for frames available in channel ring DEBUG_LOG("W"); rp->wait_for_not_empty(); DEBUG_LOG("s"); - + // Iterate through frames and present to user void *p; size_t frame_len_in_bytes; @@ -791,7 +895,7 @@ namespace usrp2 { // Transmit // ---------------------------------------------------------------- - bool + bool usrp2::impl::set_tx_gain(double gain) { op_config_tx_v2_cmd cmd; @@ -800,7 +904,7 @@ namespace usrp2 { init_config_tx_v2_cmd(&cmd); cmd.op.valid = htons(CFGV_GAIN); cmd.op.gain = htons(u2_double_to_fxpt_gain(gain)); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -808,7 +912,7 @@ namespace usrp2 { bool success = (ntohx(reply.ok) == 1); return success; } - + bool usrp2::impl::set_tx_lo_offset(double frequency) { @@ -827,7 +931,7 @@ namespace usrp2 { cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -847,7 +951,7 @@ namespace usrp2 { u2_fxpt_freq_t fxpt = u2_double_to_fxpt_freq(frequency); cmd.op.freq_hi = htonl(u2_fxpt_freq_hi(fxpt)); cmd.op.freq_lo = htonl(u2_fxpt_freq_lo(fxpt)); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -855,18 +959,18 @@ namespace usrp2 { bool success = (ntohx(reply.ok) == 1); if (result && success) { result->baseband_freq = - u2_fxpt_freq_to_double( - u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi), + u2_fxpt_freq_to_double( + u2_fxpt_freq_from_hilo(ntohl(reply.baseband_freq_hi), ntohl(reply.baseband_freq_lo))); result->dxc_freq = - u2_fxpt_freq_to_double( - u2_fxpt_freq_from_hilo(ntohl(reply.duc_freq_hi), + u2_fxpt_freq_to_double( + u2_fxpt_freq_from_hilo(ntohl(reply.duc_freq_hi), ntohl(reply.duc_freq_lo))); result->residual_freq = - u2_fxpt_freq_to_double( - u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi), + u2_fxpt_freq_to_double( + u2_fxpt_freq_from_hilo(ntohl(reply.residual_freq_hi), ntohl(reply.residual_freq_lo))); result->spectrum_inverted = (bool)(ntohx(reply.inverted) == 1); @@ -874,7 +978,7 @@ namespace usrp2 { return success; } - + bool usrp2::impl::set_tx_interp(int interpolation_factor) { @@ -884,7 +988,7 @@ namespace usrp2 { init_config_tx_v2_cmd(&cmd); cmd.op.valid = htons(CFGV_INTERP_DECIM); cmd.op.interp = htonl(interpolation_factor); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -901,7 +1005,7 @@ namespace usrp2 { return success; } - + void usrp2::impl::default_tx_scale_iq(int interpolation_factor, int *scale_i, int *scale_q) { @@ -914,7 +1018,7 @@ namespace usrp2 { // Calculate dsp_core_tx gain absent scale multipliers float gain = (1.65*i*i*i)/(4096*pow(2, ceil(log2(i*i*i)))); - + // Calculate closest multiplier constant to reverse gain int scale = (int)rint(1.0/gain); // fprintf(stderr, "if=%i i=%i gain=%f scale=%i\n", interpolation_factor, i, gain, scale); @@ -935,7 +1039,7 @@ namespace usrp2 { init_config_tx_v2_cmd(&cmd); cmd.op.valid = htons(CFGV_SCALE_IQ); cmd.op.scale_iq = htonl(((scale_i & 0xffff) << 16) | (scale_q & 0xffff)); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1063,7 +1167,7 @@ namespace usrp2 { cmd.op.flags = flags; cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1137,10 +1241,10 @@ namespace usrp2 { dst->dbid = ntohl(src->dbid); dst->freq_min = - u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_min_hi), + u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_min_hi), ntohl(src->freq_min_lo))); dst->freq_max = - u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_max_hi), + u2_fxpt_freq_to_double(u2_fxpt_freq_from_hilo(ntohl(src->freq_max_hi), ntohl(src->freq_max_lo))); dst->gain_min = u2_fxpt_gain_to_double(ntohs(src->gain_min)); @@ -1161,7 +1265,7 @@ namespace usrp2 { cmd.op.rid = d_next_rid++; cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1188,7 +1292,7 @@ namespace usrp2 { cmd.op.rid = d_next_rid++; cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1210,7 +1314,7 @@ namespace usrp2 { cmd.op.ok = enable ? 1 : 0; cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1225,7 +1329,7 @@ namespace usrp2 { // fprintf(stderr, "usrp2::peek: addr=%08X words=%u\n", addr, words); if (addr % 4 != 0) { - fprintf(stderr, "usrp2::peek: addr (=%08X) must be 32-bit word aligned\n", addr); + fprintf(stderr, "usrp2::peek: addr (=%08X) must be 32-bit word aligned\n", addr); return result; } @@ -1267,7 +1371,7 @@ namespace usrp2 { usrp2::impl::poke32(uint32_t addr, const std::vector<uint32_t> &data) { if (addr % 4 != 0) { - fprintf(stderr, "usrp2::poke32: addr (=%08X) must be 32-bit word aligned\n", addr); + fprintf(stderr, "usrp2::poke32: addr (=%08X) must be 32-bit word aligned\n", addr); return false; } @@ -1339,7 +1443,7 @@ namespace usrp2 { cmd.op.rid = d_next_rid++; cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1368,7 +1472,7 @@ namespace usrp2 { cmd.op.mask = htons(mask); cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1401,7 +1505,7 @@ namespace usrp2 { memcpy(&cmd.op.sels, sels.c_str(), 16); cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1430,7 +1534,7 @@ namespace usrp2 { cmd.op.mask = htons(mask); cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1459,7 +1563,7 @@ namespace usrp2 { cmd.op.mask = 0; // not used cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; @@ -1496,7 +1600,7 @@ namespace usrp2 { cmd.op.mask = 0; // not used cmd.eop.opcode = OP_EOP; cmd.eop.len = sizeof(cmd.eop); - + pending_reply p(cmd.op.rid, &reply, sizeof(reply)); if (!transmit_cmd_and_wait(&cmd, sizeof(cmd), &p, DEF_CMD_TIMEOUT)) return false; diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h index ed71a6ba3..d78a00db4 100644 --- a/usrp2/host/lib/usrp2_impl.h +++ b/usrp2/host/lib/usrp2_impl.h @@ -30,7 +30,7 @@ #define MAX_SUBPKT_LEN 252 namespace usrp2 { - + class eth_buffer; class pktfilter; class usrp2_thread; @@ -62,7 +62,7 @@ namespace usrp2 { std::string d_addr; // FIXME: use u2_mac_addr_t instead usrp2_thread *d_bg_thread; volatile bool d_bg_running; // TODO: multistate if needed - + int d_rx_seqno; int d_tx_seqno; int d_next_rid; @@ -84,7 +84,7 @@ namespace usrp2 { db_info d_tx_db_info; db_info d_rx_db_info; - int d_tx_interp; // shadow tx interp + int d_tx_interp; // shadow tx interp int d_rx_decim; // shadow rx decim bool d_dont_enqueue; @@ -93,13 +93,13 @@ namespace usrp2 { omni_mutex_lock l(d_enqueued_mutex); d_num_enqueued++; } - + void dec_enqueued() { omni_mutex_lock l(d_enqueued_mutex); if (--d_num_enqueued == 0) d_bg_pending_cond.signal(); } - + static bool parse_mac_addr(const std::string &s, u2_mac_addr_t *p); void init_et_hdrs(u2_eth_packet_t *p, const std::string &dst); void init_etf_hdrs(u2_eth_packet_t *p, const std::string &dst, @@ -118,7 +118,7 @@ namespace usrp2 { public: impl(const std::string &ifc, props *p, size_t rx_bufsize); ~impl(); - + void bg_loop(); std::string mac_addr() const { return d_addr; } // FIXME: convert from u2_mac_addr_t @@ -143,6 +143,8 @@ namespace usrp2 { bool write_gpio(int bank, uint16_t value, uint16_t mask); bool read_gpio(int bank, uint16_t *value); bool start_rx_streaming(unsigned int channel, unsigned int items_per_frame); + bool start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time); + bool sync_and_start_rx_streaming_at(unsigned int channel, unsigned int items_per_frame, unsigned int time); bool rx_samples(unsigned int channel, rx_sample_handler *handler); bool flush_rx_samples(unsigned int channel); bool stop_rx_streaming(unsigned int channel); @@ -196,7 +198,7 @@ namespace usrp2 { std::vector<uint32_t> peek32(uint32_t addr, uint32_t words); bool poke32(uint32_t addr, const std::vector<uint32_t> &data); }; - + } // namespace usrp2 #endif /* INCLUDED_USRP2_IMPL_H */ diff --git a/vrt/lib/copiers.cc b/vrt/lib/copiers.cc index aa2846af5..ddf82abcf 100644 --- a/vrt/lib/copiers.cc +++ b/vrt/lib/copiers.cc @@ -24,6 +24,8 @@ #endif #include <vrt/copiers.h> #include <arpa/inet.h> +#include <assert.h> +#include <string.h> namespace vrt { diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc index 0eb2042d8..bd1d92e53 100644 --- a/vrt/lib/expanded_header.cc +++ b/vrt/lib/expanded_header.cc @@ -112,12 +112,6 @@ namespace vrt { #include "expanded_header_switch_body.h" } - /* is this a if context packet? */ - if (h->if_context_p()){ - *payload = p; - *n32_bit_words_payload = n32_bit_words_packet; - } - return true; } diff --git a/vrt/lib/rx.cc b/vrt/lib/rx.cc index f75db3111..2d741e908 100644 --- a/vrt/lib/rx.cc +++ b/vrt/lib/rx.cc @@ -30,7 +30,7 @@ #include <stdexcept> static void -print_words(FILE *fp, size_t offset, uint32_t *buf, size_t n) +print_words(FILE *fp, size_t offset, const uint32_t *buf, size_t n) { size_t i; for (i = 0; i < n; i++){ @@ -85,27 +85,31 @@ namespace vrt { vrt_data_handler::~vrt_data_handler(){} + // N.B., There may be more than 1 VRT packet in a frame (usually IF-Context packets) data_handler::result vrt_data_handler::operator()(const void *base, size_t len) { -#if 0 - print_words(0, (uint32_t *)base, len/(sizeof(uint32_t))); - return 0; -#else - const uint32_t *payload; - size_t n32_bit_words; - expanded_header hdr; - if (!expanded_header::parse((const uint32_t*) base, len/(sizeof(uint32_t)), - &hdr, &payload, &n32_bit_words)){ - if (1){ - fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n"); - print_words(stderr, 0, (uint32_t *)base, len/(sizeof(uint32_t))); + const uint32_t *word_base = (const uint32_t *) base; + size_t word_len = len/(sizeof(uint32_t)); + + bool want_more = true; + while (word_len > 0 && want_more){ + const uint32_t *payload; + size_t n32_bit_words; + expanded_header hdr; + if (!expanded_header::parse(word_base, word_len, + &hdr, &payload, &n32_bit_words)){ + if (1){ + fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n"); + print_words(stderr, 0, word_base, word_len); + } + return 0; } - return 0; + want_more = (*d_handler)(payload, n32_bit_words, &hdr); + word_base += hdr.pkt_size(); + word_len -= hdr.pkt_size(); } - bool want_more = (*d_handler)(payload, n32_bit_words, &hdr); return !want_more ? data_handler::DONE : 0; -#endif } |