From metro4 at freemail.hu Mon Oct 19 19:27:10 2020 From: metro4 at freemail.hu (Csaba Sipos) Date: Mon, 19 Oct 2020 19:27:10 +0000 (GMT) Subject: [PATCH] add xtrx support Message-ID: Dear Maintainers, The attached patch adds XTRX SDR support to Gr-Osmosdr. It mostly contains the out-of tree patches added in the libxtrx branch here: https://github.com/xtrx-sdr/gr-osmosdr , also the patches upstreamed to be compatible with Gnu-Radio 3.8 and the latest master branch of gr-osmosdr. It compiles and works fine with Gnu-Radio 3.8 and Gr-Osmosdr master (tested on Ubuntu 20.04.01 LTS 64bit). Hopefully I will have time to test it against other Osmocom projects in the near future. Please let me know if the patch needs any modifications or further work. Regards, Csaba -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-add-xtrx-support.patch Type: application/octet-stream Size: 52859 bytes Desc: not available URL: From argilo at gmail.com Fri Oct 23 01:36:24 2020 From: argilo at gmail.com (argilo at gmail.com) Date: Thu, 22 Oct 2020 21:36:24 -0400 Subject: [PATCH] Replace BOOST_FOREACH with range-based for loops Message-ID: <20201023013624.1685251-1-argilo@gmail.com> From: Clayton Smith Range-based for loops are available since C++11. Using them reduces gr-osmosdr's dependence on Boost. Here I've done the replacement using a global search-and-replace. --- lib/arg_helpers.h | 13 ++-- lib/bladerf/bladerf_common.cc | 9 ++- lib/bladerf/bladerf_sink_c.cc | 4 +- lib/bladerf/bladerf_source_c.cc | 4 +- lib/device.cc | 39 ++++++------ lib/fcd/fcd_source_c.cc | 3 +- lib/ranges.cc | 13 ++-- lib/rfspace/rfspace_source_c.cc | 4 +- lib/sink_impl.cc | 82 ++++++++++++------------ lib/soapy/soapy_sink_c.cc | 12 ++-- lib/soapy/soapy_source_c.cc | 12 ++-- lib/source_impl.cc | 108 ++++++++++++++++---------------- lib/uhd/uhd_sink_c.cc | 15 +++-- lib/uhd/uhd_source_c.cc | 15 +++-- 14 files changed, 163 insertions(+), 170 deletions(-) diff --git a/lib/arg_helpers.h b/lib/arg_helpers.h index b971625774..3b02b8ffb2 100644 --- a/lib/arg_helpers.h +++ b/lib/arg_helpers.h @@ -29,7 +29,6 @@ #include #include -#include #include typedef std::map< std::string, std::string > dict_t; @@ -38,7 +37,7 @@ typedef std::pair< std::string, std::string > pair_t; inline std::string dict_to_args_string( const dict_t &d ) { std::string out; - BOOST_FOREACH(const pair_t pair, d) + for (const pair_t pair : d) { if (not out.empty()) out += ","; out += pair.first + "='" + pair.second + "'"; @@ -54,7 +53,7 @@ inline std::vector< std::string > args_to_vector( const std::string &args ) typedef boost::tokenizer< boost::escaped_list_separator > tokenizer_t; tokenizer_t tokens(args, separator); - BOOST_FOREACH(std::string token, tokens) + for (std::string token : tokens) result.push_back(token); return result; @@ -68,7 +67,7 @@ inline std::vector< std::string > params_to_vector( const std::string ¶ms ) typedef boost::tokenizer< boost::escaped_list_separator > tokenizer_t; tokenizer_t tokens(params, separator); - BOOST_FOREACH(std::string token, tokens) + for (std::string token : tokens) result.push_back(token); return result; @@ -98,7 +97,7 @@ inline dict_t params_to_dict( const std::string ¶ms ) dict_t result; std::vector< std::string > param_list = params_to_vector( params ); - BOOST_FOREACH(std::string param, param_list) + for (std::string param : param_list) { pair_t pair = param_to_pair( param ); std::string value = pair.second; @@ -124,7 +123,7 @@ inline gr::io_signature::sptr args_to_io_signature( const std::string &args ) size_t dev_nchan = 0; std::vector< std::string > arg_list = args_to_vector( args ); - BOOST_FOREACH( std::string arg, arg_list ) + for (std::string arg : arg_list) { if ( arg.find( "numchan=" ) == 0 ) // try to parse global nchan value { @@ -141,7 +140,7 @@ inline gr::io_signature::sptr args_to_io_signature( const std::string &args ) // try to parse device specific nchan values, assume 1 channel if none given - BOOST_FOREACH( std::string arg, arg_list ) + for (std::string arg : arg_list) { dict_t dict = params_to_dict(arg); if (dict.count("nchan")) diff --git a/lib/bladerf/bladerf_common.cc b/lib/bladerf/bladerf_common.cc index 19b8a021a0..67bf736744 100644 --- a/lib/bladerf/bladerf_common.cc +++ b/lib/bladerf/bladerf_common.cc @@ -35,7 +35,6 @@ #include #include -#include #include #include @@ -498,7 +497,7 @@ int bladerf_common::channel2rfport(bladerf_channel ch) bladerf_channel bladerf_common::chan2channel(bladerf_direction direction, size_t chan) { - BOOST_FOREACH(bladerf_channel_map::value_type &i, _chanmap) { + for (bladerf_channel_map::value_type &i : _chanmap) { bladerf_channel ch = i.first; if ( (i.second == (int)chan) && ( @@ -642,7 +641,7 @@ osmosdr::freq_range_t bladerf_common::filter_bandwidths(bladerf_channel ch) 0.75, 0.875, 1.25, 1.375, 1.5, 1.92, 2.5, 2.75, 3, 3.5, 4.375, 5, 6, 7, 10, 14; - BOOST_FOREACH( double half_bw, half_bandwidths ) + for (double half_bw : half_bandwidths) bandwidths += osmosdr::range_t( half_bw * 2e6 ); #else @@ -1136,7 +1135,7 @@ bladerf_sptr bladerf_common::get_cached_device(struct bladerf_devinfo devinfo) int status; struct bladerf_devinfo other_devinfo; - BOOST_FOREACH(std::weak_ptr dev, _devs) { + for (std::weak_ptr dev : _devs) { status = bladerf_get_devinfo(bladerf_sptr(dev).get(), &other_devinfo); if (status < 0) { BLADERF_THROW_STATUS(status, "Failed to get devinfo for cached device"); @@ -1199,7 +1198,7 @@ void bladerf_common::print_device_info() bool bladerf_common::is_antenna_valid(bladerf_direction dir, const std::string &antenna) { - BOOST_FOREACH(std::string ant, get_antennas(dir)) { + for (std::string ant : get_antennas(dir)) { if (antenna == ant) { return true; } diff --git a/lib/bladerf/bladerf_sink_c.cc b/lib/bladerf/bladerf_sink_c.cc index fe64439d7b..6ee3acd927 100644 --- a/lib/bladerf/bladerf_sink_c.cc +++ b/lib/bladerf/bladerf_sink_c.cc @@ -96,7 +96,7 @@ bladerf_sink_c::bladerf_sink_c(const std::string &args) : } /* Initialize channel <-> antenna map */ - BOOST_FOREACH(std::string ant, get_antennas()) { + for (std::string ant : get_antennas()) { _chanmap[str2channel(ant)] = -1; } @@ -329,7 +329,7 @@ int bladerf_sink_c::transmit_with_tags(int16_t const *samples, } } - BOOST_FOREACH(gr::tag_t tag, tags) { + for (gr::tag_t tag : tags) { // Upon seeing an SOB tag, update our offset. We'll TX the start of the // burst when we see an EOB or at the end of this function - whichever // occurs first. diff --git a/lib/bladerf/bladerf_source_c.cc b/lib/bladerf/bladerf_source_c.cc index 2ac5779f2a..83db677a10 100644 --- a/lib/bladerf/bladerf_source_c.cc +++ b/lib/bladerf/bladerf_source_c.cc @@ -144,7 +144,7 @@ bladerf_source_c::bladerf_source_c(const std::string &args) : } /* Initialize channel <-> antenna map */ - BOOST_FOREACH(std::string ant, get_antennas()) { + for (std::string ant : get_antennas()) { _chanmap[str2channel(ant)] = -1; } @@ -180,7 +180,7 @@ bladerf_source_c::bladerf_source_c(const std::string &args) : bool bladerf_source_c::is_antenna_valid(const std::string &antenna) { - BOOST_FOREACH(std::string ant, get_antennas()) { + for (std::string ant : get_antennas()) { if (antenna == ant) { return true; } diff --git a/lib/device.cc b/lib/device.cc index 015383dbd4..17efde9896 100644 --- a/lib/device.cc +++ b/lib/device.cc @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -108,7 +107,7 @@ device_t::device_t(const std::string &args) { dict_t dict = params_to_dict(args); - BOOST_FOREACH( dict_t::value_type &entry, dict ) + for (dict_t::value_type &entry : dict) (*this)[entry.first] = entry.second; } @@ -118,7 +117,7 @@ std::string device_t::to_pp_string(void) const std::stringstream ss; ss << "Device Address:" << std::endl; - BOOST_FOREACH(const device_t::value_type &entry, *this) { + for (const device_t::value_type &entry : *this) { ss << boost::format(" %s: %s") % entry.first % entry.second << std::endl; } return ss.str(); @@ -128,7 +127,7 @@ std::string device_t::to_string(void) const { std::stringstream ss; size_t count = 0; - BOOST_FOREACH(const device_t::value_type &entry, *this) { + for (const device_t::value_type &entry : *this) { std::string value = entry.second; if (value.find(" ") != std::string::npos) value = "'" + value + "'"; @@ -151,55 +150,55 @@ devices_t device::find(const device_t &hint) devices_t devices; #ifdef ENABLE_OSMOSDR - BOOST_FOREACH( std::string dev, osmosdr_src_c::get_devices() ) + for (std::string dev : osmosdr_src_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_FCD - BOOST_FOREACH( std::string dev, fcd_source_c::get_devices() ) + for (std::string dev : fcd_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_RTL - BOOST_FOREACH( std::string dev, rtl_source_c::get_devices() ) + for (std::string dev : rtl_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_UHD - BOOST_FOREACH( std::string dev, uhd_source_c::get_devices() ) + for (std::string dev : uhd_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_MIRI - BOOST_FOREACH( std::string dev, miri_source_c::get_devices() ) + for (std::string dev : miri_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_SDRPLAY - BOOST_FOREACH( std::string dev, sdrplay_source_c::get_devices() ) + for (std::string dev : sdrplay_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_BLADERF - BOOST_FOREACH( std::string dev, bladerf_source_c::get_devices() ) + for (std::string dev : bladerf_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_HACKRF - BOOST_FOREACH( std::string dev, hackrf_source_c::get_devices() ) + for (std::string dev : hackrf_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_RFSPACE - BOOST_FOREACH( std::string dev, rfspace_source_c::get_devices( fake ) ) + for (std::string dev : rfspace_source_c::get_devices( fake )) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_AIRSPY - BOOST_FOREACH( std::string dev, airspy_source_c::get_devices() ) + for (std::string dev : airspy_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_AIRSPYHF - BOOST_FOREACH( std::string dev, airspyhf_source_c::get_devices() ) + for (std::string dev : airspyhf_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_FREESRP - BOOST_FOREACH( std::string dev, freesrp_source_c::get_devices() ) + for (std::string dev : freesrp_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_SOAPY - BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() ) + for (std::string dev : soapy_source_c::get_devices()) devices.push_back( device_t(dev) ); #endif @@ -208,15 +207,15 @@ devices_t device::find(const device_t &hint) * in a graphical interface etc... */ #ifdef ENABLE_RTL_TCP - BOOST_FOREACH( std::string dev, rtl_tcp_source_c::get_devices( fake ) ) + for (std::string dev : rtl_tcp_source_c::get_devices( fake )) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_REDPITAYA - BOOST_FOREACH( std::string dev, redpitaya_source_c::get_devices( fake ) ) + for (std::string dev : redpitaya_source_c::get_devices( fake )) devices.push_back( device_t(dev) ); #endif #ifdef ENABLE_FILE - BOOST_FOREACH( std::string dev, file_source_c::get_devices( fake ) ) + for (std::string dev : file_source_c::get_devices( fake )) devices.push_back( device_t(dev) ); #endif diff --git a/lib/fcd/fcd_source_c.cc b/lib/fcd/fcd_source_c.cc index 744fa69553..854e4c0e04 100644 --- a/lib/fcd/fcd_source_c.cc +++ b/lib/fcd/fcd_source_c.cc @@ -23,7 +23,6 @@ #include #include -#include #include @@ -171,7 +170,7 @@ std::vector< std::string > fcd_source_c::get_devices() int id = 0; std::vector< std::string > devices; - BOOST_FOREACH( device_t dev, _get_devices() ) + for (device_t dev : _get_devices()) { std::string args = "fcd=" + boost::lexical_cast< std::string >( id++ ); diff --git a/lib/ranges.cc b/lib/ranges.cc index cdff96911a..09c1daedf5 100644 --- a/lib/ranges.cc +++ b/lib/ranges.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -102,7 +101,7 @@ meta_range_t::meta_range_t( double meta_range_t::start(void) const{ check_meta_range_monotonic(*this); double min_start = this->front().start(); - BOOST_FOREACH(const range_t &r, (*this)){ + for (const range_t &r : (*this)){ min_start = std::min(min_start, r.start()); } return min_start; @@ -111,7 +110,7 @@ double meta_range_t::start(void) const{ double meta_range_t::stop(void) const{ check_meta_range_monotonic(*this); double max_stop = this->front().stop(); - BOOST_FOREACH(const range_t &r, (*this)){ + for (const range_t &r : (*this)){ max_stop = std::max(max_stop, r.stop()); } return max_stop; @@ -121,7 +120,7 @@ double meta_range_t::step(void) const{ check_meta_range_monotonic(*this); std::vector non_zero_steps; range_t last = this->front(); - BOOST_FOREACH(const range_t &r, (*this)){ + for (const range_t &r : (*this)){ //steps at each range if (r.step() > 0) non_zero_steps.push_back(r.step()); //and steps in-between ranges @@ -137,7 +136,7 @@ double meta_range_t::step(void) const{ double meta_range_t::clip(double value, bool clip_step) const{ check_meta_range_monotonic(*this); double last_stop = this->front().stop(); - BOOST_FOREACH(const range_t &r, (*this)){ + for (const range_t &r : (*this)){ //in-between ranges, clip to nearest if (value < r.start()){ return (std::abs(value - r.start()) < std::abs(value - last_stop))? @@ -157,7 +156,7 @@ double meta_range_t::clip(double value, bool clip_step) const{ std::vector meta_range_t::values() const { std::vector values; - BOOST_FOREACH(const range_t &r, (*this)) { + for (const range_t &r : (*this)) { if (r.start() != r.stop()) { if ( r.step() == 0 ) { values.push_back( r.start() ); @@ -177,7 +176,7 @@ std::vector meta_range_t::values() const { const std::string meta_range_t::to_pp_string(void) const{ std::stringstream ss; - BOOST_FOREACH(const range_t &r, (*this)){ + for (const range_t &r : (*this)){ ss << r.to_pp_string() << std::endl; } return ss.str(); diff --git a/lib/rfspace/rfspace_source_c.cc b/lib/rfspace/rfspace_source_c.cc index 121dcde032..597bff6a96 100644 --- a/lib/rfspace/rfspace_source_c.cc +++ b/lib/rfspace/rfspace_source_c.cc @@ -1296,7 +1296,7 @@ std::vector rfspace_source_c::get_devices( bool fake ) std::vector < unit_t > units = discover_netsdr(); - BOOST_FOREACH( unit_t u, units ) + for (unit_t u : units) { // std::cerr << u.name << " " << u.sn << " " << u.addr << ":" << u.port // << std::endl; @@ -1310,7 +1310,7 @@ std::vector rfspace_source_c::get_devices( bool fake ) units = discover_sdr_iq(); - BOOST_FOREACH( unit_t u, units ) + for (unit_t u : units) { // std::cerr << u.name << " " << u.sn << " " << u.addr << ":" << u.port // << std::endl; diff --git a/lib/sink_impl.cc b/lib/sink_impl.cc index e8f8dc076d..a09d7df14b 100644 --- a/lib/sink_impl.cc +++ b/lib/sink_impl.cc @@ -107,13 +107,13 @@ sink_impl::sink_impl( const std::string &args ) << GR_OSMOSDR_VERSION << " (" << GR_OSMOSDR_LIBVER << ") " << "gnuradio " << gr::version() << std::endl; std::cerr << "built-in sink types: "; - BOOST_FOREACH(std::string dev_type, dev_types) + for (std::string dev_type : dev_types) std::cerr << dev_type << " "; std::cerr << std::endl; - BOOST_FOREACH(std::string arg, arg_list) { + for (std::string arg : arg_list) { dict_t dict = params_to_dict(arg); - BOOST_FOREACH(std::string dev_type, dev_types) { + for (std::string dev_type : dev_types) { if ( dict.count( dev_type ) ) { device_specified = true; break; @@ -124,36 +124,36 @@ sink_impl::sink_impl( const std::string &args ) if ( ! device_specified ) { std::vector< std::string > dev_list; #ifdef ENABLE_UHD - BOOST_FOREACH( std::string dev, uhd_sink_c::get_devices() ) + for (std::string dev : uhd_sink_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_BLADERF - BOOST_FOREACH( std::string dev, bladerf_sink_c::get_devices() ) + for (std::string dev : bladerf_sink_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_HACKRF - BOOST_FOREACH( std::string dev, hackrf_sink_c::get_devices() ) + for (std::string dev : hackrf_sink_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_SOAPY - BOOST_FOREACH( std::string dev, soapy_sink_c::get_devices() ) + for (std::string dev : soapy_sink_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_REDPITAYA - BOOST_FOREACH( std::string dev, redpitaya_sink_c::get_devices() ) + for (std::string dev : redpitaya_sink_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_FREESRP - BOOST_FOREACH( std::string dev, freesrp_sink_c::get_devices() ) + for (std::string dev : freesrp_sink_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_FILE - BOOST_FOREACH( std::string dev, file_sink_c::get_devices() ) + for (std::string dev : file_sink_c::get_devices()) dev_list.push_back( dev ); #endif // std::cerr << std::endl; -// BOOST_FOREACH( std::string dev, dev_list ) +// for (std::string dev : dev_list) // std::cerr << "'" << dev << "'" << std::endl; if ( dev_list.size() ) @@ -162,12 +162,12 @@ sink_impl::sink_impl( const std::string &args ) throw std::runtime_error("No supported devices found (check the connection and/or udev rules)."); } - BOOST_FOREACH(std::string arg, arg_list) { + for (std::string arg : arg_list) { dict_t dict = params_to_dict(arg); // std::cerr << std::endl; -// BOOST_FOREACH( dict_t::value_type &entry, dict ) +// for (dict_t::value_type &entry : dict) // std::cerr << "'" << entry.first << "' = '" << entry.second << "'" << std::endl; sink_iface *iface = NULL; @@ -235,7 +235,7 @@ size_t sink_impl::get_num_channels() { size_t channels = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) channels += dev->get_num_channels(); return channels; @@ -263,7 +263,7 @@ double sink_impl::set_sample_rate(double rate) if (_devs.empty()) throw std::runtime_error(NO_DEVICES_MSG); #endif - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) sample_rate = dev->set_sample_rate(rate); _sample_rate = sample_rate; @@ -288,7 +288,7 @@ double sink_impl::get_sample_rate() osmosdr::freq_range_t sink_impl::get_freq_range( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_freq_range( dev_chan ); @@ -299,7 +299,7 @@ osmosdr::freq_range_t sink_impl::get_freq_range( size_t chan ) double sink_impl::set_center_freq( double freq, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _center_freq[ chan ] != freq ) { @@ -314,7 +314,7 @@ double sink_impl::set_center_freq( double freq, size_t chan ) double sink_impl::get_center_freq( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_center_freq( dev_chan ); @@ -325,7 +325,7 @@ double sink_impl::get_center_freq( size_t chan ) double sink_impl::set_freq_corr( double ppm, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _freq_corr[ chan ] != ppm ) { @@ -340,7 +340,7 @@ double sink_impl::set_freq_corr( double ppm, size_t chan ) double sink_impl::get_freq_corr( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_freq_corr( dev_chan ); @@ -351,7 +351,7 @@ double sink_impl::get_freq_corr( size_t chan ) std::vector sink_impl::get_gain_names( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_names( dev_chan ); @@ -362,7 +362,7 @@ std::vector sink_impl::get_gain_names( size_t chan ) osmosdr::gain_range_t sink_impl::get_gain_range( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_range( dev_chan ); @@ -373,7 +373,7 @@ osmosdr::gain_range_t sink_impl::get_gain_range( size_t chan ) osmosdr::gain_range_t sink_impl::get_gain_range( const std::string & name, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_range( name, dev_chan ); @@ -384,7 +384,7 @@ osmosdr::gain_range_t sink_impl::get_gain_range( const std::string & name, size_ bool sink_impl::set_gain_mode( bool automatic, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _gain_mode[ chan ] != automatic ) { @@ -402,7 +402,7 @@ bool sink_impl::set_gain_mode( bool automatic, size_t chan ) bool sink_impl::get_gain_mode( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_mode( dev_chan ); @@ -413,7 +413,7 @@ bool sink_impl::get_gain_mode( size_t chan ) double sink_impl::set_gain( double gain, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _gain[ chan ] != gain ) { @@ -428,7 +428,7 @@ double sink_impl::set_gain( double gain, size_t chan ) double sink_impl::set_gain( double gain, const std::string & name, size_t chan) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->set_gain( gain, name, dev_chan ); @@ -439,7 +439,7 @@ double sink_impl::set_gain( double gain, const std::string & name, size_t chan) double sink_impl::get_gain( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain( dev_chan ); @@ -450,7 +450,7 @@ double sink_impl::get_gain( size_t chan ) double sink_impl::get_gain( const std::string & name, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain( name, dev_chan ); @@ -461,7 +461,7 @@ double sink_impl::get_gain( const std::string & name, size_t chan ) double sink_impl::set_if_gain( double gain, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _if_gain[ chan ] != gain ) { @@ -476,7 +476,7 @@ double sink_impl::set_if_gain( double gain, size_t chan ) double sink_impl::set_bb_gain( double gain, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _bb_gain[ chan ] != gain ) { @@ -491,7 +491,7 @@ double sink_impl::set_bb_gain( double gain, size_t chan ) std::vector< std::string > sink_impl::get_antennas( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_antennas( dev_chan ); @@ -502,7 +502,7 @@ std::vector< std::string > sink_impl::get_antennas( size_t chan ) std::string sink_impl::set_antenna( const std::string & antenna, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _antenna[ chan ] != antenna ) { @@ -517,7 +517,7 @@ std::string sink_impl::set_antenna( const std::string & antenna, size_t chan ) std::string sink_impl::get_antenna( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_antenna( dev_chan ); @@ -528,7 +528,7 @@ std::string sink_impl::get_antenna( size_t chan ) void sink_impl::set_dc_offset( const std::complex &offset, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) dev->set_dc_offset( offset, dev_chan ); @@ -537,7 +537,7 @@ void sink_impl::set_dc_offset( const std::complex &offset, size_t chan ) void sink_impl::set_iq_balance( const std::complex &balance, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) dev->set_iq_balance( balance, dev_chan ); @@ -546,7 +546,7 @@ void sink_impl::set_iq_balance( const std::complex &balance, size_t chan double sink_impl::set_bandwidth( double bandwidth, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _bandwidth[ chan ] != bandwidth || 0.0f == bandwidth ) { @@ -561,7 +561,7 @@ double sink_impl::set_bandwidth( double bandwidth, size_t chan ) double sink_impl::get_bandwidth( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_bandwidth( dev_chan ); @@ -572,7 +572,7 @@ double sink_impl::get_bandwidth( size_t chan ) osmosdr::freq_range_t sink_impl::get_bandwidth_range( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_bandwidth_range( dev_chan ); @@ -665,7 +665,7 @@ void sink_impl::set_time_now(const osmosdr::time_spec_t &time_spec, size_t mboar void sink_impl::set_time_next_pps(const osmosdr::time_spec_t &time_spec) { - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) { dev->set_time_next_pps( time_spec ); } @@ -673,7 +673,7 @@ void sink_impl::set_time_next_pps(const osmosdr::time_spec_t &time_spec) void sink_impl::set_time_unknown_pps(const osmosdr::time_spec_t &time_spec) { - BOOST_FOREACH( sink_iface *dev, _devs ) + for (sink_iface *dev : _devs) { dev->set_time_unknown_pps( time_spec ); } diff --git a/lib/soapy/soapy_sink_c.cc b/lib/soapy/soapy_sink_c.cc index e4422f7f45..4aafc47203 100644 --- a/lib/soapy/soapy_sink_c.cc +++ b/lib/soapy/soapy_sink_c.cc @@ -107,7 +107,7 @@ std::vector soapy_sink_c::get_devices() { std::vector result; int i = 0; - BOOST_FOREACH(SoapySDR::Kwargs kw, SoapySDR::Device::enumerate()) + for (SoapySDR::Kwargs kw : SoapySDR::Device::enumerate()) { kw["soapy"] = boost::lexical_cast(i++); result.push_back(dict_to_args_string(kw)); @@ -124,12 +124,12 @@ osmosdr::meta_range_t soapy_sink_c::get_sample_rates( void ) { osmosdr::meta_range_t result; #ifdef SOAPY_SDR_API_HAS_GET_SAMPLE_RATE_RANGE - BOOST_FOREACH(const SoapySDR::Range &r, _device->getSampleRateRange(SOAPY_SDR_TX, 0)) + for (const SoapySDR::Range &r : _device->getSampleRateRange(SOAPY_SDR_TX, 0)) { result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); } #else - BOOST_FOREACH(const double rate, _device->listSampleRates(SOAPY_SDR_TX, 0)) + for (const double rate : _device->listSampleRates(SOAPY_SDR_TX, 0)) { result.push_back(osmosdr::range_t(rate)); } @@ -151,7 +151,7 @@ double soapy_sink_c::get_sample_rate( void ) osmosdr::freq_range_t soapy_sink_c::get_freq_range( size_t chan) { osmosdr::meta_range_t result; - BOOST_FOREACH(const SoapySDR::Range r, _device->getFrequencyRange(SOAPY_SDR_TX, 0)) + for (const SoapySDR::Range r : _device->getFrequencyRange(SOAPY_SDR_TX, 0)) { result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); } @@ -309,12 +309,12 @@ osmosdr::freq_range_t soapy_sink_c::get_bandwidth_range( size_t chan) { osmosdr::meta_range_t result; #ifdef SOAPY_SDR_API_HAS_GET_BANDWIDTH_RANGE - BOOST_FOREACH(const SoapySDR::Range &r, _device->getBandwidthRange(SOAPY_SDR_TX, 0)) + for (const SoapySDR::Range &r : _device->getBandwidthRange(SOAPY_SDR_TX, 0)) { result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); } #else - BOOST_FOREACH(const double bw, _device->listBandwidths(SOAPY_SDR_TX, 0)) + for (const double bw : _device->listBandwidths(SOAPY_SDR_TX, 0)) { result.push_back(osmosdr::range_t(bw)); } diff --git a/lib/soapy/soapy_source_c.cc b/lib/soapy/soapy_source_c.cc index 4056a508a0..4dc9efc019 100644 --- a/lib/soapy/soapy_source_c.cc +++ b/lib/soapy/soapy_source_c.cc @@ -113,7 +113,7 @@ std::vector soapy_source_c::get_devices() { std::vector result; int i = 0; - BOOST_FOREACH(SoapySDR::Kwargs kw, SoapySDR::Device::enumerate()) + for (SoapySDR::Kwargs kw : SoapySDR::Device::enumerate()) { kw["soapy"] = boost::lexical_cast(i++); result.push_back(dict_to_args_string(kw)); @@ -130,12 +130,12 @@ osmosdr::meta_range_t soapy_source_c::get_sample_rates( void ) { osmosdr::meta_range_t result; #ifdef SOAPY_SDR_API_HAS_GET_SAMPLE_RATE_RANGE - BOOST_FOREACH(const SoapySDR::Range &r, _device->getSampleRateRange(SOAPY_SDR_RX, 0)) + for (const SoapySDR::Range &r : _device->getSampleRateRange(SOAPY_SDR_RX, 0)) { result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); } #else - BOOST_FOREACH(const double rate, _device->listSampleRates(SOAPY_SDR_RX, 0)) + for (const double rate : _device->listSampleRates(SOAPY_SDR_RX, 0)) { result.push_back(osmosdr::range_t(rate)); } @@ -157,7 +157,7 @@ double soapy_source_c::get_sample_rate( void ) osmosdr::freq_range_t soapy_source_c::get_freq_range( size_t chan ) { osmosdr::meta_range_t result; - BOOST_FOREACH(const SoapySDR::Range r, _device->getFrequencyRange(SOAPY_SDR_RX, 0)) + for (const SoapySDR::Range r : _device->getFrequencyRange(SOAPY_SDR_RX, 0)) { result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); } @@ -338,12 +338,12 @@ osmosdr::freq_range_t soapy_source_c::get_bandwidth_range( size_t chan ) { osmosdr::meta_range_t result; #ifdef SOAPY_SDR_API_HAS_GET_BANDWIDTH_RANGE - BOOST_FOREACH(const SoapySDR::Range &r, _device->getBandwidthRange(SOAPY_SDR_RX, 0)) + for (const SoapySDR::Range &r : _device->getBandwidthRange(SOAPY_SDR_RX, 0)) { result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); } #else - BOOST_FOREACH(const double bw, _device->listBandwidths(SOAPY_SDR_RX, 0)) + for (const double bw : _device->listBandwidths(SOAPY_SDR_RX, 0)) { result.push_back(osmosdr::range_t(bw)); } diff --git a/lib/source_impl.cc b/lib/source_impl.cc index f1426e0e0b..41c45bf467 100644 --- a/lib/source_impl.cc +++ b/lib/source_impl.cc @@ -177,7 +177,7 @@ source_impl::source_impl( const std::string &args ) << GR_OSMOSDR_VERSION << " (" << GR_OSMOSDR_LIBVER << ") " << "gnuradio " << gr::version() << std::endl; std::cerr << "built-in source types: "; - BOOST_FOREACH(std::string dev_type, dev_types) + for (std::string dev_type : dev_types) std::cerr << dev_type << " "; std::cerr << std::endl; @@ -188,9 +188,9 @@ source_impl::source_impl( const std::string &args ) dev_types.push_back("cloudiq"); #endif - BOOST_FOREACH(std::string arg, arg_list) { + for (std::string arg : arg_list) { dict_t dict = params_to_dict(arg); - BOOST_FOREACH(std::string dev_type, dev_types) { + for (std::string dev_type : dev_types) { if ( dict.count( dev_type ) ) { device_specified = true; break; @@ -201,64 +201,64 @@ source_impl::source_impl( const std::string &args ) if ( ! device_specified ) { std::vector< std::string > dev_list; #ifdef ENABLE_OSMOSDR - BOOST_FOREACH( std::string dev, osmosdr_src_c::get_devices() ) + for (std::string dev : osmosdr_src_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_FCD - BOOST_FOREACH( std::string dev, fcd_source_c::get_devices() ) + for (std::string dev : fcd_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_RTL - BOOST_FOREACH( std::string dev, rtl_source_c::get_devices() ) + for (std::string dev : rtl_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_UHD - BOOST_FOREACH( std::string dev, uhd_source_c::get_devices() ) + for (std::string dev : uhd_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_MIRI - BOOST_FOREACH( std::string dev, miri_source_c::get_devices() ) + for (std::string dev : miri_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_SDRPLAY - BOOST_FOREACH( std::string dev, sdrplay_source_c::get_devices() ) + for (std::string dev : sdrplay_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_BLADERF - BOOST_FOREACH( std::string dev, bladerf_source_c::get_devices() ) + for (std::string dev : bladerf_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_RFSPACE - BOOST_FOREACH( std::string dev, rfspace_source_c::get_devices() ) + for (std::string dev : rfspace_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_HACKRF - BOOST_FOREACH( std::string dev, hackrf_source_c::get_devices() ) + for (std::string dev : hackrf_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_AIRSPY - BOOST_FOREACH( std::string dev, airspy_source_c::get_devices() ) + for (std::string dev : airspy_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_AIRSPYHF - BOOST_FOREACH( std::string dev, airspyhf_source_c::get_devices() ) + for (std::string dev : airspyhf_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_SOAPY - BOOST_FOREACH( std::string dev, soapy_source_c::get_devices() ) + for (std::string dev : soapy_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_REDPITAYA - BOOST_FOREACH( std::string dev, redpitaya_source_c::get_devices() ) + for (std::string dev : redpitaya_source_c::get_devices()) dev_list.push_back( dev ); #endif #ifdef ENABLE_FREESRP - BOOST_FOREACH( std::string dev, freesrp_source_c::get_devices() ) + for (std::string dev : freesrp_source_c::get_devices()) dev_list.push_back( dev ); #endif // std::cerr << std::endl; -// BOOST_FOREACH( std::string dev, dev_list ) +// for (std::string dev : dev_list) // std::cerr << "'" << dev << "'" << std::endl; if ( dev_list.size() ) @@ -267,12 +267,12 @@ source_impl::source_impl( const std::string &args ) throw std::runtime_error("No supported devices found (check the connection and/or udev rules)."); } - BOOST_FOREACH(std::string arg, arg_list) { + for (std::string arg : arg_list) { dict_t dict = params_to_dict(arg); // std::cerr << std::endl; -// BOOST_FOREACH( dict_t::value_type &entry, dict ) +// for (dict_t::value_type &entry : dict) // std::cerr << "'" << entry.first << "' = '" << entry.second << "'" << std::endl; source_iface *iface = NULL; @@ -427,7 +427,7 @@ size_t source_impl::get_num_channels() { size_t channels = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) channels += dev->get_num_channels(); return channels; @@ -436,7 +436,7 @@ size_t source_impl::get_num_channels() bool source_impl::seek( long seek_point, int whence, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->seek( seek_point, whence, dev_chan ); @@ -466,12 +466,12 @@ double source_impl::set_sample_rate(double rate) if (_devs.empty()) throw std::runtime_error(NO_DEVICES_MSG); #endif - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) sample_rate = dev->set_sample_rate(rate); #ifdef HAVE_IQBALANCE size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) { + for (source_iface *dev : _devs) { for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) { if ( channel < _iq_opt.size() ) { gr::iqbalance::optimize_c *opt = _iq_opt[channel]; @@ -509,7 +509,7 @@ double source_impl::get_sample_rate() osmosdr::freq_range_t source_impl::get_freq_range( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_freq_range( dev_chan ); @@ -520,7 +520,7 @@ osmosdr::freq_range_t source_impl::get_freq_range( size_t chan ) double source_impl::set_center_freq( double freq, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _center_freq[ chan ] != freq ) { @@ -535,7 +535,7 @@ double source_impl::set_center_freq( double freq, size_t chan ) double source_impl::get_center_freq( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_center_freq( dev_chan ); @@ -546,7 +546,7 @@ double source_impl::get_center_freq( size_t chan ) double source_impl::set_freq_corr( double ppm, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _freq_corr[ chan ] != ppm ) { @@ -561,7 +561,7 @@ double source_impl::set_freq_corr( double ppm, size_t chan ) double source_impl::get_freq_corr( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_freq_corr( dev_chan ); @@ -572,7 +572,7 @@ double source_impl::get_freq_corr( size_t chan ) std::vector source_impl::get_gain_names( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_names( dev_chan ); @@ -583,7 +583,7 @@ std::vector source_impl::get_gain_names( size_t chan ) osmosdr::gain_range_t source_impl::get_gain_range( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_range( dev_chan ); @@ -594,7 +594,7 @@ osmosdr::gain_range_t source_impl::get_gain_range( size_t chan ) osmosdr::gain_range_t source_impl::get_gain_range( const std::string & name, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_range( name, dev_chan ); @@ -605,7 +605,7 @@ osmosdr::gain_range_t source_impl::get_gain_range( const std::string & name, siz bool source_impl::set_gain_mode( bool automatic, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _gain_mode[ chan ] != automatic ) { @@ -623,7 +623,7 @@ bool source_impl::set_gain_mode( bool automatic, size_t chan ) bool source_impl::get_gain_mode( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain_mode( dev_chan ); @@ -634,7 +634,7 @@ bool source_impl::get_gain_mode( size_t chan ) double source_impl::set_gain( double gain, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _gain[ chan ] != gain ) { @@ -649,7 +649,7 @@ double source_impl::set_gain( double gain, size_t chan ) double source_impl::set_gain( double gain, const std::string & name, size_t chan) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->set_gain( gain, name, dev_chan ); @@ -660,7 +660,7 @@ double source_impl::set_gain( double gain, const std::string & name, size_t chan double source_impl::get_gain( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain( dev_chan ); @@ -671,7 +671,7 @@ double source_impl::get_gain( size_t chan ) double source_impl::get_gain( const std::string & name, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_gain( name, dev_chan ); @@ -682,7 +682,7 @@ double source_impl::get_gain( const std::string & name, size_t chan ) double source_impl::set_if_gain( double gain, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _if_gain[ chan ] != gain ) { @@ -697,7 +697,7 @@ double source_impl::set_if_gain( double gain, size_t chan ) double source_impl::set_bb_gain( double gain, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _bb_gain[ chan ] != gain ) { @@ -712,7 +712,7 @@ double source_impl::set_bb_gain( double gain, size_t chan ) std::vector< std::string > source_impl::get_antennas( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_antennas( dev_chan ); @@ -723,7 +723,7 @@ std::vector< std::string > source_impl::get_antennas( size_t chan ) std::string source_impl::set_antenna( const std::string & antenna, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _antenna[ chan ] != antenna ) { @@ -738,7 +738,7 @@ std::string source_impl::set_antenna( const std::string & antenna, size_t chan ) std::string source_impl::get_antenna( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_antenna( dev_chan ); @@ -749,7 +749,7 @@ std::string source_impl::get_antenna( size_t chan ) void source_impl::set_dc_offset_mode( int mode, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) dev->set_dc_offset_mode( mode, dev_chan ); @@ -758,7 +758,7 @@ void source_impl::set_dc_offset_mode( int mode, size_t chan ) void source_impl::set_dc_offset( const std::complex &offset, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) dev->set_dc_offset( offset, dev_chan ); @@ -768,7 +768,7 @@ void source_impl::set_iq_balance_mode( int mode, size_t chan ) { size_t channel = 0; #ifdef HAVE_IQBALANCE - BOOST_FOREACH( source_iface *dev, _devs ) { + for (source_iface *dev : _devs) { for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) { if ( chan == channel++ ) { if ( chan < _iq_opt.size() && chan < _iq_fix.size() ) { @@ -798,7 +798,7 @@ void source_impl::set_iq_balance_mode( int mode, size_t chan ) } } #else - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->set_iq_balance_mode( mode, dev_chan ); @@ -809,7 +809,7 @@ void source_impl::set_iq_balance( const std::complex &balance, size_t ch { size_t channel = 0; #ifdef HAVE_IQBALANCE - BOOST_FOREACH( source_iface *dev, _devs ) { + for (source_iface *dev : _devs) { for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) { if ( chan == channel++ ) { if ( chan < _iq_opt.size() && chan < _iq_fix.size() ) { @@ -825,7 +825,7 @@ void source_impl::set_iq_balance( const std::complex &balance, size_t ch } } #else - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->set_iq_balance( balance, dev_chan ); @@ -835,7 +835,7 @@ void source_impl::set_iq_balance( const std::complex &balance, size_t ch double source_impl::set_bandwidth( double bandwidth, size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) { if ( _bandwidth[ chan ] != bandwidth || 0.0f == bandwidth ) { @@ -850,7 +850,7 @@ double source_impl::set_bandwidth( double bandwidth, size_t chan ) double source_impl::get_bandwidth( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_bandwidth( dev_chan ); @@ -861,7 +861,7 @@ double source_impl::get_bandwidth( size_t chan ) osmosdr::freq_range_t source_impl::get_bandwidth_range( size_t chan ) { size_t channel = 0; - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) if ( chan == channel++ ) return dev->get_bandwidth_range( dev_chan ); @@ -954,7 +954,7 @@ void source_impl::set_time_now(const osmosdr::time_spec_t &time_spec, size_t mbo void source_impl::set_time_next_pps(const osmosdr::time_spec_t &time_spec) { - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) { dev->set_time_next_pps( time_spec ); } @@ -962,7 +962,7 @@ void source_impl::set_time_next_pps(const osmosdr::time_spec_t &time_spec) void source_impl::set_time_unknown_pps(const osmosdr::time_spec_t &time_spec) { - BOOST_FOREACH( source_iface *dev, _devs ) + for (source_iface *dev : _devs) { dev->set_time_unknown_pps( time_spec ); } diff --git a/lib/uhd/uhd_sink_c.cc b/lib/uhd/uhd_sink_c.cc index a154556fc0..8698f4c2f5 100644 --- a/lib/uhd/uhd_sink_c.cc +++ b/lib/uhd/uhd_sink_c.cc @@ -18,7 +18,6 @@ * Boston, MA 02110-1301, USA. */ -#include #include #include @@ -71,7 +70,7 @@ uhd_sink_c::uhd_sink_c(const std::string &args) : _lo_offset = boost::lexical_cast< double >( dict["lo_offset"] ); std::string arguments; // rebuild argument string without internal arguments - BOOST_FOREACH( dict_t::value_type &entry, dict ) + for (dict_t::value_type &entry : dict) { if ( "cpu_format" == entry.first || "otw_format" == entry.first || @@ -135,7 +134,7 @@ std::vector< std::string > uhd_sink_c::get_devices() std::vector< std::string > devices; uhd::device_addr_t hint; - BOOST_FOREACH(const uhd::device_addr_t &dev, uhd::device::find(hint)) + for (const uhd::device_addr_t &dev : uhd::device::find(hint)) { std::string args = "uhd," + dev.to_string(); @@ -190,7 +189,7 @@ osmosdr::meta_range_t uhd_sink_c::get_sample_rates( void ) { osmosdr::meta_range_t rates; - BOOST_FOREACH( uhd::range_t rate, _snk->get_samp_rates() ) + for (uhd::range_t rate : _snk->get_samp_rates()) rates += osmosdr::range_t( rate.start(), rate.stop(), rate.step() ); return rates; @@ -211,7 +210,7 @@ osmosdr::freq_range_t uhd_sink_c::get_freq_range( size_t chan ) { osmosdr::freq_range_t range; - BOOST_FOREACH( uhd::range_t freq, _snk->get_freq_range(chan) ) + for (uhd::range_t freq : _snk->get_freq_range(chan)) range += osmosdr::range_t( freq.start(), freq.stop(), freq.step() ); return range; @@ -260,7 +259,7 @@ osmosdr::gain_range_t uhd_sink_c::get_gain_range( size_t chan ) { osmosdr::gain_range_t range; - BOOST_FOREACH( uhd::range_t gain, _snk->get_gain_range(chan) ) + for (uhd::range_t gain : _snk->get_gain_range(chan)) range += osmosdr::range_t( gain.start(), gain.stop(), gain.step() ); return range; @@ -270,7 +269,7 @@ osmosdr::gain_range_t uhd_sink_c::get_gain_range( const std::string & name, size { osmosdr::gain_range_t range; - BOOST_FOREACH( uhd::range_t gain, _snk->get_gain_range(name, chan) ) + for (uhd::range_t gain : _snk->get_gain_range(name, chan)) range += osmosdr::range_t( gain.start(), gain.stop(), gain.step() ); return range; @@ -351,7 +350,7 @@ osmosdr::freq_range_t uhd_sink_c::get_bandwidth_range( size_t chan ) { osmosdr::freq_range_t bandwidths; - BOOST_FOREACH( uhd::range_t bw, _snk->get_bandwidth_range(chan) ) + for (uhd::range_t bw : _snk->get_bandwidth_range(chan)) bandwidths += osmosdr::range_t( bw.start(), bw.stop(), bw.step() ); return bandwidths; diff --git a/lib/uhd/uhd_source_c.cc b/lib/uhd/uhd_source_c.cc index fc1301746e..f9f9fdd620 100644 --- a/lib/uhd/uhd_source_c.cc +++ b/lib/uhd/uhd_source_c.cc @@ -18,7 +18,6 @@ * Boston, MA 02110-1301, USA. */ -#include #include #include @@ -72,7 +71,7 @@ uhd_source_c::uhd_source_c(const std::string &args) : _lo_offset = boost::lexical_cast< double >( dict["lo_offset"] ); std::string arguments; // rebuild argument string without internal arguments - BOOST_FOREACH( dict_t::value_type &entry, dict ) + for (dict_t::value_type &entry : dict) { if ( "cpu_format" == entry.first || "otw_format" == entry.first || @@ -136,7 +135,7 @@ std::vector< std::string > uhd_source_c::get_devices() std::vector< std::string > devices; uhd::device_addr_t hint; - BOOST_FOREACH(const uhd::device_addr_t &dev, uhd::device::find(hint)) + for (const uhd::device_addr_t &dev : uhd::device::find(hint)) { std::string args = "uhd," + dev.to_string(); @@ -191,7 +190,7 @@ osmosdr::meta_range_t uhd_source_c::get_sample_rates( void ) { osmosdr::meta_range_t rates; - BOOST_FOREACH( uhd::range_t rate, _src->get_samp_rates() ) + for (uhd::range_t rate : _src->get_samp_rates()) rates += osmosdr::range_t( rate.start(), rate.stop(), rate.step() ); return rates; @@ -212,7 +211,7 @@ osmosdr::freq_range_t uhd_source_c::get_freq_range( size_t chan ) { osmosdr::freq_range_t range; - BOOST_FOREACH( uhd::range_t freq, _src->get_freq_range(chan) ) + for (uhd::range_t freq : _src->get_freq_range(chan)) range += osmosdr::range_t( freq.start(), freq.stop(), freq.step() ); return range; @@ -261,7 +260,7 @@ osmosdr::gain_range_t uhd_source_c::get_gain_range( size_t chan ) { osmosdr::gain_range_t range; - BOOST_FOREACH( uhd::range_t gain, _src->get_gain_range(chan) ) + for (uhd::range_t gain : _src->get_gain_range(chan)) range += osmosdr::range_t( gain.start(), gain.stop(), gain.step() ); return range; @@ -271,7 +270,7 @@ osmosdr::gain_range_t uhd_source_c::get_gain_range( const std::string & name, si { osmosdr::gain_range_t range; - BOOST_FOREACH( uhd::range_t gain, _src->get_gain_range(name, chan) ) + for (uhd::range_t gain : _src->get_gain_range(name, chan)) range += osmosdr::range_t( gain.start(), gain.stop(), gain.step() ); return range; @@ -383,7 +382,7 @@ osmosdr::freq_range_t uhd_source_c::get_bandwidth_range( size_t chan ) { osmosdr::freq_range_t bandwidths; - BOOST_FOREACH( uhd::range_t bw, _src->get_bandwidth_range(chan) ) + for (uhd::range_t bw : _src->get_bandwidth_range(chan)) bandwidths += osmosdr::range_t( bw.start(), bw.stop(), bw.step() ); return bandwidths; -- 2.25.1 From argilo at gmail.com Fri Oct 23 02:41:04 2020 From: argilo at gmail.com (argilo at gmail.com) Date: Thu, 22 Oct 2020 22:41:04 -0400 Subject: [PATCH] Replace boost::bind with std::bind Message-ID: <20201023024104.1692521-1-argilo@gmail.com> From: Clayton Smith This removes gr-iqbal's second-last dependence on Boost. All that remains is boost::shared_ptr, which will have to stay until GNU Radio 3.9. --- lib/fix_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fix_cc.cc b/lib/fix_cc.cc index af79d7db26..628421db3e 100644 --- a/lib/fix_cc.cc +++ b/lib/fix_cc.cc @@ -43,7 +43,7 @@ iqbalance::fix_cc::fix_cc(float mag, float phase) { message_port_register_in(pmt::mp("iqbal_corr")); set_msg_handler(pmt::mp("iqbal_corr"), - boost::bind(&iqbalance::fix_cc::apply_new_corrections, this, boost::placeholders::_1)); + std::bind(&iqbalance::fix_cc::apply_new_corrections, this, std::placeholders::_1)); } -- 2.25.1 From argilo at gmail.com Fri Oct 23 03:06:12 2020 From: argilo at gmail.com (argilo at gmail.com) Date: Thu, 22 Oct 2020 23:06:12 -0400 Subject: [PATCH] rfspace: Remove broken asio code Message-ID: <20201023030612.1693932-1-argilo@gmail.com> From: Clayton Smith Asio sockets were replaced with native BSD sockets in e1b699fda04b114c8973e4cbef929781d2312ba5, and the old code was placed behind #ifdef USE_ASIO. Subsequent commits soon broke the asio code. Since it's been broken for a long time, I doubt anyone is using it, so it makes sense to remove it. --- lib/rfspace/rfspace_source_c.cc | 146 -------------------------------- lib/rfspace/rfspace_source_c.h | 16 ---- 2 files changed, 162 deletions(-) diff --git a/lib/rfspace/rfspace_source_c.cc b/lib/rfspace/rfspace_source_c.cc index 121dcde032..6bd741252d 100644 --- a/lib/rfspace/rfspace_source_c.cc +++ b/lib/rfspace/rfspace_source_c.cc @@ -27,7 +27,6 @@ #include "config.h" #endif -#ifndef USE_ASIO #include #include #include @@ -35,7 +34,6 @@ #include #include #include -#endif #include #include @@ -54,9 +52,6 @@ #include #include #include -#ifdef USE_ASIO -#include -#endif #include @@ -64,9 +59,6 @@ #include "rfspace_source_c.h" using namespace boost::assign; -#ifdef USE_ASIO -using boost::asio::deadline_timer; -#endif #define DEFAULT_HOST "127.0.0.1" /* We assume a running "siqs" from CuteSDR project */ #define DEFAULT_PORT 50000 @@ -102,15 +94,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args) gr::io_signature::make (MIN_IN, MAX_IN, sizeof (gr_complex)), gr::io_signature::make (MIN_OUT, MAX_OUT, sizeof (gr_complex))), _radio(RADIO_UNKNOWN), -#ifdef USE_ASIO - _io_service(), - _resolver(_io_service), - _t(_io_service), - _u(_io_service), -#else _tcp(-1), _udp(-1), -#endif _usb(-1), _running(false), _keep_running(false), @@ -239,30 +224,6 @@ rfspace_source_c::rfspace_source_c (const std::string &args) /* SDR-IP 4.4.4 Data Output UDP IP and Port Address */ /* NETSDR 4.4.3 Data Output UDP IP and Port Address */ -#ifdef USE_ASIO - - tcp::resolver::query query(tcp::v4(), host.c_str(), port_str.c_str()); - tcp::resolver::iterator iterator = _resolver.resolve(query); - - boost::system::error_code ec; - - boost::asio::connect(_t, iterator, ec); - if ( ec ) - throw std::runtime_error(ec.message() + " (" + host + ":" + port_str + ")"); - - _u.open(udp::v4(), ec); - if ( ec ) - throw std::runtime_error(ec.message()); - - _u.bind(udp::endpoint(udp::v4(), DEFAULT_PORT), ec); - if ( ec ) - throw std::runtime_error(ec.message()); - - _u.set_option(udp::socket::reuse_address(true)); - _t.set_option(udp::socket::reuse_address(true)); - -#else - if ( (_tcp = socket(AF_INET, SOCK_STREAM, 0) ) < 0) { throw std::runtime_error("Could not create TCP socket"); @@ -339,8 +300,6 @@ rfspace_source_c::rfspace_source_c (const std::string &args) throw std::runtime_error("Bind of UDP socket failed: " + std::string(strerror(errno))); } -#endif - } /* Wait 10 ms before sending queries to device (required for networked radios). */ @@ -506,10 +465,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args) */ rfspace_source_c::~rfspace_source_c () { -#ifndef USE_ASIO close(_tcp); close(_udp); -#endif if ( RFSPACE_SDR_IQ == _radio ) { @@ -600,11 +557,6 @@ bool rfspace_source_c::transaction( const unsigned char *cmd, size_t size, { std::lock_guard lock(_tcp_lock); -#ifdef USE_ASIO - _t.write_some( boost::asio::buffer(cmd, size) ); - - rx_bytes = _t.read_some( boost::asio::buffer(data, sizeof(data)) ); -#else if ( write(_tcp, cmd, size) != (int)size ) return false; @@ -624,7 +576,6 @@ bool rfspace_source_c::transaction( const unsigned char *cmd, size_t size, return false; rx_bytes = 2 + length; /* header + payload */ -#endif } response.resize( rx_bytes ); @@ -852,10 +803,6 @@ int rfspace_source_c::work( int noutput_items, return noutput_items; } -#ifdef USE_ASIO - udp::endpoint ep; - size_t rx_bytes = _u.receive_from( boost::asio::buffer(data, sizeof(data)), ep ); -#else struct sockaddr_in sa_in; /* remote address */ socklen_t addrlen = sizeof(sa_in); /* length of addresses */ ssize_t rx_bytes = recvfrom(_udp, data, sizeof(data), 0, (struct sockaddr *)&sa_in, &addrlen); @@ -864,7 +811,6 @@ int rfspace_source_c::work( int noutput_items, std::cerr << "recvfrom returned " << rx_bytes << std::endl; return WORK_DONE; } -#endif #define HEADER_SIZE 2 #define SEQNUM_SIZE 2 @@ -892,11 +838,7 @@ int rfspace_source_c::work( int noutput_items, if ( diff > 1 ) { std::cerr << "Lost " << diff << " packets from " -#ifdef USE_ASIO - << ep -#else << inet_ntoa(sa_in.sin_addr) << ":" << ntohs(sa_in.sin_port) -#endif << std::endl; } @@ -977,48 +919,11 @@ typedef struct uint16_t port; } unit_t; -#ifdef USE_ASIO -static void handle_receive( const boost::system::error_code& ec, - std::size_t length, - boost::system::error_code* out_ec, - std::size_t* out_length ) -{ - *out_ec = ec; - *out_length = length; -} - -static void handle_timer( const boost::system::error_code& ec, - boost::system::error_code* out_ec ) -{ - *out_ec = boost::asio::error::timed_out; -} -#endif static std::vector < unit_t > discover_netsdr() { std::vector < unit_t > units; -#ifdef USE_ASIO - boost::system::error_code ec; - boost::asio::io_service ios; - udp::socket socket(ios); - deadline_timer timer(ios); - - timer.expires_at(boost::posix_time::pos_infin); - - socket.open(udp::v4(), ec); - - if ( ec ) - return units; - - socket.bind(udp::endpoint(udp::v4(), DISCOVER_CLIENT_PORT), ec); - - if ( ec ) - return units; - - socket.set_option(udp::socket::reuse_address(true)); - socket.set_option(boost::asio::socket_base::broadcast(true)); -#else int sock; if ( (sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ) @@ -1058,7 +963,6 @@ static std::vector < unit_t > discover_netsdr() close(sock); return units; } -#endif discover_common_msg_t tx_msg; memset( (void *)&tx_msg, 0, sizeof(discover_common_msg_t) ); @@ -1067,64 +971,18 @@ static std::vector < unit_t > discover_netsdr() tx_msg.key[0] = KEY0; tx_msg.key[1] = KEY1; tx_msg.op = MSG_REQ; -#ifdef USE_ASIO - udp::endpoint ep(boost::asio::ip::address_v4::broadcast(), DISCOVER_SERVER_PORT); - socket.send_to(boost::asio::buffer(&tx_msg, sizeof(tx_msg)), ep); -#else sendto(sock, &tx_msg, sizeof(tx_msg), 0, (struct sockaddr *)&peer_sa, sizeof(peer_sa)); -#endif while ( true ) { std::size_t rx_bytes = 0; unsigned char data[1024*2]; -#ifdef USE_ASIO - // Set up the variables that receive the result of the asynchronous - // operation. The error code is set to would_block to signal that the - // operation is incomplete. Asio guarantees that its asynchronous - // operations will never fail with would_block, so any other value in - // ec indicates completion. - ec = boost::asio::error::would_block; - - // Start the asynchronous receive operation. The handle_receive function - // used as a callback will update the ec and rx_bytes variables. - socket.async_receive( boost::asio::buffer(data, sizeof(data)), - boost::bind(handle_receive, _1, _2, &ec, &rx_bytes) ); - - // Set a deadline for the asynchronous operation. - timer.expires_from_now( boost::posix_time::milliseconds(10) ); - - // Start an asynchronous wait on the timer. The handle_timer function - // used as a callback will update the ec variable. - timer.async_wait( boost::bind(handle_timer, _1, &ec) ); - - // Reset the io_service in preparation for a subsequent run_one() invocation. - ios.reset(); - - // Block until at least one asynchronous operation has completed. - do ios.run_one(); while ( ec == boost::asio::error::would_block ); - - if ( boost::asio::error::timed_out == ec ) /* timer was first to complete */ - { - // Please note that cancel() has portability issues on some versions of - // Microsoft Windows, and it may be necessary to use close() instead. - // Consult the documentation for cancel() for further information. - socket.cancel(); - - break; - } - else /* socket was first to complete */ - { - timer.cancel(); - } -#else socklen_t addrlen = sizeof(peer_sa); /* length of addresses */ int nbytes = recvfrom(sock, data, sizeof(data), 0, (struct sockaddr *)&peer_sa, &addrlen); if ( nbytes <= 0 ) break; rx_bytes = nbytes; -#endif if ( rx_bytes >= sizeof(discover_common_msg_t) ) { @@ -1151,11 +1009,7 @@ static std::vector < unit_t > discover_netsdr() } } } -#ifdef USE_ASIO - socket.close(ec); -#else close(sock); -#endif return units; } diff --git a/lib/rfspace/rfspace_source_c.h b/lib/rfspace/rfspace_source_c.h index a51bfc6f8a..d2bf66d9c5 100644 --- a/lib/rfspace/rfspace_source_c.h +++ b/lib/rfspace/rfspace_source_c.h @@ -20,11 +20,6 @@ #ifndef INCLUDED_RFSPACE_SOURCE_C_H #define INCLUDED_RFSPACE_SOURCE_C_H -//#define USE_ASIO - -#ifdef USE_ASIO -#include -#endif #include #include #include @@ -36,10 +31,6 @@ #include "osmosdr/ranges.h" #include "source_iface.h" -#ifdef USE_ASIO -using boost::asio::ip::tcp; -using boost::asio::ip::udp; -#endif class rfspace_source_c; #ifndef SOCKET @@ -144,15 +135,8 @@ private: /* members */ radio_type _radio; -#ifdef USE_ASIO - boost::asio::io_service _io_service; - tcp::resolver _resolver; - tcp::socket _t; - udp::socket _u; -#else SOCKET _tcp; SOCKET _udp; -#endif int _usb; bool _running; bool _keep_running; -- 2.25.1 From argilo at gmail.com Thu Oct 29 00:10:47 2020 From: argilo at gmail.com (argilo at gmail.com) Date: Wed, 28 Oct 2020 20:10:47 -0400 Subject: [PATCH] Remove disabled OsmoSDR and MiriSDR code Message-ID: <20201029001047.73620-1-argilo@gmail.com> From: Clayton Smith OsmoSDR and MiriSDR support was disabled in v0.2.1 because the hardware is rare and obsolete. I think it would be useful to completely remove the associated code, since this will reduce the future maintenance burden for gr-osmosdr. --- CMakeLists.txt | 2 - README | 2 - cmake/Modules/FindLibMiriSDR.cmake | 27 -- cmake/Modules/FindLibOsmoSDR.cmake | 27 -- grc/gen_osmosdr_blocks.py | 4 - lib/CMakeLists.txt | 16 - lib/config.h.in | 2 - lib/device.cc | 16 - lib/miri/CMakeLists.txt | 36 -- lib/miri/miri_source_c.cc | 451 ------------------------ lib/miri/miri_source_c.h | 135 -------- lib/osmosdr/CMakeLists.txt | 36 -- lib/osmosdr/osmosdr_src_c.cc | 533 ----------------------------- lib/osmosdr/osmosdr_src_c.h | 140 -------- lib/source_impl.cc | 36 -- 15 files changed, 1463 deletions(-) delete mode 100644 cmake/Modules/FindLibMiriSDR.cmake delete mode 100644 cmake/Modules/FindLibOsmoSDR.cmake delete mode 100644 lib/miri/CMakeLists.txt delete mode 100644 lib/miri/miri_source_c.cc delete mode 100644 lib/miri/miri_source_c.h delete mode 100644 lib/osmosdr/CMakeLists.txt delete mode 100644 lib/osmosdr/osmosdr_src_c.cc delete mode 100644 lib/osmosdr/osmosdr_src_c.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9679f88c64..b6e2ed14f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,9 +165,7 @@ message (STATUS " Found Volk: ${Volk_FOUND}") # Hardware drivers #################### -#find_package(LibOsmoSDR) find_package(LibRTLSDR) -#find_package(LibMiriSDR) if(ENABLE_NONFREE) find_package(LibSDRplay) endif(ENABLE_NONFREE) diff --git a/README b/README index 67fa475e74..842c154b90 100644 --- a/README +++ b/README @@ -3,10 +3,8 @@ as well supports: * FUNcube Dongle through libgnuradio-fcd * FUNcube Dongle Pro+ through gr-fcdproplus - * sysmocom OsmoSDR Devices through libosmosdr * RTL2832U based DVB-T dongles through librtlsdr * RTL-TCP spectrum server (see librtlsdr project) - * MSi2500 based DVB-T dongles through libmirisdr * SDRplay RSP through SDRplay API library * gnuradio .cfile input through libgnuradio-blocks * RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option) diff --git a/cmake/Modules/FindLibMiriSDR.cmake b/cmake/Modules/FindLibMiriSDR.cmake deleted file mode 100644 index cdb673ff95..0000000000 --- a/cmake/Modules/FindLibMiriSDR.cmake +++ /dev/null @@ -1,27 +0,0 @@ -if(NOT LIBMIRISDR_FOUND) - pkg_check_modules (LIBMIRISDR_PKG libmirisdr) - find_path(LIBMIRISDR_INCLUDE_DIRS NAMES mirisdr.h - PATHS - ${LIBMIRISDR_PKG_INCLUDE_DIRS} - /usr/include - /usr/local/include - ) - - find_library(LIBMIRISDR_LIBRARIES NAMES mirisdr - PATHS - ${LIBMIRISDR_PKG_LIBRARY_DIRS} - /usr/lib - /usr/local/lib - ) - -if(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES) - set(LIBMIRISDR_FOUND TRUE CACHE INTERNAL "libmirisdr found") - message(STATUS "Found libmirisdr: ${LIBMIRISDR_INCLUDE_DIRS}, ${LIBMIRISDR_LIBRARIES}") -else(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES) - set(LIBMIRISDR_FOUND FALSE CACHE INTERNAL "libmirisdr found") - message(STATUS "libmirisdr not found.") -endif(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES) - -mark_as_advanced(LIBMIRISDR_LIBRARIES LIBMIRISDR_INCLUDE_DIRS) - -endif(NOT LIBMIRISDR_FOUND) diff --git a/cmake/Modules/FindLibOsmoSDR.cmake b/cmake/Modules/FindLibOsmoSDR.cmake deleted file mode 100644 index a772e680ea..0000000000 --- a/cmake/Modules/FindLibOsmoSDR.cmake +++ /dev/null @@ -1,27 +0,0 @@ -if(NOT LIBOSMOSDR_FOUND) - pkg_check_modules (LIBOSMOSDR_PKG libosmosdr) - find_path(LIBOSMOSDR_INCLUDE_DIRS NAMES osmosdr.h - PATHS - ${LIBOSMOSDR_PKG_INCLUDE_DIRS} - /usr/include - /usr/local/include - ) - - find_library(LIBOSMOSDR_LIBRARIES NAMES osmosdr - PATHS - ${LIBOSMOSDR_PKG_LIBRARY_DIRS} - /usr/lib - /usr/local/lib - ) - -if(LIBOSMOSDR_INCLUDE_DIRS AND LIBOSMOSDR_LIBRARIES) - set(LIBOSMOSDR_FOUND TRUE CACHE INTERNAL "libosmosdr found") - message(STATUS "Found libosmosdr: ${LIBOSMOSDR_INCLUDE_DIRS}, ${LIBOSMOSDR_LIBRARIES}") -else(LIBOSMOSDR_INCLUDE_DIRS AND LIBOSMOSDR_LIBRARIES) - set(LIBOSMOSDR_FOUND FALSE CACHE INTERNAL "libosmosdr found") - message(STATUS "libosmosdr not found.") -endif(LIBOSMOSDR_INCLUDE_DIRS AND LIBOSMOSDR_LIBRARIES) - -mark_as_advanced(LIBOSMOSDR_LIBRARIES LIBOSMOSDR_INCLUDE_DIRS) - -endif(NOT LIBOSMOSDR_FOUND) diff --git a/grc/gen_osmosdr_blocks.py b/grc/gen_osmosdr_blocks.py index bfe81f23c4..45bac1f984 100644 --- a/grc/gen_osmosdr_blocks.py +++ b/grc/gen_osmosdr_blocks.py @@ -157,10 +157,8 @@ documentation: |- While primarily being developed for the OsmoSDR hardware, this block as well supports: % if sourk == 'source': - * sysmocom OsmoSDR Devices through libosmosdr * RTL2832U based DVB-T dongles through librtlsdr * RTL-TCP spectrum server (see librtlsdr project) - * MSi2500 based DVB-T dongles through libmirisdr * SDRplay RSP devices through SDRplay library * gnuradio .cfile input through libgnuradio-blocks * RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option) @@ -192,13 +190,11 @@ documentation: |- Lines ending with ... mean it's possible to bind devices together by specifying multiple device arguments separated with a space. % if sourk == 'source': - miri=0[,buffers=32] ... rtl=serial_number ... rtl=0[,rtl_xtal=28.8e6][,tuner_xtal=28.8e6] ... rtl=1[,buffers=32][,buflen=N*512] ... rtl=2[,direct_samp=0|1|2][,offset_tune=0|1][,bias=0|1] ... rtl_tcp=127.0.0.1:1234[,psize=16384][,direct_samp=0|1|2][,offset_tune=0|1][,bias=0|1] ... - osmosdr=0[,buffers=32][,buflen=N*512] ... file='/path/to/your file',rate=1e6[,freq=100e6][,repeat=true][,throttle=true] ... netsdr=127.0.0.1[:50000][,nchan=2] sdr-ip=127.0.0.1[:50000] diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f699c0d7e5..bf974d8caf 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -135,14 +135,6 @@ if(ENABLE_IQBALANCE) APPEND_LIB_LIST( gnuradio::gnuradio-iqbalance) endif(ENABLE_IQBALANCE) -######################################################################## -# Setup OsmoSDR component -######################################################################## -#GR_REGISTER_COMPONENT("sysmocom OsmoSDR" ENABLE_OSMOSDR LIBOSMOSDR_FOUND) -#if(ENABLE_OSMOSDR) -# add_subdirectory(osmosdr) -#endif(ENABLE_OSMOSDR) - ######################################################################## # Setup FCD component ######################################################################## @@ -183,14 +175,6 @@ if(ENABLE_UHD) add_subdirectory(uhd) endif(ENABLE_UHD) -######################################################################## -# Setup MiriSDR component -######################################################################## -#GR_REGISTER_COMPONENT("Osmocom MiriSDR" ENABLE_MIRI LIBMIRISDR_FOUND) -#if(ENABLE_MIRI) -# add_subdirectory(miri) -#endif(ENABLE_MIRI) - ######################################################################## # Setup SDRplay component ######################################################################## diff --git a/lib/config.h.in b/lib/config.h.in index 5303d7dbbc..cce87e6b3b 100644 --- a/lib/config.h.in +++ b/lib/config.h.in @@ -4,13 +4,11 @@ #define GR_OSMOSDR_VERSION "@VERSION@" #define GR_OSMOSDR_LIBVER "@LIBVER@" -#cmakedefine ENABLE_OSMOSDR #cmakedefine ENABLE_FCD #cmakedefine ENABLE_FILE #cmakedefine ENABLE_RTL #cmakedefine ENABLE_RTL_TCP #cmakedefine ENABLE_UHD -#cmakedefine ENABLE_MIRI #cmakedefine ENABLE_SDRPLAY #cmakedefine ENABLE_HACKRF #cmakedefine ENABLE_BLADERF diff --git a/lib/device.cc b/lib/device.cc index 015383dbd4..91f5aefdfd 100644 --- a/lib/device.cc +++ b/lib/device.cc @@ -30,10 +30,6 @@ #include "config.h" #endif -#ifdef ENABLE_OSMOSDR -#include -#endif - #ifdef ENABLE_FCD #include #endif @@ -54,10 +50,6 @@ #include #endif -#ifdef ENABLE_MIRI -#include -#endif - #ifdef ENABLE_SDRPLAY #include #endif @@ -150,10 +142,6 @@ devices_t device::find(const device_t &hint) devices_t devices; -#ifdef ENABLE_OSMOSDR - BOOST_FOREACH( std::string dev, osmosdr_src_c::get_devices() ) - devices.push_back( device_t(dev) ); -#endif #ifdef ENABLE_FCD BOOST_FOREACH( std::string dev, fcd_source_c::get_devices() ) devices.push_back( device_t(dev) ); @@ -166,10 +154,6 @@ devices_t device::find(const device_t &hint) BOOST_FOREACH( std::string dev, uhd_source_c::get_devices() ) devices.push_back( device_t(dev) ); #endif -#ifdef ENABLE_MIRI - BOOST_FOREACH( std::string dev, miri_source_c::get_devices() ) - devices.push_back( device_t(dev) ); -#endif #ifdef ENABLE_SDRPLAY BOOST_FOREACH( std::string dev, sdrplay_source_c::get_devices() ) devices.push_back( device_t(dev) ); diff --git a/lib/miri/CMakeLists.txt b/lib/miri/CMakeLists.txt deleted file mode 100644 index 672fc903ed..0000000000 --- a/lib/miri/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2012 Free Software Foundation, Inc. -# -# This file is part of gr-osmosdr -# -# gr-osmosdr 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. -# -# gr-osmosdr 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 gr-osmosdr; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -target_include_directories(gnuradio-osmosdr PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${LIBMIRISDR_INCLUDE_DIRS} -) - -APPEND_LIB_LIST( - ${LIBMIRISDR_LIBRARIES} -) - -list(APPEND gr_osmosdr_srcs - ${CMAKE_CURRENT_SOURCE_DIR}/miri_source_c.cc -) -set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) diff --git a/lib/miri/miri_source_c.cc b/lib/miri/miri_source_c.cc deleted file mode 100644 index c1b9428fbb..0000000000 --- a/lib/miri/miri_source_c.cc +++ /dev/null @@ -1,451 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Dimitri Stolnikov - * Copyright 2012 Steve Markgraf - * - * 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. - */ - -/* - * config.h is generated by configure. It contains the results - * of probing for features, options etc. It should be the first - * file included in your .cc file. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "miri_source_c.h" -#include - -#include -#include - -#include -#include -#include - -#include - -#include "arg_helpers.h" - -using namespace boost::assign; - -#define BUF_SIZE 2304 * 8 * 2 -#define BUF_NUM 15 -#define BUF_SKIP 1 // buffers to skip due to garbage - -#define BYTES_PER_SAMPLE 4 // mirisdr device delivers 16 bit signed IQ data - // containing 12 bits of information - -/* - * Create a new instance of miri_source_c and return - * a boost shared_ptr. This is effectively the public constructor. - */ -miri_source_c_sptr -make_miri_source_c (const std::string &args) -{ - return gnuradio::get_initial_sptr(new miri_source_c (args)); -} - -/* - * Specify constraints on number of input and output streams. - * This info is used to construct the input and output signatures - * (2nd & 3rd args to gr::block's constructor). The input and - * output signatures are used by the runtime system to - * check that a valid number and type of inputs and outputs - * are connected to this block. In this case, we accept - * only 0 input and 1 output. - */ -static const int MIN_IN = 0; // mininum number of input streams -static const int MAX_IN = 0; // maximum number of input streams -static const int MIN_OUT = 1; // minimum number of output streams -static const int MAX_OUT = 1; // maximum number of output streams - -/* - * The private constructor - */ -miri_source_c::miri_source_c (const std::string &args) - : gr::sync_block ("miri_source_c", - gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)), - gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))), - _running(true), - _auto_gain(false), - _skipped(0) -{ - int ret; - unsigned int dev_index = 0; - - dict_t dict = params_to_dict(args); - - if (dict.count("miri")) - dev_index = boost::lexical_cast< unsigned int >( dict["miri"] ); - - _buf_num = _buf_head = _buf_used = _buf_offset = 0; - _samp_avail = BUF_SIZE / BYTES_PER_SAMPLE; - - if (dict.count("buffers")) - _buf_num = boost::lexical_cast< unsigned int >( dict["buffers"] ); - - if (0 == _buf_num) - _buf_num = BUF_NUM; - - if ( BUF_NUM != _buf_num ) { - std::cerr << "Using " << _buf_num << " buffers of size " << BUF_SIZE << "." - << std::endl; - } - - if ( dev_index >= mirisdr_get_device_count() ) - throw std::runtime_error("Wrong mirisdr device index given."); - - std::cerr << "Using device #" << dev_index << ": " - << mirisdr_get_device_name(dev_index) - << std::endl; - - _dev = NULL; - ret = mirisdr_open( &_dev, dev_index ); - if (ret < 0) - throw std::runtime_error("Failed to open mirisdr device."); -#if 0 - ret = mirisdr_set_sample_rate( _dev, 500000 ); - if (ret < 0) - throw std::runtime_error("Failed to set default samplerate."); - - ret = mirisdr_set_tuner_gain_mode(_dev, int(!_auto_gain)); - if (ret < 0) - throw std::runtime_error("Failed to enable manual gain mode."); -#endif - ret = mirisdr_reset_buffer( _dev ); - if (ret < 0) - throw std::runtime_error("Failed to reset usb buffers."); - - _buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *)); - _buf_lens = (unsigned int *) malloc(_buf_num * sizeof(unsigned int)); - - if (_buf && _buf_lens) { - for(unsigned int i = 0; i < _buf_num; ++i) - _buf[i] = (unsigned short *) malloc(BUF_SIZE); - } - - _thread = gr::thread::thread(_mirisdr_wait, this); -} - -/* - * Our virtual destructor. - */ -miri_source_c::~miri_source_c () -{ - if (_dev) { - _running = false; - mirisdr_cancel_async( _dev ); - _thread.join(); - mirisdr_close( _dev ); - _dev = NULL; - } - - if (_buf) { - for(unsigned int i = 0; i < _buf_num; ++i) { - free(_buf[i]); - } - - free(_buf); - _buf = NULL; - free(_buf_lens); - _buf_lens = NULL; - } -} - -void miri_source_c::_mirisdr_callback(unsigned char *buf, uint32_t len, void *ctx) -{ - miri_source_c *obj = (miri_source_c *)ctx; - obj->mirisdr_callback(buf, len); -} - -void miri_source_c::mirisdr_callback(unsigned char *buf, uint32_t len) -{ - if (_skipped < BUF_SKIP) { - _skipped++; - return; - } - - { - std::lock_guard lock( _buf_mutex ); - - if (len > BUF_SIZE) - throw std::runtime_error("Buffer too small."); - - int buf_tail = (_buf_head + _buf_used) % _buf_num; - memcpy(_buf[buf_tail], buf, len); - _buf_lens[buf_tail] = len; - - if (_buf_used == _buf_num) { - std::cerr << "O" << std::flush; - _buf_head = (_buf_head + 1) % _buf_num; - } else { - _buf_used++; - } - } - - _buf_cond.notify_one(); -} - -void miri_source_c::_mirisdr_wait(miri_source_c *obj) -{ - obj->mirisdr_wait(); -} - -void miri_source_c::mirisdr_wait() -{ - int ret = mirisdr_read_async( _dev, _mirisdr_callback, (void *)this, _buf_num, BUF_SIZE ); - - _running = false; - - if ( ret != 0 ) - std::cerr << "mirisdr_read_async returned with " << ret << std::endl; - - _buf_cond.notify_one(); -} - -int miri_source_c::work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items ) -{ - gr_complex *out = (gr_complex *)output_items[0]; - - { - std::unique_lock lock( _buf_mutex ); - - while (_buf_used < 3 && _running) // collect at least 3 buffers - _buf_cond.wait( lock ); - } - - if (!_running) - return WORK_DONE; - - short *buf = (short *)_buf[_buf_head] + _buf_offset; - - if (noutput_items <= _samp_avail) { - for (int i = 0; i < noutput_items; i++) - *out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/4096.0f), - float(*(buf + i * 2 + 1)) * (1.0f/4096.0f) ); - - _buf_offset += noutput_items * 2; - _samp_avail -= noutput_items; - } else { - for (int i = 0; i < _samp_avail; i++) - *out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/4096.0f), - float(*(buf + i * 2 + 1)) * (1.0f/4096.0f) ); - - { - std::lock_guard lock( _buf_mutex ); - - _buf_head = (_buf_head + 1) % _buf_num; - _buf_used--; - } - - buf = (short *)_buf[_buf_head]; - - int remaining = noutput_items - _samp_avail; - - for (int i = 0; i < remaining; i++) - *out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/4096.0f), - float(*(buf + i * 2 + 1)) * (1.0f/4096.0f) ); - - _buf_offset = remaining * 2; - _samp_avail = (_buf_lens[_buf_head] / BYTES_PER_SAMPLE) - remaining; - } - - return noutput_items; -} - -std::vector miri_source_c::get_devices() -{ - std::vector devices; - - for (unsigned int i = 0; i < mirisdr_get_device_count(); i++) { - std::string args = "miri=" + boost::lexical_cast< std::string >( i ); - args += ",label='" + std::string(mirisdr_get_device_name( i )) + "'"; - devices.push_back( args ); - } - - return devices; -} - -size_t miri_source_c::get_num_channels() -{ - return 1; -} - -osmosdr::meta_range_t miri_source_c::get_sample_rates() -{ - osmosdr::meta_range_t range; - - range += osmosdr::range_t( 8000000 ); // known to work - - return range; -} - -double miri_source_c::set_sample_rate(double rate) -{ - if (_dev) { - mirisdr_set_sample_rate( _dev, (uint32_t)rate ); - } - - return get_sample_rate(); -} - -double miri_source_c::get_sample_rate() -{ - if (_dev) - return (double)mirisdr_get_sample_rate( _dev ); - - return 0; -} - -osmosdr::freq_range_t miri_source_c::get_freq_range( size_t chan ) -{ - osmosdr::freq_range_t range; - - range += osmosdr::range_t( 150e3, 30e6 ); /* LW/MW/SW (150 kHz - 30 MHz) */ - range += osmosdr::range_t( 64e6, 108e6 ); /* VHF Band II (64 - 108 MHz) */ - range += osmosdr::range_t( 162e6, 240e6 ); /* Band III (162 - 240 MHz) */ - range += osmosdr::range_t( 470e6, 960e6 ); /* Band IV/V (470 - 960 MHz) */ - range += osmosdr::range_t( 1450e6, 1675e6 ); /* L-Band (1450 - 1675 MHz) */ - - return range; -} - -double miri_source_c::set_center_freq( double freq, size_t chan ) -{ - if (_dev) - mirisdr_set_center_freq( _dev, (uint32_t)freq ); - - return get_center_freq( chan ); -} - -double miri_source_c::get_center_freq( size_t chan ) -{ - if (_dev) - return (double)mirisdr_get_center_freq( _dev ); - - return 0; -} - -double miri_source_c::set_freq_corr( double ppm, size_t chan ) -{ - return get_freq_corr( chan ); -} - -double miri_source_c::get_freq_corr( size_t chan ) -{ - return 0; -} - -std::vector miri_source_c::get_gain_names( size_t chan ) -{ - std::vector< std::string > gains; - - gains += "LNA"; - - return gains; -} - -osmosdr::gain_range_t miri_source_c::get_gain_range( size_t chan ) -{ - osmosdr::gain_range_t range; - - if (_dev) { - int count = mirisdr_get_tuner_gains(_dev, NULL); - if (count > 0) { - int* gains = new int[ count ]; - count = mirisdr_get_tuner_gains(_dev, gains); - for (int i = 0; i < count; i++) - range += osmosdr::range_t( gains[i] / 10.0 ); - delete[] gains; - } - } - - return range; -} - -osmosdr::gain_range_t miri_source_c::get_gain_range( const std::string & name, size_t chan ) -{ - return get_gain_range( chan ); -} - -bool miri_source_c::set_gain_mode( bool automatic, size_t chan ) -{ - if (_dev) { - if (!mirisdr_set_tuner_gain_mode(_dev, int(!automatic))) { - _auto_gain = automatic; - } - } - - return get_gain_mode(chan); -} - -bool miri_source_c::get_gain_mode( size_t chan ) -{ - return _auto_gain; -} - -double miri_source_c::set_gain( double gain, size_t chan ) -{ - osmosdr::gain_range_t rf_gains = miri_source_c::get_gain_range( chan ); - - if (_dev) { - mirisdr_set_tuner_gain( _dev, int(rf_gains.clip(gain) * 10.0) ); - } - - return get_gain( chan ); -} - -double miri_source_c::set_gain( double gain, const std::string & name, size_t chan) -{ - return set_gain( gain, chan ); -} - -double miri_source_c::get_gain( size_t chan ) -{ - if ( _dev ) - return ((double)mirisdr_get_tuner_gain( _dev )) / 10.0; - - return 0; -} - -double miri_source_c::get_gain( const std::string & name, size_t chan ) -{ - return get_gain( chan ); -} - -std::vector< std::string > miri_source_c::get_antennas( size_t chan ) -{ - std::vector< std::string > antennas; - - antennas += get_antenna( chan ); - - return antennas; -} - -std::string miri_source_c::set_antenna( const std::string & antenna, size_t chan ) -{ - return get_antenna( chan ); -} - -std::string miri_source_c::get_antenna( size_t chan ) -{ - return "RX"; -} diff --git a/lib/miri/miri_source_c.h b/lib/miri/miri_source_c.h deleted file mode 100644 index 1ea906f27a..0000000000 --- a/lib/miri/miri_source_c.h +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Dimitri Stolnikov - * - * 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_MIRI_SOURCE_C_H -#define INCLUDED_MIRI_SOURCE_C_H - -#include - -#include - -#include -#include - -#include "source_iface.h" - -class miri_source_c; -typedef struct mirisdr_dev mirisdr_dev_t; - -/* - * We use boost::shared_ptr's instead of raw pointers for all access - * to gr::blocks (and many other data structures). The shared_ptr gets - * us transparent reference counting, which greatly simplifies storage - * management issues. This is especially helpful in our hybrid - * C++ / Python system. - * - * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm - * - * As a convention, the _sptr suffix indicates a boost::shared_ptr - */ -typedef boost::shared_ptr miri_source_c_sptr; - -/*! - * \brief Return a shared_ptr to a new instance of miri_source_c. - * - * To avoid accidental use of raw pointers, miri_source_c's - * constructor is private. make_miri_source_c is the public - * interface for creating new instances. - */ -miri_source_c_sptr make_miri_source_c (const std::string & args = ""); - -/*! - * \brief Provides a stream of complex samples. - * \ingroup block - */ -class miri_source_c : - public gr::sync_block, - public source_iface -{ -private: - // The friend declaration allows make_miri_source_c to - // access the private constructor. - - friend miri_source_c_sptr make_miri_source_c (const std::string & args); - - /*! - * \brief Provides a stream of complex samples. - */ - miri_source_c (const std::string & args); // private constructor - - public: - ~miri_source_c (); // public destructor - - int work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items ); - - static std::vector< std::string > get_devices(); - - size_t get_num_channels( void ); - - osmosdr::meta_range_t get_sample_rates( void ); - double set_sample_rate( double rate ); - double get_sample_rate( void ); - - osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); - double set_center_freq( double freq, size_t chan = 0 ); - double get_center_freq( size_t chan = 0 ); - double set_freq_corr( double ppm, size_t chan = 0 ); - double get_freq_corr( size_t chan = 0 ); - - std::vector get_gain_names( size_t chan = 0 ); - osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); - osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); - bool set_gain_mode( bool automatic, size_t chan = 0 ); - bool get_gain_mode( size_t chan = 0 ); - double set_gain( double gain, size_t chan = 0 ); - double set_gain( double gain, const std::string & name, size_t chan = 0 ); - double get_gain( size_t chan = 0 ); - double get_gain( const std::string & name, size_t chan = 0 ); - - std::vector< std::string > get_antennas( size_t chan = 0 ); - std::string set_antenna( const std::string & antenna, size_t chan = 0 ); - std::string get_antenna( size_t chan = 0 ); - -private: - static void _mirisdr_callback(unsigned char *buf, uint32_t len, void *ctx); - void mirisdr_callback(unsigned char *buf, uint32_t len); - static void _mirisdr_wait(miri_source_c *obj); - void mirisdr_wait(); - - mirisdr_dev_t *_dev; - gr::thread::thread _thread; - unsigned short **_buf; - unsigned int *_buf_lens; - unsigned int _buf_num; - unsigned int _buf_head; - unsigned int _buf_used; - std::mutex _buf_mutex; - std::condition_variable _buf_cond; - bool _running; - - unsigned int _buf_offset; - int _samp_avail; - - bool _auto_gain; - unsigned int _skipped; -}; - -#endif /* INCLUDED_MIRI_SOURCE_C_H */ diff --git a/lib/osmosdr/CMakeLists.txt b/lib/osmosdr/CMakeLists.txt deleted file mode 100644 index eb540e106f..0000000000 --- a/lib/osmosdr/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2012 Free Software Foundation, Inc. -# -# This file is part of gr-osmosdr -# -# gr-osmosdr 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. -# -# gr-osmosdr 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 gr-osmosdr; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -######################################################################## -# This file included, use CMake directory variables -######################################################################## - -target_include_directories(gnuradio-osmosdr PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${LIBOSMOSDR_INCLUDE_DIRS} -) - -APPEND_LIB_LIST( - ${LIBOSMOSDR_LIBRARIES} -) - -list(APPEND gr_osmosdr_srcs - ${CMAKE_CURRENT_SOURCE_DIR}/osmosdr_src_c.cc -) -set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) diff --git a/lib/osmosdr/osmosdr_src_c.cc b/lib/osmosdr/osmosdr_src_c.cc deleted file mode 100644 index e4f8b89944..0000000000 --- a/lib/osmosdr/osmosdr_src_c.cc +++ /dev/null @@ -1,533 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Dimitri Stolnikov - * - * 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. - */ - -/* - * config.h is generated by configure. It contains the results - * of probing for features, options etc. It should be the first - * file included in your .cc file. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "osmosdr_src_c.h" -#include - -#include -#include - -#include -#include -#include - -#include - -#include "arg_helpers.h" - -using namespace boost::assign; - -#define BUF_LEN (16 * 32 * 512) /* must be multiple of 512 */ -#define BUF_NUM 15 -#define BUF_SKIP 1 // buffers to skip due to garbage - -#define BYTES_PER_SAMPLE 4 // osmosdr device delivers 16 bit signed IQ data - -/* - * Create a new instance of osmosdr_src_c and return - * a boost shared_ptr. This is effectively the public constructor. - */ -osmosdr_src_c_sptr -osmosdr_make_src_c (const std::string &args) -{ - return gnuradio::get_initial_sptr(new osmosdr_src_c (args)); -} - -/* - * The private constructor - */ -osmosdr_src_c::osmosdr_src_c (const std::string &args) - : gr::sync_block ("osmosdr_src_c", - gr::io_signature::make(0, 0, sizeof (gr_complex)), - gr::io_signature::make(1, 1, sizeof (gr_complex)) ), - _dev(NULL), - _buf(NULL), - _running(true), - _auto_gain(false), - _if_gain(0), - _skipped(0) -{ - int ret; - unsigned int dev_index = 0; - - dict_t dict = params_to_dict(args); - - if (dict.count("osmosdr")) - dev_index = boost::lexical_cast< unsigned int >( dict["osmosdr"] ); - - _buf_num = _buf_len = _buf_head = _buf_used = _buf_offset = 0; - - if (dict.count("buffers")) - _buf_num = boost::lexical_cast< unsigned int >( dict["buffers"] ); - - if (dict.count("buflen")) - _buf_len = boost::lexical_cast< unsigned int >( dict["buflen"] ); - - if (0 == _buf_num) - _buf_num = BUF_NUM; - - if (0 == _buf_len || _buf_len % 512 != 0) /* len must be multiple of 512 */ - _buf_len = BUF_LEN; - - if ( BUF_NUM != _buf_num || BUF_LEN != _buf_len ) { - std::cerr << "Using " << _buf_num << " buffers of size " << _buf_len << "." - << std::endl; - } - - _samp_avail = _buf_len / BYTES_PER_SAMPLE; - - if ( dev_index >= osmosdr_get_device_count() ) - throw std::runtime_error("Wrong osmosdr device index given."); - - std::cerr << "Using device #" << dev_index << ": " - << osmosdr_get_device_name(dev_index) - << std::endl; - - _dev = NULL; - ret = osmosdr_open( &_dev, dev_index ); - if (ret < 0) - throw std::runtime_error("Failed to open osmosdr device."); - - ret = osmosdr_set_fpga_iq_swap(_dev, 0); - if (ret < 0) - throw std::runtime_error("Failed to disable IQ swapping."); - - ret = osmosdr_set_sample_rate( _dev, 500000 ); - if (ret < 0) - throw std::runtime_error("Failed to set default samplerate."); - - ret = osmosdr_set_tuner_gain_mode(_dev, int(!_auto_gain)); - if (ret < 0) - throw std::runtime_error("Failed to enable manual gain mode."); - - ret = osmosdr_reset_buffer( _dev ); - if (ret < 0) - throw std::runtime_error("Failed to reset usb buffers."); - - set_if_gain( 24 ); /* preset to a reasonable default (non-GRC use case) */ - - _buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *)); - - if (_buf) { - for(unsigned int i = 0; i < _buf_num; ++i) - _buf[i] = (unsigned short *) malloc(_buf_len); - } - - _thread = gr::thread::thread(_osmosdr_wait, this); -} - -/* - * Our virtual destructor. - */ -osmosdr_src_c::~osmosdr_src_c () -{ - if (_dev) { - _running = false; - osmosdr_cancel_async( _dev ); - _thread.join(); - osmosdr_close( _dev ); - _dev = NULL; - } - - if (_buf) { - for(unsigned int i = 0; i < _buf_num; ++i) { - free(_buf[i]); - } - - free(_buf); - _buf = NULL; - } -} - -void osmosdr_src_c::_osmosdr_callback(unsigned char *buf, uint32_t len, void *ctx) -{ - osmosdr_src_c *obj = (osmosdr_src_c *)ctx; - obj->osmosdr_callback(buf, len); -} - -void osmosdr_src_c::osmosdr_callback(unsigned char *buf, uint32_t len) -{ - if (_skipped < BUF_SKIP) { - _skipped++; - return; - } - - { - std::lock_guard lock( _buf_mutex ); - - int buf_tail = (_buf_head + _buf_used) % _buf_num; - memcpy(_buf[buf_tail], buf, len); - - if (_buf_used == _buf_num) { - std::cerr << "O" << std::flush; - _buf_head = (_buf_head + 1) % _buf_num; - } else { - _buf_used++; - } - } - - _buf_cond.notify_one(); -} - -void osmosdr_src_c::_osmosdr_wait(osmosdr_src_c *obj) -{ - obj->osmosdr_wait(); -} - -void osmosdr_src_c::osmosdr_wait() -{ - int ret = osmosdr_read_async( _dev, _osmosdr_callback, (void *)this, _buf_num, _buf_len ); - - _running = false; - - if ( ret != 0 ) - std::cerr << "osmosdr_read_async returned with " << ret << std::endl; - - _buf_cond.notify_one(); -} - -int osmosdr_src_c::work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items ) -{ - gr_complex *out = (gr_complex *)output_items[0]; - - { - std::unique_lock lock( _buf_mutex ); - - while (_buf_used < 3 && _running) // collect at least 3 buffers - _buf_cond.wait( lock ); - } - - if (!_running) - return WORK_DONE; - - short *buf = (short *)_buf[_buf_head] + _buf_offset; - - if (noutput_items <= _samp_avail) { - for (int i = 0; i < noutput_items; i++) - *out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/32767.5f), - float(*(buf + i * 2 + 1)) * (1.0f/32767.5f) ); - - _buf_offset += noutput_items * 2; - _samp_avail -= noutput_items; - } else { - for (int i = 0; i < _samp_avail; i++) - *out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/32767.5f), - float(*(buf + i * 2 + 1)) * (1.0f/32767.5f) ); - - { - std::lock_guard lock( _buf_mutex ); - - _buf_head = (_buf_head + 1) % _buf_num; - _buf_used--; - } - - buf = (short *)_buf[_buf_head]; - - int remaining = noutput_items - _samp_avail; - - for (int i = 0; i < remaining; i++) - *out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/32767.5f), - float(*(buf + i * 2 + 1)) * (1.0f/32767.5f) ); - - _buf_offset = remaining * 2; - _samp_avail = (_buf_len / BYTES_PER_SAMPLE) - remaining; - } - - return noutput_items; -} - -std::vector osmosdr_src_c::get_devices() -{ - std::vector< std::string > devices; - char buffer[256]; - - for (unsigned int i = 0; i < osmosdr_get_device_count(); i++) { - std::string args = "osmosdr=" + boost::lexical_cast< std::string >( i ); - - std::string label = std::string(osmosdr_get_device_name( i )); - - memset(buffer, 0, sizeof(buffer)); - osmosdr_get_device_usb_strings( i, NULL, NULL, buffer ); - std::string serial = std::string(buffer); - - if (serial.length()) - label += " " + serial; - - args += ",label='" + label + + "'"; - - devices.push_back( args ); - } - - return devices; -} - -size_t osmosdr_src_c::get_num_channels() -{ - return 1; -} - -osmosdr::meta_range_t osmosdr_src_c::get_sample_rates() -{ - osmosdr::meta_range_t range; - - if (_dev) { - int count = osmosdr_get_sample_rates(_dev, NULL); - if (count > 0) { - uint32_t* rates = new uint32_t[ count ]; - count = osmosdr_get_sample_rates(_dev, rates); - for (int i = 0; i < count; i++) - range += osmosdr::range_t( rates[i] ); - delete[] rates; - } - } - - return range; -} - -double osmosdr_src_c::set_sample_rate(double rate) -{ - if (_dev) { - osmosdr_set_sample_rate( _dev, (uint32_t)rate ); - } - - return get_sample_rate(); -} - -double osmosdr_src_c::get_sample_rate() -{ - if (_dev) - return (double)osmosdr_get_sample_rate( _dev ); - - return 0; -} - -osmosdr::freq_range_t osmosdr_src_c::get_freq_range( size_t chan ) -{ - osmosdr::freq_range_t range; - - /* there is a (temperature dependent) gap between 1100 to 1250 MHz */ - range += osmosdr::range_t( 52e6, 2.2e9 ); - - return range; -} - -double osmosdr_src_c::set_center_freq( double freq, size_t chan ) -{ - if (_dev) - osmosdr_set_center_freq( _dev, (uint32_t)freq ); - - return get_center_freq( chan ); -} - -double osmosdr_src_c::get_center_freq( size_t chan ) -{ - if (_dev) - return (double)osmosdr_get_center_freq( _dev ); - - return 0; -} - -double osmosdr_src_c::set_freq_corr( double ppm, size_t chan ) -{ - return get_freq_corr( chan ); -} - -double osmosdr_src_c::get_freq_corr( size_t chan ) -{ - return 0; -} - -std::vector osmosdr_src_c::get_gain_names( size_t chan ) -{ - std::vector< std::string > names; - - names += "LNA"; - names += "IF"; - - return names; -} - -osmosdr::gain_range_t osmosdr_src_c::get_gain_range( size_t chan ) -{ - osmosdr::gain_range_t range; - - if (_dev) { - int count = osmosdr_get_tuner_gains(_dev, NULL); - if (count > 0) { - int* gains = new int[ count ]; - count = osmosdr_get_tuner_gains(_dev, gains); - for (int i = 0; i < count; i++) - range += osmosdr::range_t( gains[i] / 10.0 ); - delete[] gains; - } - } - - return range; -} - -osmosdr::gain_range_t osmosdr_src_c::get_gain_range( const std::string & name, size_t chan ) -{ - if ( "IF" == name ) { - return osmosdr::gain_range_t(3, 56, 1); - } - - return get_gain_range( chan ); -} - -bool osmosdr_src_c::set_gain_mode( bool automatic, size_t chan ) -{ - if (_dev) { - if (!osmosdr_set_tuner_gain_mode(_dev, int(!automatic))) { - _auto_gain = automatic; - } - } - - return get_gain_mode(chan); -} - -bool osmosdr_src_c::get_gain_mode( size_t chan ) -{ - return _auto_gain; -} - -double osmosdr_src_c::set_gain( double gain, size_t chan ) -{ - osmosdr::gain_range_t rf_gains = osmosdr_src_c::get_gain_range( chan ); - - if (_dev) { - osmosdr_set_tuner_gain( _dev, int(rf_gains.clip(gain) * 10.0) ); - } - - return get_gain( chan ); -} - -double osmosdr_src_c::set_gain( double gain, const std::string & name, size_t chan) -{ - if ( "IF" == name ) { - return set_if_gain( gain, chan ); - } - - return set_gain( gain, chan ); -} - -double osmosdr_src_c::get_gain( size_t chan ) -{ - if ( _dev ) - return ((double)osmosdr_get_tuner_gain( _dev )) / 10.0; - - return 0; -} - -double osmosdr_src_c::get_gain( const std::string & name, size_t chan ) -{ - if ( "IF" == name ) { - return _if_gain; - } - - return get_gain( chan ); -} - -double osmosdr_src_c::set_if_gain(double gain, size_t chan) -{ - std::vector< osmosdr::gain_range_t > if_gains; - - if_gains += osmosdr::gain_range_t(-3, 6, 9); - if_gains += osmosdr::gain_range_t(0, 9, 3); - if_gains += osmosdr::gain_range_t(0, 9, 3); - if_gains += osmosdr::gain_range_t(0, 2, 1); - if_gains += osmosdr::gain_range_t(3, 15, 3); - if_gains += osmosdr::gain_range_t(3, 15, 3); - - std::map< int, double > gains; - - /* initialize with min gains */ - for (unsigned int i = 0; i < if_gains.size(); i++) { - gains[ i + 1 ] = if_gains[ i ].start(); - } - - for (int i = if_gains.size() - 1; i >= 0; i--) { - osmosdr::gain_range_t range = if_gains[ i ]; - - double error = gain; - - for( double g = range.start(); g <= range.stop(); g += range.step() ) { - - double sum = 0; - for (int j = 0; j < int(gains.size()); j++) { - if ( i == j ) - sum += g; - else - sum += gains[ j + 1 ]; - } - - double err = abs(gain - sum); - if (err < error) { - error = err; - gains[ i + 1 ] = g; - } - } - } -#if 0 - std::cerr << gain << " => "; double sum = 0; - for (unsigned int i = 0; i < gains.size(); i++) { - sum += gains[ i + 1 ]; - std::cerr << gains[ i + 1 ] << " "; - } - std::cerr << " = " << sum << std::endl; -#endif - if (_dev) { - for (unsigned int stage = 1; stage <= gains.size(); stage++) { - osmosdr_set_tuner_if_gain( _dev, stage, int(gains[ stage ] * 10.0)); - } - } - - _if_gain = gain; - return gain; -} - -std::vector< std::string > osmosdr_src_c::get_antennas( size_t chan ) -{ - std::vector< std::string > antennas; - - antennas += get_antenna( chan ); - - return antennas; -} - -std::string osmosdr_src_c::set_antenna( const std::string & antenna, size_t chan ) -{ - return get_antenna( chan ); -} - -std::string osmosdr_src_c::get_antenna( size_t chan ) -{ - return "RX"; -} diff --git a/lib/osmosdr/osmosdr_src_c.h b/lib/osmosdr/osmosdr_src_c.h deleted file mode 100644 index f8f18ec776..0000000000 --- a/lib/osmosdr/osmosdr_src_c.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 Dimitri Stolnikov - * - * 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_OSMOSDR_SRC_C_H -#define INCLUDED_OSMOSDR_SRC_C_H - -#include - -#include - -#include -#include - -#include "source_iface.h" - -class osmosdr_src_c; -typedef struct osmosdr_dev osmosdr_dev_t; - -/* - * We use boost::shared_ptr's instead of raw pointers for all access - * to gr::blocks (and many other data structures). The shared_ptr gets - * us transparent reference counting, which greatly simplifies storage - * management issues. This is especially helpful in our hybrid - * C++ / Python system. - * - * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm - * - * As a convention, the _sptr suffix indicates a boost::shared_ptr - */ -typedef boost::shared_ptr osmosdr_src_c_sptr; - -/*! - * \brief Return a shared_ptr to a new instance of osmosdr_src_c. - * - * To avoid accidental use of raw pointers, osmosdr_src_c's - * constructor is private. osmosdr_make_src_c is the public - * interface for creating new instances. - */ -osmosdr_src_c_sptr osmosdr_make_src_c (const std::string & args = ""); - -/*! - * \brief Provides a stream of complex samples. - * \ingroup block - * - * \sa sink for a version that subclasses gr::hier_block2. - */ -class osmosdr_src_c : - public gr::sync_block, - public source_iface -{ -private: - // The friend declaration allows osmosdr_make_src_c to - // access the private constructor. - - friend osmosdr_src_c_sptr osmosdr_make_src_c (const std::string & args); - - /*! - * \brief Provides a stream of complex samples. - */ - osmosdr_src_c (const std::string & args); // private constructor - - public: - ~osmosdr_src_c (); // public destructor - - int work( int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items ); - - static std::vector< std::string > get_devices(); - - size_t get_num_channels( void ); - - osmosdr::meta_range_t get_sample_rates( void ); - double set_sample_rate( double rate ); - double get_sample_rate( void ); - - osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); - double set_center_freq( double freq, size_t chan = 0 ); - double get_center_freq( size_t chan = 0 ); - double set_freq_corr( double ppm, size_t chan = 0 ); - double get_freq_corr( size_t chan = 0 ); - - std::vector get_gain_names( size_t chan = 0 ); - osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); - osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); - bool set_gain_mode( bool automatic, size_t chan = 0 ); - bool get_gain_mode( size_t chan = 0 ); - double set_gain( double gain, size_t chan = 0 ); - double set_gain( double gain, const std::string & name, size_t chan = 0 ); - double get_gain( size_t chan = 0 ); - double get_gain( const std::string & name, size_t chan = 0 ); - - double set_if_gain( double gain, size_t chan = 0 ); - - std::vector< std::string > get_antennas( size_t chan = 0 ); - std::string set_antenna( const std::string & antenna, size_t chan = 0 ); - std::string get_antenna( size_t chan = 0 ); - -private: - static void _osmosdr_callback(unsigned char *buf, uint32_t len, void *ctx); - void osmosdr_callback(unsigned char *buf, uint32_t len); - static void _osmosdr_wait(osmosdr_src_c *obj); - void osmosdr_wait(); - - osmosdr_dev_t *_dev; - gr::thread::thread _thread; - unsigned short **_buf; - unsigned int _buf_num; - unsigned int _buf_len; - unsigned int _buf_head; - unsigned int _buf_used; - std::mutex _buf_mutex; - std::condition_variable _buf_cond; - bool _running; - - unsigned int _buf_offset; - int _samp_avail; - - bool _auto_gain; - double _if_gain; - unsigned int _skipped; -}; - -#endif /* INCLUDED_OSMOSDR_SRC_C_H */ diff --git a/lib/source_impl.cc b/lib/source_impl.cc index f1426e0e0b..d95b414345 100644 --- a/lib/source_impl.cc +++ b/lib/source_impl.cc @@ -32,10 +32,6 @@ #include #include -#ifdef ENABLE_OSMOSDR -#include -#endif - #ifdef ENABLE_FCD #include #endif @@ -56,10 +52,6 @@ #include #endif -#ifdef ENABLE_MIRI -#include -#endif - #ifdef ENABLE_SDRPLAY #include #endif @@ -128,9 +120,6 @@ source_impl::source_impl( const std::string &args ) #ifdef ENABLE_FILE dev_types.push_back("file"); #endif -#ifdef ENABLE_OSMOSDR - dev_types.push_back("osmosdr"); -#endif #ifdef ENABLE_FCD dev_types.push_back("fcd"); #endif @@ -143,9 +132,6 @@ source_impl::source_impl( const std::string &args ) #ifdef ENABLE_UHD dev_types.push_back("uhd"); #endif -#ifdef ENABLE_MIRI - dev_types.push_back("miri"); -#endif #ifdef ENABLE_SDRPLAY dev_types.push_back("sdrplay"); #endif @@ -200,10 +186,6 @@ source_impl::source_impl( const std::string &args ) if ( ! device_specified ) { std::vector< std::string > dev_list; -#ifdef ENABLE_OSMOSDR - BOOST_FOREACH( std::string dev, osmosdr_src_c::get_devices() ) - dev_list.push_back( dev ); -#endif #ifdef ENABLE_FCD BOOST_FOREACH( std::string dev, fcd_source_c::get_devices() ) dev_list.push_back( dev ); @@ -216,10 +198,6 @@ source_impl::source_impl( const std::string &args ) BOOST_FOREACH( std::string dev, uhd_source_c::get_devices() ) dev_list.push_back( dev ); #endif -#ifdef ENABLE_MIRI - BOOST_FOREACH( std::string dev, miri_source_c::get_devices() ) - dev_list.push_back( dev ); -#endif #ifdef ENABLE_SDRPLAY BOOST_FOREACH( std::string dev, sdrplay_source_c::get_devices() ) dev_list.push_back( dev ); @@ -278,13 +256,6 @@ source_impl::source_impl( const std::string &args ) source_iface *iface = NULL; gr::basic_block_sptr block; -#ifdef ENABLE_OSMOSDR - if ( dict.count("osmosdr") ) { - osmosdr_src_c_sptr src = osmosdr_make_src_c( arg ); - block = src; iface = src.get(); - } -#endif - #ifdef ENABLE_FCD if ( dict.count("fcd") ) { fcd_source_c_sptr src = make_fcd_source_c( arg ); @@ -320,13 +291,6 @@ source_impl::source_impl( const std::string &args ) } #endif -#ifdef ENABLE_MIRI - if ( dict.count("miri") ) { - miri_source_c_sptr src = make_miri_source_c( arg ); - block = src; iface = src.get(); - } -#endif - #ifdef ENABLE_SDRPLAY if ( dict.count("sdrplay") ) { sdrplay_source_c_sptr src = make_sdrplay_source_c( arg ); -- 2.25.1 From josepharmbruster at gmail.com Fri Oct 30 14:35:20 2020 From: josepharmbruster at gmail.com (Joseph Armbruster) Date: Fri, 30 Oct 2020 10:35:20 -0400 Subject: Windows build failure Message-ID: There's a current build failure on windows with: master @ 710d578901a08b091748d4fd4471e3327a4d099e The issue is in: src/convenience/wavewrite.c, there's an unresolved external for the gettimeofday function. If you #ifdef the function in (like done elsewhere), it builds successfully. Reason i'm building this out right now is that I discovered a weird issue yesterday, while using rtl_fm + multimon-ng to demod/decode APRS... Specifically, I noticed that when I did not use the -M fm option, it works, however when I attempted to explicitly specify -M fm, it did not work. I was going to debug-in to determine why this would be and found the above build issue along the way. If there is a better list to post development issues to, please advise and i'll join that one instead. 73's Joseph Armbruster KJ4JIO -------------- next part -------------- An HTML attachment was scrubbed... URL: From ewild at sysmocom.de Fri Oct 30 16:12:22 2020 From: ewild at sysmocom.de (Eric Wild) Date: Fri, 30 Oct 2020 17:12:22 +0100 Subject: Windows build failure In-Reply-To: References: Message-ID: <1bd16f61-4e2b-16ce-2e9f-0f1362500645@sysmocom.de> Hi Joseph, this is the right mailing list, but the wrong project - you're apparently using one of the many library forks, so there is nothing we can do about that, that file is not part of our librtlsdr (https://cgit.osmocom.org/rtl-sdr/). -Eric Am 30.10.2020 um 15:35 schrieb Joseph Armbruster: > > There's a current build failure on windows with: > > master @ 710d578901a08b091748d4fd4471e3327a4d099e > > The issue is in: src/convenience/wavewrite.c, there's an unresolved > external for the gettimeofday function. If you #ifdef the function in > (like done elsewhere), it builds successfully. > > Reason i'm building this out right now is that I discovered a weird > issue yesterday, while using rtl_fm?+ multimon-ng to demod/decode > APRS... Specifically, I noticed that when I did not use the -M fm > option, it works, however?when I attempted to explicitly specify -M > fm, it did not work.? I was going to debug-in to determine?why this > would be and found the above build issue along the way. > > If there is a better list to post development issues to, please advise > and i'll join that one instead. > > > 73's > > Joseph Armbruster > > KJ4JIO > -------------- next part -------------- An HTML attachment was scrubbed... URL: