introduce osmosdr namespace, remove _c suffix

- the namespace conversion adopts the common gnuradio coding guidelines
- suffix removal is a preparation to support 8/16 bit complex data types
standalone
Dimitri Stolnikov 9 years ago
parent 3e6a24e5d9
commit 7e55cb9224
  1. 2
      docs/doxygen/Doxyfile.in
  2. 6
      grc/CMakeLists.txt
  3. 18
      grc/gen_osmosdr_blocks.py
  4. 12
      include/osmosdr/CMakeLists.txt
  5. 0
      include/osmosdr/api.h
  6. 4
      include/osmosdr/device.h
  7. 2
      include/osmosdr/pimpl.h
  8. 4
      include/osmosdr/ranges.h
  9. 52
      include/osmosdr/sink.h
  10. 52
      include/osmosdr/source.h
  11. 8
      lib/CMakeLists.txt
  12. 0
      lib/arg_helpers.h
  13. 8
      lib/device.cc
  14. 2
      lib/fcd/CMakeLists.txt
  15. 56
      lib/fcd/fcd_source_c.cc
  16. 24
      lib/fcd/fcd_source_c.h
  17. 2
      lib/file/file_source_c.cc
  18. 4
      lib/file/file_source_c.h
  19. 2
      lib/hackrf/hackrf_sink_c.cc
  20. 4
      lib/hackrf/hackrf_sink_c.h
  21. 2
      lib/hackrf/hackrf_source_c.cc
  22. 4
      lib/hackrf/hackrf_source_c.h
  23. 2
      lib/miri/miri_source_c.cc
  24. 4
      lib/miri/miri_source_c.h
  25. 2
      lib/osmosdr/osmosdr_src_c.cc
  26. 6
      lib/osmosdr/osmosdr_src_c.h
  27. 2
      lib/ranges.cc
  28. 2
      lib/rtl/rtl_source_c.cc
  29. 4
      lib/rtl/rtl_source_c.h
  30. 2
      lib/rtl_tcp/rtl_tcp_source_c.cc
  31. 4
      lib/rtl_tcp/rtl_tcp_source_c.h
  32. 14
      lib/sink_iface.h
  33. 123
      lib/sink_impl.cc
  34. 22
      lib/sink_impl.h
  35. 14
      lib/source_iface.h
  36. 134
      lib/source_impl.cc
  37. 22
      lib/source_impl.h
  38. 2
      lib/uhd/uhd_sink_c.cc
  39. 4
      lib/uhd/uhd_sink_c.h
  40. 2
      lib/uhd/uhd_source_c.cc
  41. 4
      lib/uhd/uhd_source_c.h
  42. 27
      swig/osmosdr_swig.i

@ -679,7 +679,7 @@ INPUT_FILTER =
# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
# is applied to all files.
FILTER_PATTERNS = *.py=@top_srcdir@/gnuradio-core/doc/other/doxypy.py
FILTER_PATTERNS = *.py=@top_srcdir@/gnuradio-runtime/doc/other/doxypy.py
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source

@ -32,9 +32,9 @@ macro(GEN_BLOCK_XML _generator _xml_block)
)
endmacro(GEN_BLOCK_XML)
GEN_BLOCK_XML(gen_osmosdr_blocks.py rtlsdr_source_c.xml)
GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_source_c.xml)
GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_sink_c.xml)
GEN_BLOCK_XML(gen_osmosdr_blocks.py rtlsdr_source.xml)
GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_source.xml)
GEN_BLOCK_XML(gen_osmosdr_blocks.py osmosdr_sink.xml)
add_custom_target(osmosdr_grc_xml_blocks ALL DEPENDS ${xml_blocks})

@ -22,11 +22,11 @@ MAIN_TMPL = """\
<?xml version="1.0"?>
<block>
<name>$(title) $sourk.title()</name>
<key>$(prefix)_$(sourk)_c</key>
<key>$(prefix)_$(sourk)</key>
<category>$($sourk.title())s</category>
<throttle>1</throttle>
<import>import osmosdr</import>
<make>osmosdr.$(sourk)_c( args="nchan=" + str(\$nchan) + " " + \$args )
<make>osmosdr.$(sourk)( args="nchan=" + str(\$nchan) + " " + \$args )
self.\$(id).set_sample_rate(\$sample_rate)
#for $n in range($max_nchan)
\#if \$nchan() > $n
@ -104,12 +104,12 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
<nports>\$nchan</nports>
</$sourk>
<doc>
The OSMOCOM block:
The osmocom block:
While primarily being developed for the OsmoSDR hardware, this block as well supports:
* FunCube Dongle through libgnuradio-fcd
* OSMOCOM OsmoSDR Devices through libosmosdr
* sysmocom OsmoSDR Devices through libosmosdr
* Great Scott Gadgets HackRF through libhackrf
* Ettus USRP Devices through Ettus UHD library
* RTL2832U based DVB-T dongles through librtlsdr
@ -192,9 +192,9 @@ Bandwidth:
Set the bandpass filter on the radio frontend. To use the default (automatic) bandwidth filter setting, this should be zero.
See the OsmoSDR project page for more detailed documentation:
http://sdr.osmocom.org/trac/
http://sdr.osmocom.org/trac/wiki/rtl-sdr
http://sdr.osmocom.org/trac/wiki/GrOsmoSDR
http://sdr.osmocom.org/trac/wiki/rtl-sdr
http://sdr.osmocom.org/trac/
</doc>
</block>
"""
@ -318,14 +318,14 @@ if __name__ == '__main__':
title = 'RTL-SDR'
prefix = 'rtlsdr'
elif tail.startswith('osmosdr'):
title = 'OSMOCOM'
title = 'osmocom'
prefix = 'osmosdr'
else: raise Exception, 'file %s has wrong syntax!'%tail
if tail.endswith ('source_c.xml'):
if tail.endswith ('source.xml'):
sourk = 'source'
dir = 'out'
elif tail.endswith ('sink_c.xml'):
elif tail.endswith ('sink.xml'):
sourk = 'sink'
dir = 'in'
else: raise Exception, 'is %s a source or sink?'%file

@ -21,11 +21,11 @@
# Install public header files
########################################################################
install(FILES
osmosdr_api.h
osmosdr_pimpl.h
osmosdr_ranges.h
osmosdr_device.h
osmosdr_source_c.h
osmosdr_sink_c.h
api.h
pimpl.h
ranges.h
device.h
source.h
sink.h
DESTINATION include/osmosdr
)

@ -21,8 +21,8 @@
#ifndef INCLUDED_OSMOSDR_DEVICE_H
#define INCLUDED_OSMOSDR_DEVICE_H
#include <osmosdr/osmosdr_api.h>
#include <osmosdr/osmosdr_pimpl.h>
#include <osmosdr/api.h>
#include <osmosdr/pimpl.h>
#include <boost/noncopyable.hpp>
#include <boost/lexical_cast.hpp>
#include <stdexcept>

@ -20,7 +20,7 @@
#include <boost/shared_ptr.hpp>
/*! \file osmosdr_pimpl.h
/*! \file pimpl.h
* "Pimpl idiom" (pointer to implementation idiom).
* The OSMOSDR_PIMPL_* macros simplify code overhead for declaring and making pimpls.
*

@ -18,8 +18,8 @@
#ifndef INCLUDED_OSMOSDR_RANGES_H
#define INCLUDED_OSMOSDR_RANGES_H
#include <osmosdr/osmosdr_api.h>
#include <osmosdr/osmosdr_pimpl.h>
#include <osmosdr/api.h>
#include <osmosdr/pimpl.h>
#include <string>
#include <vector>

@ -17,36 +17,16 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_OSMOSDR_SINK_C_H
#define INCLUDED_OSMOSDR_SINK_C_H
#ifndef INCLUDED_OSMOSDR_SINK_H
#define INCLUDED_OSMOSDR_SINK_H
#include <osmosdr/osmosdr_api.h>
#include <osmosdr/osmosdr_ranges.h>
#include <osmosdr/api.h>
#include <osmosdr/ranges.h>
#include <gnuradio/hier_block2.h>
class osmosdr_sink_c;
namespace osmosdr {
/*
* 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_sink_c> osmosdr_sink_c_sptr;
/*!
* \brief Return a shared_ptr to a new instance of osmosdr_sink_c.
*
* To avoid accidental use of raw pointers, osmosdr_sink_c's
* constructor is private. osmosdr_make_sink_c is the public
* interface for creating new instances.
*/
OSMOSDR_API osmosdr_sink_c_sptr osmosdr_make_sink_c ( const std::string & args = "" );
class sink;
/*!
* \brief Takes a stream of complex samples.
@ -54,9 +34,23 @@ OSMOSDR_API osmosdr_sink_c_sptr osmosdr_make_sink_c ( const std::string & args =
*
* This uses the preferred technique: subclassing gr::hier_block2.
*/
class OSMOSDR_API osmosdr_sink_c : virtual public gr::hier_block2
class OSMOSDR_API sink : virtual public gr::hier_block2
{
public:
typedef boost::shared_ptr< sink > sptr;
/*!
* \brief Return a shared_ptr to a new instance of sink.
*
* To avoid accidental use of raw pointers, sink's
* constructor is private. osmosdr::sink::make is the public
* interface for creating new instances.
*
* \param args the address to identify the hardware
* \return a new osmosdr sink block object
*/
static sptr make( const std::string & args = "" );
/*!
* Get the number of channels the underlying radio hardware offers.
* \return the number of available channels
@ -287,4 +281,6 @@ public:
virtual osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ) = 0;
};
#endif /* INCLUDED_OSMOSDR_SINK_C_H */
} /* namespace osmosdr */
#endif /* INCLUDED_OSMOSDR_SINK_H */

@ -17,36 +17,16 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_OSMOSDR_SOURCE_C_H
#define INCLUDED_OSMOSDR_SOURCE_C_H
#ifndef INCLUDED_OSMOSDR_SOURCE_H
#define INCLUDED_OSMOSDR_SOURCE_H
#include <osmosdr/osmosdr_api.h>
#include <osmosdr/osmosdr_ranges.h>
#include <osmosdr/api.h>
#include <osmosdr/ranges.h>
#include <gnuradio/hier_block2.h>
class osmosdr_source_c;
namespace osmosdr {
/*
* 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_source_c> osmosdr_source_c_sptr;
/*!
* \brief Return a shared_ptr to a new instance of osmosdr_source_c.
*
* To avoid accidental use of raw pointers, osmosdr_source_c's
* constructor is private. osmosdr_make_source_c is the public
* interface for creating new instances.
*/
OSMOSDR_API osmosdr_source_c_sptr osmosdr_make_source_c ( const std::string & args = "" );
class source;
/*!
* \brief Provides a stream of complex samples.
@ -54,9 +34,23 @@ OSMOSDR_API osmosdr_source_c_sptr osmosdr_make_source_c ( const std::string & ar
*
* This uses the preferred technique: subclassing gr::hier_block2.
*/
class OSMOSDR_API osmosdr_source_c : virtual public gr::hier_block2
class OSMOSDR_API source : virtual public gr::hier_block2
{
public:
typedef boost::shared_ptr< source > sptr;
/*!
* \brief Return a shared_ptr to a new instance of source.
*
* To avoid accidental use of raw pointers, source's
* constructor is private. osmosdr::source::make is the public
* interface for creating new instances.
*
* \param args the address to identify the hardware
* \return a new osmosdr source block object
*/
static sptr make( const std::string & args = "" );
/*!
* Get the number of channels the underlying radio hardware offers.
* \return the number of available channels
@ -287,4 +281,6 @@ public:
virtual osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ) = 0;
};
#endif /* INCLUDED_OSMOSDR_SOURCE_C_H */
} /* namespace osmosdr */
#endif /* INCLUDED_OSMOSDR_SOURCE_H */

@ -36,10 +36,10 @@ MACRO(GR_OSMOSDR_APPEND_LIBS)
ENDMACRO(GR_OSMOSDR_APPEND_LIBS)
GR_OSMOSDR_APPEND_SRCS(
osmosdr_source_c_impl.cc
osmosdr_sink_c_impl.cc
osmosdr_ranges.cc
osmosdr_device.cc
source_impl.cc
sink_impl.cc
ranges.cc
device.cc
)
GR_OSMOSDR_APPEND_LIBS(

@ -18,7 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
#include <osmosdr/osmosdr_device.h>
#include <osmosdr/device.h>
#include <stdexcept>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
@ -35,7 +35,7 @@
#endif
#ifdef ENABLE_FCD
#include <fcd_source.h>
#include <fcd_source_c.h>
#endif
#ifdef ENABLE_FILE
@ -62,7 +62,7 @@
#include <hackrf_source_c.h>
#endif
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace osmosdr;
@ -118,7 +118,7 @@ devices_t device::find(const device_t &hint)
devices.push_back( device_t(dev) );
#endif
#ifdef ENABLE_FCD
BOOST_FOREACH( std::string dev, fcd_source::get_devices() )
BOOST_FOREACH( std::string dev, fcd_source_c::get_devices() )
devices.push_back( device_t(dev) );
#endif
#ifdef ENABLE_RTL

@ -27,7 +27,7 @@ include_directories(
)
set(fcd_srcs
${CMAKE_CURRENT_SOURCE_DIR}/fcd_source.cc
${CMAKE_CURRENT_SOURCE_DIR}/fcd_source_c.cc
)
########################################################################

@ -27,15 +27,15 @@
#include <gnuradio/io_signature.h>
#include "fcd_source.h"
#include "fcd_source_c.h"
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;
fcd_source_sptr make_fcd_source(const std::string &args)
fcd_source_c_sptr make_fcd_source_c(const std::string &args)
{
return gnuradio::get_initial_sptr(new fcd_source(args));
return gnuradio::get_initial_sptr(new fcd_source_c(args));
}
/*
@ -73,8 +73,8 @@ static std::vector< std::string > _get_devices()
return devices;
}
fcd_source::fcd_source(const std::string &args) :
gr::hier_block2("fcd_source",
fcd_source_c::fcd_source_c(const std::string &args) :
gr::hier_block2("fcd_source_c",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 1, sizeof (gr_complex)))
{
@ -98,11 +98,11 @@ fcd_source::fcd_source(const std::string &args) :
connect( _src, 0, self(), 0 );
}
fcd_source::~fcd_source()
fcd_source_c::~fcd_source_c()
{
}
std::vector< std::string > fcd_source::get_devices()
std::vector< std::string > fcd_source_c::get_devices()
{
int id = 0;
std::vector< std::string > devices;
@ -116,17 +116,17 @@ std::vector< std::string > fcd_source::get_devices()
return devices;
}
std::string fcd_source::name()
std::string fcd_source_c::name()
{
return "FUNcube Dongle";
}
size_t fcd_source::get_num_channels( void )
size_t fcd_source_c::get_num_channels( void )
{
return 1;
}
osmosdr::meta_range_t fcd_source::get_sample_rates( void )
osmosdr::meta_range_t fcd_source_c::get_sample_rates( void )
{
osmosdr::meta_range_t range;
@ -135,24 +135,24 @@ osmosdr::meta_range_t fcd_source::get_sample_rates( void )
return range;
}
double fcd_source::set_sample_rate( double rate )
double fcd_source_c::set_sample_rate( double rate )
{
return get_sample_rate();
}
double fcd_source::get_sample_rate( void )
double fcd_source_c::get_sample_rate( void )
{
return 96e3;
}
osmosdr::freq_range_t fcd_source::get_freq_range( size_t chan )
osmosdr::freq_range_t fcd_source_c::get_freq_range( size_t chan )
{
osmosdr::freq_range_t range( 52e6, 2.2e9 );
return range;
}
double fcd_source::set_center_freq( double freq, size_t chan )
double fcd_source_c::set_center_freq( double freq, size_t chan )
{
_src->set_freq(float(freq));
@ -161,12 +161,12 @@ double fcd_source::set_center_freq( double freq, size_t chan )
return get_center_freq(chan);
}
double fcd_source::get_center_freq( size_t chan )
double fcd_source_c::get_center_freq( size_t chan )
{
return _freq;
}
double fcd_source::set_freq_corr( double ppm, size_t chan )
double fcd_source_c::set_freq_corr( double ppm, size_t chan )
{
_src->set_freq_corr( ppm );
@ -175,12 +175,12 @@ double fcd_source::set_freq_corr( double ppm, size_t chan )
return get_freq_corr( chan );
}
double fcd_source::get_freq_corr( size_t chan )
double fcd_source_c::get_freq_corr( size_t chan )
{
return _correct;
}
std::vector<std::string> fcd_source::get_gain_names( size_t chan )
std::vector<std::string> fcd_source_c::get_gain_names( size_t chan )
{
std::vector< std::string > names;
@ -189,19 +189,19 @@ std::vector<std::string> fcd_source::get_gain_names( size_t chan )
return names;
}
osmosdr::gain_range_t fcd_source::get_gain_range( size_t chan )
osmosdr::gain_range_t fcd_source_c::get_gain_range( size_t chan )
{
osmosdr::gain_range_t range(-5, 30, 2.5);
return range;
}
osmosdr::gain_range_t fcd_source::get_gain_range( const std::string & name, size_t chan )
osmosdr::gain_range_t fcd_source_c::get_gain_range( const std::string & name, size_t chan )
{
return get_gain_range( chan );
}
double fcd_source::set_gain( double gain, size_t chan )
double fcd_source_c::set_gain( double gain, size_t chan )
{
_src->set_lna_gain(gain);
@ -210,22 +210,22 @@ double fcd_source::set_gain( double gain, size_t chan )
return get_gain(chan);
}
double fcd_source::set_gain( double gain, const std::string & name, size_t chan )
double fcd_source_c::set_gain( double gain, const std::string & name, size_t chan )
{
return set_gain(chan);
}
double fcd_source::get_gain( size_t chan )
double fcd_source_c::get_gain( size_t chan )
{
return _gain;
}
double fcd_source::get_gain( const std::string & name, size_t chan )
double fcd_source_c::get_gain( const std::string & name, size_t chan )
{
return get_gain(chan);
}
std::vector< std::string > fcd_source::get_antennas( size_t chan )
std::vector< std::string > fcd_source_c::get_antennas( size_t chan )
{
std::vector< std::string > antennas;
@ -234,12 +234,12 @@ std::vector< std::string > fcd_source::get_antennas( size_t chan )
return antennas;
}
std::string fcd_source::set_antenna( const std::string & antenna, size_t chan )
std::string fcd_source_c::set_antenna( const std::string & antenna, size_t chan )
{
return get_antenna(chan);
}
std::string fcd_source::get_antenna( size_t chan )
std::string fcd_source_c::get_antenna( size_t chan )
{
return "RX";
}

@ -17,32 +17,32 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef FCD_SOURCE_H
#define FCD_SOURCE_H
#ifndef FCD_SOURCE_C_H
#define FCD_SOURCE_C_H
#include <gnuradio/hier_block2.h>
#include <gnuradio/fcd/source_c.h>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
class fcd_source;
class fcd_source_c;
typedef boost::shared_ptr< fcd_source > fcd_source_sptr;
typedef boost::shared_ptr< fcd_source_c > fcd_source_c_sptr;
fcd_source_sptr make_fcd_source( const std::string & args = "" );
fcd_source_c_sptr make_fcd_source_c( const std::string & args = "" );
class fcd_source :
class fcd_source_c :
public gr::hier_block2,
public osmosdr_src_iface
public source_iface
{
private:
friend fcd_source_sptr make_fcd_source(const std::string &args);
friend fcd_source_c_sptr make_fcd_source_c(const std::string &args);
fcd_source(const std::string &args);
fcd_source_c(const std::string &args);
public:
~fcd_source();
~fcd_source_c();
static std::vector< std::string > get_devices();
@ -78,4 +78,4 @@ private:
int32_t _correct;
};
#endif // FCD_SOURCE_H
#endif // FCD_SOURCE_C_H

@ -30,7 +30,7 @@
#include "file_source_c.h"
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;

@ -22,7 +22,7 @@
#include <gnuradio/hier_block2.h>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
class file_source_c;
@ -32,7 +32,7 @@ file_source_c_sptr make_file_source_c( const std::string & args = "" );
class file_source_c :
public gr::hier_block2,
public osmosdr_src_iface
public source_iface
{
private:
friend file_source_c_sptr make_file_source_c(const std::string &args);

@ -46,7 +46,7 @@
#include "hackrf_sink_c.h"
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;

@ -28,7 +28,7 @@
#include <libhackrf/hackrf.h>
#include "osmosdr_snk_iface.h"
#include "sink_iface.h"
class hackrf_sink_c;
@ -67,7 +67,7 @@ hackrf_sink_c_sptr make_hackrf_sink_c (const std::string & args = "");
class hackrf_sink_c :
public gr::sync_block,
public osmosdr_snk_iface
public sink_iface
{
private:
// The friend declaration allows hackrf_make_sink_c to

@ -39,7 +39,7 @@
#include <stdexcept>
#include <iostream>
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;

@ -30,7 +30,7 @@
#include <libhackrf/hackrf.h>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
class hackrf_source_c;
@ -62,7 +62,7 @@ hackrf_source_c_sptr make_hackrf_source_c (const std::string & args = "");
*/
class hackrf_source_c :
public gr::sync_block,
public osmosdr_src_iface
public source_iface
{
private:
// The friend declaration allows make_hackrf_source_c to

@ -40,7 +40,7 @@
#include <mirisdr.h>
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;

@ -26,7 +26,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
class miri_source_c;
typedef struct mirisdr_dev mirisdr_dev_t;
@ -59,7 +59,7 @@ miri_source_c_sptr make_miri_source_c (const std::string & args = "");
*/
class miri_source_c :
public gr::sync_block,
public osmosdr_src_iface
public source_iface
{
private:
// The friend declaration allows make_miri_source_c to

@ -39,7 +39,7 @@
#include <osmosdr.h>
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;

@ -26,7 +26,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
class osmosdr_src_c;
typedef struct osmosdr_dev osmosdr_dev_t;
@ -57,11 +57,11 @@ osmosdr_src_c_sptr osmosdr_make_src_c (const std::string & args = "");
* \brief Provides a stream of complex samples.
* \ingroup block
*
* \sa osmosdr_sink_c for a version that subclasses gr::hier_block2.
* \sa sink for a version that subclasses gr::hier_block2.
*/
class osmosdr_src_c :
public gr::sync_block,
public osmosdr_src_iface
public source_iface
{
private:
// The friend declaration allows osmosdr_make_src_c to

@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <osmosdr/osmosdr_ranges.h>
#include <osmosdr/ranges.h>
#include <stdexcept>
#include <boost/math/special_functions/round.hpp>
#include <boost/foreach.hpp>

@ -41,7 +41,7 @@
#include <rtl-sdr.h>
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;

@ -28,7 +28,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
class rtl_source_c;
typedef struct rtlsdr_dev rtlsdr_dev_t;
@ -62,7 +62,7 @@ rtl_source_c_sptr make_rtl_source_c (const std::string & args = "");
*/
class rtl_source_c :
public gr::sync_block,
public osmosdr_src_iface
public source_iface
{
private:
// The friend declaration allows make_rtl_source_c to

@ -31,7 +31,7 @@
#include "rtl_tcp_source_c.h"
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
using namespace boost::assign;

@ -22,7 +22,7 @@
#include <gnuradio/hier_block2.h>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
#include "rtl_tcp_source_f.h"
@ -34,7 +34,7 @@ rtl_tcp_source_c_sptr make_rtl_tcp_source_c( const std::string & args = "" );
class rtl_tcp_source_c :
public gr::hier_block2,
public osmosdr_src_iface
public source_iface
{
private:
friend rtl_tcp_source_c_sptr make_rtl_tcp_source_c(const std::string &args);

@ -18,21 +18,17 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef OSMOSDR_SNK_IFACE_H
#define OSMOSDR_SNK_IFACE_H
#ifndef OSMOSDR_SINK_IFACE_H
#define OSMOSDR_SINK_IFACE_H
#include <osmosdr/osmosdr_ranges.h>
#include <osmosdr/ranges.h>
#include <gnuradio/basic_block.h>
class osmosdr_snk_iface;
typedef boost::shared_ptr<osmosdr_snk_iface> osmosdr_snk_iface_sptr;
/*!
* TODO: document
*
*/
class osmosdr_snk_iface
class sink_iface
{
public:
/*!
@ -258,4 +254,4 @@ public:
{ return osmosdr::freq_range_t(); }
};
#endif // OSMOSDR_SNK_IFACE_H
#endif // OSMOSDR_SINK_IFACE_H

@ -32,8 +32,6 @@
#include <gnuradio/blocks/throttle.h>
#include <gnuradio/blocks/null_sink.h>
#include "osmosdr_sink_c_impl.h"
#ifdef ENABLE_UHD
#include "uhd_sink_c.h"
#endif
@ -41,27 +39,28 @@
#include "hackrf_sink_c.h"
#endif
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
#include "sink_impl.h"
/* This avoids throws in ctor of gr::hier_block2, as gnuradio is unable to deal
with this behavior in a clean way. The GR maintainer Rondeau has been informed. */
#define WORKAROUND_GR_HIER_BLOCK2_BUG
/*
* Create a new instance of osmosdr_sink_c_impl and return
* Create a new instance of sink_impl and return
* a boost shared_ptr. This is effectively the public constructor.
*/
osmosdr_sink_c_sptr
osmosdr_make_sink_c (const std::string &args)
osmosdr::sink::sptr
osmosdr::sink::make( const std::string &args )
{
return gnuradio::get_initial_sptr(new osmosdr_sink_c_impl (args));
return gnuradio::get_initial_sptr( new sink_impl(args) );
}
/*
* The private constructor
*/
osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args)
: gr::hier_block2 ("osmosdr_sink_c_impl",
sink_impl::sink_impl( const std::string &args )
: gr::hier_block2 ("sink_impl",
args_to_io_signature(args),
gr::io_signature::make(0, 0, 0))
{
@ -127,7 +126,7 @@ osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args)
// BOOST_FOREACH( dict_t::value_type &entry, dict )
// std::cerr << "'" << entry.first << "' = '" << entry.second << "'" << std::endl;
osmosdr_snk_iface *iface = NULL;
sink_iface *iface = NULL;
gr::basic_block_sptr block;
#ifdef ENABLE_UHD
@ -185,11 +184,11 @@ osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args)
#endif
}
size_t osmosdr_sink_c_impl::get_num_channels()
size_t sink_impl::get_num_channels()
{
size_t channels = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( sink_iface *dev, _devs )
channels += dev->get_num_channels();
return channels;
@ -197,7 +196,7 @@ size_t osmosdr_sink_c_impl::get_num_channels()
#define NO_DEVICES_MSG "FATAL: No device(s) available to work with."
osmosdr::meta_range_t osmosdr_sink_c_impl::get_sample_rates()
osmosdr::meta_range_t sink_impl::get_sample_rates()
{
if ( ! _devs.empty() )
return _devs[0]->get_sample_rates(); // assume same devices used in the group
@ -208,7 +207,7 @@ osmosdr::meta_range_t osmosdr_sink_c_impl::get_sample_rates()
return osmosdr::meta_range_t();
}
double osmosdr_sink_c_impl::set_sample_rate(double rate)
double sink_impl::set_sample_rate(double rate)
{
double sample_rate = 0;
@ -217,7 +216,7 @@ double osmosdr_sink_c_impl::set_sample_rate(double rate)
if (_devs.empty())
throw std::runtime_error(NO_DEVICES_MSG);
#endif
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( sink_iface *dev, _devs )
sample_rate = dev->set_sample_rate(rate);
_sample_rate = sample_rate;
@ -226,7 +225,7 @@ double osmosdr_sink_c_impl::set_sample_rate(double rate)
return sample_rate;
}
double osmosdr_sink_c_impl::get_sample_rate()
double sink_impl::get_sample_rate()
{
double sample_rate = 0;
@ -239,10 +238,10 @@ double osmosdr_sink_c_impl::get_sample_rate()
return sample_rate;
}
osmosdr::freq_range_t osmosdr_sink_c_impl::get_freq_range( size_t chan )
osmosdr::freq_range_t sink_impl::get_freq_range( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -250,10 +249,10 @@ osmosdr::freq_range_t osmosdr_sink_c_impl::get_freq_range( size_t chan )
return osmosdr::freq_range_t();
}
double osmosdr_sink_c_impl::set_center_freq( double freq, size_t chan )
double sink_impl::set_center_freq( double freq, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -264,10 +263,10 @@ double osmosdr_sink_c_impl::set_center_freq( double freq, size_t chan )
return 0;
}
double osmosdr_sink_c_impl::get_center_freq( size_t chan )
double sink_impl::get_center_freq( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -275,10 +274,10 @@ double osmosdr_sink_c_impl::get_center_freq( size_t chan )
return 0;
}
double osmosdr_sink_c_impl::set_freq_corr( double ppm, size_t chan )
double sink_impl::set_freq_corr( double ppm, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -289,10 +288,10 @@ double osmosdr_sink_c_impl::set_freq_corr( double ppm, size_t chan )
return 0;
}
double osmosdr_sink_c_impl::get_freq_corr( size_t chan )
double sink_impl::get_freq_corr( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -300,10 +299,10 @@ double osmosdr_sink_c_impl::get_freq_corr( size_t chan )
return 0;
}
std::vector<std::string> osmosdr_sink_c_impl::get_gain_names( size_t chan )
std::vector<std::string> sink_impl::get_gain_names( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -311,10 +310,10 @@ std::vector<std::string> osmosdr_sink_c_impl::get_gain_names( size_t chan )
return std::vector< std::string >();
}
osmosdr::gain_range_t osmosdr_sink_c_impl::get_gain_range( size_t chan )
osmosdr::gain_range_t sink_impl::get_gain_range( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -322,10 +321,10 @@ osmosdr::gain_range_t osmosdr_sink_c_impl::get_gain_range( size_t chan )
return osmosdr::gain_range_t();
}
osmosdr::gain_range_t osmosdr_sink_c_impl::get_gain_range( const std::string & name, 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( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -333,10 +332,10 @@ osmosdr::gain_range_t osmosdr_sink_c_impl::get_gain_range( const std::string & n
return osmosdr::gain_range_t();
}
bool osmosdr_sink_c_impl::set_gain_mode( bool automatic, size_t chan )
bool sink_impl::set_gain_mode( bool automatic, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -350,10 +349,10 @@ bool osmosdr_sink_c_impl::set_gain_mode( bool automatic, size_t chan )
return false;
}
bool osmosdr_sink_c_impl::get_gain_mode( size_t chan )
bool sink_impl::get_gain_mode( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -361,10 +360,10 @@ bool osmosdr_sink_c_impl::get_gain_mode( size_t chan )
return false;
}
double osmosdr_sink_c_impl::set_gain( double gain, size_t chan )
double sink_impl::set_gain( double gain, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -375,10 +374,10 @@ double osmosdr_sink_c_impl::set_gain( double gain, size_t chan )
return 0;
}
double osmosdr_sink_c_impl::set_gain( double gain, const std::string & name, size_t chan)
double sink_impl::set_gain( double gain, const std::string & name, size_t chan)
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -386,10 +385,10 @@ double osmosdr_sink_c_impl::set_gain( double gain, const std::string & name, siz
return 0;
}
double osmosdr_sink_c_impl::get_gain( size_t chan )
double sink_impl::get_gain( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -397,10 +396,10 @@ double osmosdr_sink_c_impl::get_gain( size_t chan )
return 0;
}
double osmosdr_sink_c_impl::get_gain( const std::string & name, size_t chan )
double sink_impl::get_gain( const std::string & name, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -408,10 +407,10 @@ double osmosdr_sink_c_impl::get_gain( const std::string & name, size_t chan )
return 0;
}
double osmosdr_sink_c_impl::set_if_gain( double gain, size_t chan )
double sink_impl::set_if_gain( double gain, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_snk_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -422,10 +421,10 @@ double osmosdr_sink_c_impl::set_if_gain( double gain, size_t chan )