diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2015-04-04 10:14:00 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2015-04-04 10:14:00 -0700 |
commit | 0e4f02cfee57c73712a8bb21b408d69d9fcfe1b9 (patch) | |
tree | 6580c74a77c5667f1825bc597d363a2fefbf9c7a | |
parent | 83ded122ba7c0db8c3cd113c9e7c2814937775ca (diff) | |
parent | e16f9489d71720e8a9d9ec37ced0c033a99c87aa (diff) |
Merge branch 'master' into next
-rw-r--r-- | gnuradio-runtime/include/gnuradio/basic_block.h | 1 | ||||
-rw-r--r-- | gnuradio-runtime/lib/top_block_impl.cc | 23 | ||||
-rw-r--r-- | gnuradio-runtime/lib/top_block_impl.h | 2 | ||||
-rw-r--r-- | gnuradio-runtime/python/gnuradio/gr/top_block.py | 8 | ||||
-rw-r--r-- | gnuradio-runtime/swig/top_block.i | 8 | ||||
-rw-r--r-- | gr-blocks/grc/blocks_repack_bits_bb.xml | 3 | ||||
-rw-r--r-- | gr-blocks/lib/pdu_to_tagged_stream_impl.cc | 18 | ||||
-rw-r--r-- | gr-blocks/lib/repack_bits_bb_impl.cc | 6 | ||||
-rw-r--r-- | gr-blocks/lib/tagged_stream_mux_impl.cc | 25 | ||||
-rwxr-xr-x | gr-blocks/python/blocks/qa_hier_block2.py | 16 | ||||
-rwxr-xr-x | gr-digital/examples/ofdm/tunnel.py | 11 | ||||
-rw-r--r-- | gr-digital/include/gnuradio/digital/correlate_and_sync_cc.h | 11 | ||||
-rw-r--r-- | gr-digital/include/gnuradio/digital/packet_header_default.h | 38 | ||||
-rwxr-xr-x | gr-qtgui/python/qtgui/range.py | 8 |
14 files changed, 114 insertions, 64 deletions
diff --git a/gnuradio-runtime/include/gnuradio/basic_block.h b/gnuradio-runtime/include/gnuradio/basic_block.h index b687a8f971..2ad507894b 100644 --- a/gnuradio-runtime/include/gnuradio/basic_block.h +++ b/gnuradio-runtime/include/gnuradio/basic_block.h @@ -61,7 +61,6 @@ namespace gr { typedef boost::function<void(pmt::pmt_t)> msg_handler_t; private: - //msg_handler_t d_msg_handler; typedef std::map<pmt::pmt_t , msg_handler_t, pmt::comparator> d_msg_handlers_t; d_msg_handlers_t d_msg_handlers; diff --git a/gnuradio-runtime/lib/top_block_impl.cc b/gnuradio-runtime/lib/top_block_impl.cc index b7322c8e2a..48404a6832 100644 --- a/gnuradio-runtime/lib/top_block_impl.cc +++ b/gnuradio-runtime/lib/top_block_impl.cc @@ -86,6 +86,9 @@ namespace gr { top_block_impl::~top_block_impl() { + if (d_lock_count) { + std::cerr << "error: destroying locked block." << std::endl; + } d_owner = 0; } @@ -129,6 +132,21 @@ namespace gr { void top_block_impl::wait() { + do { + wait_for_jobs(); + { + gr::thread::scoped_lock lock(d_mutex); + if (!d_lock_count) { + break; + } + d_lock_cond.wait(lock); + } + } while(true); + } + + void + top_block_impl::wait_for_jobs() + { if(d_scheduler) d_scheduler->wait(); @@ -141,6 +159,7 @@ namespace gr { top_block_impl::lock() { gr::thread::scoped_lock lock(d_mutex); + stop(); d_lock_count++; } @@ -158,6 +177,7 @@ namespace gr { if(d_lock_count > 0 || d_state == IDLE) // nothing to do return; + d_lock_cond.notify_all(); restart(); } @@ -167,8 +187,7 @@ namespace gr { void top_block_impl::restart() { - stop(); // Stop scheduler and wait for completion - wait(); + wait_for_jobs(); // Create new simple flow graph flat_flowgraph_sptr new_ffg = d_owner->flatten(); diff --git a/gnuradio-runtime/lib/top_block_impl.h b/gnuradio-runtime/lib/top_block_impl.h index 67395e0c35..1ac5136ddf 100644 --- a/gnuradio-runtime/lib/top_block_impl.h +++ b/gnuradio-runtime/lib/top_block_impl.h @@ -82,10 +82,12 @@ namespace gr { gr::thread::mutex d_mutex; // protects d_state and d_lock_count tb_state d_state; int d_lock_count; + boost::condition_variable d_lock_cond; int d_max_noutput_items; private: void restart(); + void wait_for_jobs(); }; } /* namespace gr */ diff --git a/gnuradio-runtime/python/gnuradio/gr/top_block.py b/gnuradio-runtime/python/gnuradio/gr/top_block.py index f9872fc114..f449d98489 100644 --- a/gnuradio-runtime/python/gnuradio/gr/top_block.py +++ b/gnuradio-runtime/python/gnuradio/gr/top_block.py @@ -22,7 +22,7 @@ from runtime_swig import top_block_swig, \ top_block_wait_unlocked, top_block_run_unlocked, \ top_block_start_unlocked, top_block_stop_unlocked, \ - dot_graph_tb + top_block_unlock_unlocked, dot_graph_tb #import gnuradio.gr.gr_threading as _threading import gr_threading as _threading @@ -118,6 +118,12 @@ class top_block(hier_block2): self.start(max_noutput_items) self.wait() + def unlock(self): + """ + Release lock and continue execution of flow-graph. + """ + top_block_unlock_unlocked(self._impl) + def wait(self): """ Wait for the flowgraph to finish running diff --git a/gnuradio-runtime/swig/top_block.i b/gnuradio-runtime/swig/top_block.i index 60c9e1a232..c7ee0af941 100644 --- a/gnuradio-runtime/swig/top_block.i +++ b/gnuradio-runtime/swig/top_block.i @@ -89,6 +89,14 @@ void top_block_stop_unlocked(gr::top_block_sptr r) throw (std::runtime_error) ) } +void top_block_unlock_unlocked(gr::top_block_sptr r) throw (std::runtime_error) +{ + GR_PYTHON_BLOCKING_CODE + ( + r->unlock(); + ) +} + std::string dot_graph_tb(gr::top_block_sptr r) { diff --git a/gr-blocks/grc/blocks_repack_bits_bb.xml b/gr-blocks/grc/blocks_repack_bits_bb.xml index 3554e30f11..0c107d8439 100644 --- a/gr-blocks/grc/blocks_repack_bits_bb.xml +++ b/gr-blocks/grc/blocks_repack_bits_bb.xml @@ -42,7 +42,6 @@ </option> </param> - <param> <name>Endianness</name> <key>endianness</key> @@ -51,7 +50,7 @@ <hide>part</hide> <option> <name>MSB</name> - <key>gr.GR_MSB_FIRST</key> + <key>gr.GR_MSB_FIRST</key> </option> <option> <name>LSB</name> diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc index e0da2e5022..3a2b50efe1 100644 --- a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc +++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc @@ -39,12 +39,12 @@ namespace gr { pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type, const std::string& tsb_tag_key) : tagged_stream_block("pdu_to_tagged_stream", - io_signature::make(0, 0, 0), - io_signature::make(1, 1, pdu::itemsize(type)), - tsb_tag_key), - d_itemsize(pdu::itemsize(type)), - d_type(type), - d_curr_len(0) + io_signature::make(0, 0, 0), + io_signature::make(1, 1, pdu::itemsize(type)), + tsb_tag_key), + d_itemsize(pdu::itemsize(type)), + d_type(type), + d_curr_len(0) { message_port_register_in(PDU_PORT_ID); } @@ -73,9 +73,9 @@ namespace gr { int pdu_to_tagged_stream_impl::work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { uint8_t *out = (uint8_t*) output_items[0]; diff --git a/gr-blocks/lib/repack_bits_bb_impl.cc b/gr-blocks/lib/repack_bits_bb_impl.cc index 947a3c23ce..c20c99786a 100644 --- a/gr-blocks/lib/repack_bits_bb_impl.cc +++ b/gr-blocks/lib/repack_bits_bb_impl.cc @@ -84,9 +84,9 @@ namespace gr { int repack_bits_bb_impl::work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { gr::thread::scoped_lock guard(d_setlock); const unsigned char *in = (const unsigned char *) input_items[0]; diff --git a/gr-blocks/lib/tagged_stream_mux_impl.cc b/gr-blocks/lib/tagged_stream_mux_impl.cc index c49c14c36e..ac2d1c2203 100644 --- a/gr-blocks/lib/tagged_stream_mux_impl.cc +++ b/gr-blocks/lib/tagged_stream_mux_impl.cc @@ -31,16 +31,20 @@ namespace gr { namespace blocks { tagged_stream_mux::sptr - tagged_stream_mux::make(size_t itemsize, const std::string &lengthtagname, unsigned int tag_preserve_head_pos) + tagged_stream_mux::make(size_t itemsize, const std::string &lengthtagname, + unsigned int tag_preserve_head_pos) { - return gnuradio::get_initial_sptr (new tagged_stream_mux_impl(itemsize, lengthtagname, tag_preserve_head_pos)); + return gnuradio::get_initial_sptr + (new tagged_stream_mux_impl(itemsize, lengthtagname, + tag_preserve_head_pos)); } - tagged_stream_mux_impl::tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname, unsigned int tag_preserve_head_pos) + tagged_stream_mux_impl::tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname, + unsigned int tag_preserve_head_pos) : tagged_stream_block("tagged_stream_mux", - io_signature::make(1, -1, itemsize), - io_signature::make(1, 1, itemsize), - lengthtagname), + io_signature::make(1, -1, itemsize), + io_signature::make(1, 1, itemsize), + lengthtagname), d_itemsize(itemsize), d_tag_preserve_head_pos(tag_preserve_head_pos) { @@ -62,10 +66,10 @@ namespace gr { } int - tagged_stream_mux_impl::work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + tagged_stream_mux_impl::work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { unsigned char *out = (unsigned char *) output_items[0]; int n_produced = 0; @@ -94,4 +98,3 @@ namespace gr { } /* namespace blocks */ } /* namespace gr */ - diff --git a/gr-blocks/python/blocks/qa_hier_block2.py b/gr-blocks/python/blocks/qa_hier_block2.py index 5a351f2b37..97206a248d 100755 --- a/gr-blocks/python/blocks/qa_hier_block2.py +++ b/gr-blocks/python/blocks/qa_hier_block2.py @@ -2,6 +2,7 @@ from gnuradio import gr, gr_unittest, blocks import numpy +import time class add_ff(gr.sync_block): def __init__(self): @@ -426,5 +427,20 @@ class test_hier_block2(gr_unittest.TestCase): procs = hblock.processor_affinity() self.assertEquals((0,), procs) + def test_lock_unlock(self): + hblock = gr.top_block("test_block") + src = blocks.null_source(gr.sizeof_float) + throttle = blocks.throttle(gr.sizeof_float, 32000) + hier = multiply_const_ff(0.5) + sink = blocks.null_sink(gr.sizeof_float) + hblock.connect(src, throttle, hier, sink) + hblock.set_processor_affinity([0,]) + hblock.start() + time.sleep(1) + hblock.lock() + hblock.unlock() + hblock.stop() + hblock.wait() + if __name__ == "__main__": gr_unittest.run(test_hier_block2, "test_hier_block2.xml") diff --git a/gr-digital/examples/ofdm/tunnel.py b/gr-digital/examples/ofdm/tunnel.py index f407aef8d6..17b31db9af 100755 --- a/gr-digital/examples/ofdm/tunnel.py +++ b/gr-digital/examples/ofdm/tunnel.py @@ -89,15 +89,16 @@ class my_top_block(gr.top_block): self.source = uhd_receiver(options.args, options.bandwidth, - options.rx_freq, options.rx_gain, + options.rx_freq, + options.lo_offset, options.rx_gain, options.spec, options.antenna, - options.verbose) + options.clock_source, options.verbose) self.sink = uhd_transmitter(options.args, - options.bandwidth, - options.tx_freq, options.tx_gain, + options.bandwidth, options.tx_freq, + options.lo_offset, options.tx_gain, options.spec, options.antenna, - options.verbose) + options.clock_source, options.verbose) self.txpath = transmit_path(options) self.rxpath = receive_path(callback, options) diff --git a/gr-digital/include/gnuradio/digital/correlate_and_sync_cc.h b/gr-digital/include/gnuradio/digital/correlate_and_sync_cc.h index c84357f713..704b86662a 100644 --- a/gr-digital/include/gnuradio/digital/correlate_and_sync_cc.h +++ b/gr-digital/include/gnuradio/digital/correlate_and_sync_cc.h @@ -1,19 +1,19 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 Free Software Foundation, Inc. - * + * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. - * + * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -88,4 +88,3 @@ namespace gr { } // namespace gr #endif /* INCLUDED_DIGITAL_CORRELATE_AND_SYNC_CC_H */ - diff --git a/gr-digital/include/gnuradio/digital/packet_header_default.h b/gr-digital/include/gnuradio/digital/packet_header_default.h index 6567dd7626..9ffb3d047b 100644 --- a/gr-digital/include/gnuradio/digital/packet_header_default.h +++ b/gr-digital/include/gnuradio/digital/packet_header_default.h @@ -1,18 +1,18 @@ /* -*- c++ -*- */ /* Copyright 2012 Free Software Foundation, Inc. - * + * * This file is part of GNU Radio - * + * * GNU Radio is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. - * + * * GNU Radio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with GNU Radio; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -46,16 +46,16 @@ namespace gr { * gr::digital::packet_headergenerator_bb uses header generators derived from * this class to create packet headers from data streams. */ - class DIGITAL_API packet_header_default : public boost::enable_shared_from_this<gr::digital::packet_header_default> + class DIGITAL_API packet_header_default + : public boost::enable_shared_from_this<gr::digital::packet_header_default> { public: typedef boost::shared_ptr<packet_header_default> sptr; - packet_header_default( - long header_len, - const std::string &len_tag_key="packet_len", - const std::string &num_tag_key="packet_num", - int bits_per_byte=1); + packet_header_default(long header_len, + const std::string &len_tag_key="packet_len", + const std::string &num_tag_key="packet_num", + int bits_per_byte=1); virtual ~packet_header_default(); sptr base() { return shared_from_this(); }; @@ -80,11 +80,9 @@ namespace gr { * However, it is recommended to stay above 32 Bits, in order to have a working * CRC. */ - virtual bool header_formatter( - long packet_len, - unsigned char *out, - const std::vector<tag_t> &tags=std::vector<tag_t>() - ); + virtual bool header_formatter(long packet_len, + unsigned char *out, + const std::vector<tag_t> &tags=std::vector<tag_t>()); /*! * \brief Inverse function to header_formatter(). @@ -95,11 +93,10 @@ namespace gr { const unsigned char *header, std::vector<tag_t> &tags); - static sptr make( - long header_len, - const std::string &len_tag_key="packet_len", - const std::string &num_tag_key="packet_num", - int bits_per_byte=1); + static sptr make(long header_len, + const std::string &len_tag_key="packet_len", + const std::string &num_tag_key="packet_num", + int bits_per_byte=1); protected: long d_header_len; @@ -115,4 +112,3 @@ namespace gr { } // namespace gr #endif /* INCLUDED_DIGITAL_PACKET_HEADER_DEFAULT_H */ - diff --git a/gr-qtgui/python/qtgui/range.py b/gr-qtgui/python/qtgui/range.py index 566170dde4..8347963f6f 100755 --- a/gr-qtgui/python/qtgui/range.py +++ b/gr-qtgui/python/qtgui/range.py @@ -90,9 +90,10 @@ class RangeWidget(QtGui.QWidget): QtGui.QDial.__init__(self, parent) self.setRange(0, ranges.ds_steps-1) self.setSingleStep(ranges.step) + self.setNotchTarget(1) self.setNotchesVisible(True) - self.setNotchTarget(ranges.step) - self.setValue(ranges.default) + temp = [abs(x-ranges.default) for x in ranges.ds_vals] + self.setValue(temp.index(min(temp))) self.valueChanged.connect(slot) class Slider(QtGui.QSlider): @@ -101,7 +102,8 @@ class RangeWidget(QtGui.QWidget): QtGui.QSlider.__init__(self, QtCore.Qt.Horizontal, parent) self.setFocusPolicy(QtCore.Qt.NoFocus) self.setRange(0, ranges.ds_steps-1) - self.setValue(ranges.default) + temp = [abs(x-ranges.default) for x in ranges.ds_vals] + self.setValue(temp.index(min(temp))) self.setPageStep(1) self.setSingleStep(1) self.setTickPosition(2) |