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
This commit is contained in:
Dimitri Stolnikov 2013-05-30 16:14:22 +02:00
parent 3e6a24e5d9
commit 7e55cb9224
42 changed files with 323 additions and 341 deletions

View File

@ -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

View File

@ -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})

View File

@ -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

View 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
)

View File

@ -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>

View File

@ -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.
*

View File

@ -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>

View File

@ -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 */

View File

@ -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 */

View File

@ -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(

View File

@ -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

View File

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

View File

@ -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";
}

View File

@ -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

View File

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

View File

@ -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);

View File

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

View File

@ -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

View File

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

View File

@ -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

View File

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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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>

View File

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

View File

@ -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

View File

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

View File

@ -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);

View File

@ -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

View File

@ -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 )
return 0;
}
double osmosdr_sink_c_impl::set_bb_gain( double gain, size_t chan )
double sink_impl::set_bb_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 ( _bb_gain[ chan ] != gain ) {
@ -436,10 +435,10 @@ double osmosdr_sink_c_impl::set_bb_gain( double gain, size_t chan )
return 0;
}
std::vector< std::string > osmosdr_sink_c_impl::get_antennas( size_t chan )
std::vector< std::string > sink_impl::get_antennas( 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_antennas( dev_chan );
@ -447,10 +446,10 @@ std::vector< std::string > osmosdr_sink_c_impl::get_antennas( size_t chan )
return std::vector< std::string >();
}
std::string osmosdr_sink_c_impl::set_antenna( const std::string & antenna, size_t chan )
std::string sink_impl::set_antenna( const std::string & antenna, 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 ( _antenna[ chan ] != antenna ) {
@ -461,10 +460,10 @@ std::string osmosdr_sink_c_impl::set_antenna( const std::string & antenna, size_
return "";
}
std::string osmosdr_sink_c_impl::get_antenna( size_t chan )
std::string sink_impl::get_antenna( 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_antenna( dev_chan );
@ -472,20 +471,20 @@ std::string osmosdr_sink_c_impl::get_antenna( size_t chan )
return "";
}
void osmosdr_sink_c_impl::set_iq_balance_mode( int mode, size_t chan )
void sink_impl::set_iq_balance_mode( int mode, size_t chan )
{
}
void osmosdr_sink_c_impl::set_iq_balance( const std::complex<double> &correction, size_t chan )
void sink_impl::set_iq_balance( const std::complex<double> &correction, size_t chan )
{
}
double osmosdr_sink_c_impl::set_bandwidth( double bandwidth, size_t chan )
double sink_impl::set_bandwidth( double bandwidth, 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 ( _bandwidth[ chan ] != bandwidth ) {
@ -496,10 +495,10 @@ double osmosdr_sink_c_impl::set_bandwidth( double bandwidth, size_t chan )
return 0;
}
double osmosdr_sink_c_impl::get_bandwidth( size_t chan )
double sink_impl::get_bandwidth( 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_bandwidth( dev_chan );
@ -507,10 +506,10 @@ double osmosdr_sink_c_impl::get_bandwidth( size_t chan )
return 0;
}
osmosdr::freq_range_t osmosdr_sink_c_impl::get_bandwidth_range( size_t chan )
osmosdr::freq_range_t sink_impl::get_bandwidth_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_bandwidth_range( dev_chan );

View File

@ -17,18 +17,20 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_OSMOSDR_SINK_C_IMPL_H
#define INCLUDED_OSMOSDR_SINK_C_IMPL_H
#ifndef INCLUDED_OSMOSDR_SINK_IMPL_H
#define INCLUDED_OSMOSDR_SINK_IMPL_H
#include "osmosdr/osmosdr_sink_c.h"
#include "osmosdr/sink.h"
#include "osmosdr_snk_iface.h"
#include "sink_iface.h"
#include <map>
class osmosdr_sink_c_impl : public osmosdr_sink_c
class sink_impl : public osmosdr::sink
{
public:
sink_impl(const std::string & args);
size_t get_num_channels( void );
osmosdr::meta_range_t get_sample_rates( void );
@ -66,13 +68,7 @@ public:
osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 );
private:
osmosdr_sink_c_impl (const std::string & args); // private constructor
// The friend declaration allows osmosdr_make_sink_c to
// access the private constructor.
friend osmosdr_sink_c_sptr osmosdr_make_sink_c (const std::string & args);
std::vector< osmosdr_snk_iface * > _devs;
std::vector< sink_iface * > _devs;
double _sample_rate;
std::map< size_t, double > _center_freq;
@ -85,4 +81,4 @@ private:
std::map< size_t, double > _bandwidth;
};
#endif /* INCLUDED_OSMOSDR_SINK_C_IMPL_H */
#endif /* INCLUDED_OSMOSDR_SINK_IMPL_H */

View File

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

View File

@ -27,7 +27,6 @@
#include "config.h"
#endif
#include <osmosdr_source_c_impl.h>
#include <gnuradio/io_signature.h>
#include <gnuradio/blocks/null_source.h>
#include <gnuradio/blocks/throttle.h>
@ -38,7 +37,7 @@
#endif
#ifdef ENABLE_FCD
#include <fcd_source.h>
#include <fcd_source_c.h>
#endif
#ifdef ENABLE_FILE
@ -65,27 +64,28 @@
#include <hackrf_source_c.h>
#endif
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
#include "source_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_source_c_impl and return
* Create a new instance of source_impl and return
* a boost shared_ptr. This is effectively the public constructor.
*/
osmosdr_source_c_sptr
osmosdr_make_source_c (const std::string &args)
osmosdr::source::sptr
osmosdr::source::make( const std::string &args )
{
return gnuradio::get_initial_sptr(new osmosdr_source_c_impl (args));
return gnuradio::get_initial_sptr( new source_impl(args) );
}
/*
* The private constructor
*/
osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args)
: gr::hier_block2 ("osmosdr_source_c_impl",
source_impl::source_impl( const std::string &args )
: gr::hier_block2 ("source_impl",
gr::io_signature::make(0, 0, 0),
args_to_io_signature(args))
{
@ -147,7 +147,7 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args)
dev_list.push_back( dev );
#endif
#ifdef ENABLE_FCD
BOOST_FOREACH( std::string dev, fcd_source::get_devices() )
BOOST_FOREACH( std::string dev, fcd_source_c::get_devices() )
dev_list.push_back( dev );
#endif
#ifdef ENABLE_RTL
@ -185,7 +185,7 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args)
// BOOST_FOREACH( dict_t::value_type &entry, dict )
// std::cerr << "'" << entry.first << "' = '" << entry.second << "'" << std::endl;
osmosdr_src_iface *iface = NULL;
source_iface *iface = NULL;
gr::basic_block_sptr block;
#ifdef ENABLE_OSMOSDR
@ -197,7 +197,7 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args)
#ifdef ENABLE_FCD
if ( dict.count("fcd") ) {
fcd_source_sptr src = make_fcd_source( arg );
fcd_source_c_sptr src = make_fcd_source_c( arg );
block = src; iface = src.get();
}
#endif
@ -300,11 +300,11 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args)
#endif
}
size_t osmosdr_source_c_impl::get_num_channels()
size_t source_impl::get_num_channels()
{
size_t channels = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( source_iface *dev, _devs )
channels += dev->get_num_channels();
return channels;
@ -312,7 +312,7 @@ size_t osmosdr_source_c_impl::get_num_channels()
#define NO_DEVICES_MSG "FATAL: No device(s) available to work with."
osmosdr::meta_range_t osmosdr_source_c_impl::get_sample_rates()
osmosdr::meta_range_t source_impl::get_sample_rates()
{
if ( ! _devs.empty() )
return _devs[0]->get_sample_rates(); // assume same devices used in the group
@ -323,7 +323,7 @@ osmosdr::meta_range_t osmosdr_source_c_impl::get_sample_rates()
return osmosdr::meta_range_t();;
}
double osmosdr_source_c_impl::set_sample_rate(double rate)
double source_impl::set_sample_rate(double rate)
{
double sample_rate = 0;
@ -332,12 +332,12 @@ double osmosdr_source_c_impl::set_sample_rate(double rate)
if (_devs.empty())
throw std::runtime_error(NO_DEVICES_MSG);
#endif
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( source_iface *dev, _devs )
sample_rate = dev->set_sample_rate(rate);
#ifdef HAVE_IQBALANCE
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs ) {
BOOST_FOREACH( source_iface *dev, _devs ) {
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++) {
if ( channel < _iq_opt.size() ) {
iqbalance_optimize_c *opt = _iq_opt[channel];
@ -359,7 +359,7 @@ double osmosdr_source_c_impl::set_sample_rate(double rate)
return sample_rate;
}
double osmosdr_source_c_impl::get_sample_rate()
double source_impl::get_sample_rate()
{
double sample_rate = 0;
@ -372,10 +372,10 @@ double osmosdr_source_c_impl::get_sample_rate()
return sample_rate;
}
osmosdr::freq_range_t osmosdr_source_c_impl::get_freq_range( size_t chan )
osmosdr::freq_range_t source_impl::get_freq_range( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -383,10 +383,10 @@ osmosdr::freq_range_t osmosdr_source_c_impl::get_freq_range( size_t chan )
return osmosdr::freq_range_t();
}
double osmosdr_source_c_impl::set_center_freq( double freq, size_t chan )
double source_impl::set_center_freq( double freq, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -397,10 +397,10 @@ double osmosdr_source_c_impl::set_center_freq( double freq, size_t chan )
return 0;
}
double osmosdr_source_c_impl::get_center_freq( size_t chan )
double source_impl::get_center_freq( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -408,10 +408,10 @@ double osmosdr_source_c_impl::get_center_freq( size_t chan )
return 0;
}
double osmosdr_source_c_impl::set_freq_corr( double ppm, size_t chan )
double source_impl::set_freq_corr( double ppm, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -422,10 +422,10 @@ double osmosdr_source_c_impl::set_freq_corr( double ppm, size_t chan )
return 0;
}
double osmosdr_source_c_impl::get_freq_corr( size_t chan )
double source_impl::get_freq_corr( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -433,10 +433,10 @@ double osmosdr_source_c_impl::get_freq_corr( size_t chan )
return 0;
}
std::vector<std::string> osmosdr_source_c_impl::get_gain_names( size_t chan )
std::vector<std::string> source_impl::get_gain_names( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -444,10 +444,10 @@ std::vector<std::string> osmosdr_source_c_impl::get_gain_names( size_t chan )
return std::vector< std::string >();
}
osmosdr::gain_range_t osmosdr_source_c_impl::get_gain_range( size_t chan )
osmosdr::gain_range_t source_impl::get_gain_range( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -455,10 +455,10 @@ osmosdr::gain_range_t osmosdr_source_c_impl::get_gain_range( size_t chan )
return osmosdr::gain_range_t();
}
osmosdr::gain_range_t osmosdr_source_c_impl::get_gain_range( const std::string & name, 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( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -466,10 +466,10 @@ osmosdr::gain_range_t osmosdr_source_c_impl::get_gain_range( const std::string &
return osmosdr::gain_range_t();
}
bool osmosdr_source_c_impl::set_gain_mode( bool automatic, size_t chan )
bool source_impl::set_gain_mode( bool automatic, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -483,10 +483,10 @@ bool osmosdr_source_c_impl::set_gain_mode( bool automatic, size_t chan )
return false;
}
bool osmosdr_source_c_impl::get_gain_mode( size_t chan )
bool source_impl::get_gain_mode( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -494,10 +494,10 @@ bool osmosdr_source_c_impl::get_gain_mode( size_t chan )
return false;
}
double osmosdr_source_c_impl::set_gain( double gain, size_t chan )
double source_impl::set_gain( double gain, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -508,10 +508,10 @@ double osmosdr_source_c_impl::set_gain( double gain, size_t chan )
return 0;
}
double osmosdr_source_c_impl::set_gain( double gain, const std::string & name, size_t chan)
double source_impl::set_gain( double gain, const std::string & name, size_t chan)
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -519,10 +519,10 @@ double osmosdr_source_c_impl::set_gain( double gain, const std::string & name, s
return 0;
}
double osmosdr_source_c_impl::get_gain( size_t chan )
double source_impl::get_gain( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -530,10 +530,10 @@ double osmosdr_source_c_impl::get_gain( size_t chan )
return 0;
}
double osmosdr_source_c_impl::get_gain( const std::string & name, size_t chan )
double source_impl::get_gain( const std::string & name, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -541,10 +541,10 @@ double osmosdr_source_c_impl::get_gain( const std::string & name, size_t chan )
return 0;
}
double osmosdr_source_c_impl::set_if_gain( double gain, size_t chan )
double source_impl::set_if_gain( double gain, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -555,10 +555,10 @@ double osmosdr_source_c_impl::set_if_gain( double gain, size_t chan )
return 0;
}
double osmosdr_source_c_impl::set_bb_gain( double gain, size_t chan )
double source_impl::set_bb_gain( double gain, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -569,10 +569,10 @@ double osmosdr_source_c_impl::set_bb_gain( double gain, size_t chan )
return 0;
}
std::vector< std::string > osmosdr_source_c_impl::get_antennas( size_t chan )
std::vector< std::string > source_impl::get_antennas( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -580,10 +580,10 @@ std::vector< std::string > osmosdr_source_c_impl::get_antennas( size_t chan )
return std::vector< std::string >();
}
std::string osmosdr_source_c_impl::set_antenna( const std::string & antenna, size_t chan )
std::string source_impl::set_antenna( const std::string & antenna, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -594,10 +594,10 @@ std::string osmosdr_source_c_impl::set_antenna( const std::string & antenna, siz
return "";
}
std::string osmosdr_source_c_impl::get_antenna( size_t chan )
std::string source_impl::get_antenna( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -605,11 +605,11 @@ std::string osmosdr_source_c_impl::get_antenna( size_t chan )
return "";
}
void osmosdr_source_c_impl::set_iq_balance_mode( int mode, size_t chan )
void source_impl::set_iq_balance_mode( int mode, size_t chan )
{
#ifdef HAVE_IQBALANCE
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs ) {
BOOST_FOREACH( 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() ) {
@ -641,11 +641,11 @@ void osmosdr_source_c_impl::set_iq_balance_mode( int mode, size_t chan )
#endif
}
void osmosdr_source_c_impl::set_iq_balance( const std::complex<double> &correction, size_t chan )
void source_impl::set_iq_balance( const std::complex<double> &correction, size_t chan )
{
#ifdef HAVE_IQBALANCE
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs ) {
BOOST_FOREACH( 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() ) {
@ -663,10 +663,10 @@ void osmosdr_source_c_impl::set_iq_balance( const std::complex<double> &correcti
#endif
}
double osmosdr_source_c_impl::set_bandwidth( double bandwidth, size_t chan )
double source_impl::set_bandwidth( double bandwidth, size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 ) {
@ -677,10 +677,10 @@ double osmosdr_source_c_impl::set_bandwidth( double bandwidth, size_t chan )
return 0;
}
double osmosdr_source_c_impl::get_bandwidth( size_t chan )
double source_impl::get_bandwidth( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );
@ -688,10 +688,10 @@ double osmosdr_source_c_impl::get_bandwidth( size_t chan )
return 0;
}
osmosdr::freq_range_t osmosdr_source_c_impl::get_bandwidth_range( size_t chan )
osmosdr::freq_range_t source_impl::get_bandwidth_range( size_t chan )
{
size_t channel = 0;
BOOST_FOREACH( osmosdr_src_iface *dev, _devs )
BOOST_FOREACH( 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 );

View File

@ -17,23 +17,25 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_OSMOSDR_SOURCE_C_IMPL_H
#define INCLUDED_OSMOSDR_SOURCE_C_IMPL_H
#ifndef INCLUDED_OSMOSDR_SOURCE_IMPL_H
#define INCLUDED_OSMOSDR_SOURCE_IMPL_H
#include <osmosdr/osmosdr_source_c.h>
#include <osmosdr/source.h>
#ifdef HAVE_IQBALANCE
#include <iqbalance_optimize_c.h>
#include <iqbalance_fix_cc.h>
#endif
#include <osmosdr_src_iface.h>
#include <source_iface.h>
#include <map>
class osmosdr_source_c_impl : public osmosdr_source_c
class source_impl : public osmosdr::source
{
public:
source_impl( const std::string & args );
size_t get_num_channels( void );
osmosdr::meta_range_t get_sample_rates( void );
@ -71,13 +73,7 @@ public:
osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 );
private:
osmosdr_source_c_impl (const std::string & args); // private constructor
// The friend declaration allows osmosdr_make_source_c to
// access the private constructor.
friend osmosdr_source_c_sptr osmosdr_make_source_c (const std::string & args);
std::vector< osmosdr_src_iface * > _devs;
std::vector< source_iface * > _devs;
double _sample_rate;
std::map< size_t, double > _center_freq;
@ -95,4 +91,4 @@ private:
std::map< size_t, double > _bandwidth;
};
#endif /* INCLUDED_OSMOSDR_SOURCE_C_IMPL_H */
#endif /* INCLUDED_OSMOSDR_SOURCE_IMPL_H */

View File

@ -24,7 +24,7 @@
//#include <uhd/property_tree.hpp>
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
#include "uhd_sink_c.h"

View File

@ -23,7 +23,7 @@
#include <gnuradio/hier_block2.h>
#include <gnuradio/uhd/usrp_sink.h>
#include "osmosdr_snk_iface.h"
#include "sink_iface.h"
class uhd_sink_c;
@ -33,7 +33,7 @@ uhd_sink_c_sptr make_uhd_sink_c(const std::string &args = "");
class uhd_sink_c :
public gr::hier_block2,
public osmosdr_snk_iface
public sink_iface
{
private:
friend uhd_sink_c_sptr make_uhd_sink_c(const std::string &args);

View File

@ -24,7 +24,7 @@
//#include <uhd/property_tree.hpp>
#include "osmosdr_arg_helpers.h"
#include "arg_helpers.h"
#include "uhd_source_c.h"

View File

@ -23,7 +23,7 @@
#include <gnuradio/hier_block2.h>
#include <gnuradio/uhd/usrp_source.h>
#include "osmosdr_src_iface.h"
#include "source_iface.h"
class uhd_source_c;
@ -33,7 +33,7 @@ uhd_source_c_sptr make_uhd_source_c(const std::string &args = "");
class uhd_source_c :
public gr::hier_block2,
public osmosdr_src_iface
public source_iface
{
private:
friend uhd_source_c_sptr make_uhd_source_c(const std::string &args);

View File

@ -11,9 +11,9 @@
%include "osmosdr_swig_doc.i"
%{
#include "osmosdr/osmosdr_device.h"
#include "osmosdr/osmosdr_source_c.h"
#include "osmosdr/osmosdr_sink_c.h"
#include "osmosdr/device.h"
#include "osmosdr/source.h"
#include "osmosdr/sink.h"
%}
// Workaround for a SWIG 2.0.4 bug with templates. Probably needs to be looked in to.
@ -29,20 +29,27 @@
//%template(size_vector_t) std::vector<size_t>;
%include <osmosdr/osmosdr_pimpl.h>
%include <osmosdr/pimpl.h>
%ignore osmosdr::device_t::operator[]; //ignore warnings about %extend
%template(string_string_dict_t) std::map<std::string, std::string>; //define before device
%template(devices_t) std::vector<osmosdr::device_t>;
%include <osmosdr/osmosdr_device.h>
%include <osmosdr/device.h>
%template(range_vector_t) std::vector<osmosdr::range_t>; //define before range
%include <osmosdr/osmosdr_ranges.h>
%include <osmosdr/ranges.h>
GR_SWIG_BLOCK_MAGIC(osmosdr,source_c);
%include "osmosdr/osmosdr_source_c.h"
%define OSMOSDR_SWIG_BLOCK_MAGIC2(PKG, BASE_NAME)
%template(BASE_NAME ## _sptr) boost::shared_ptr<PKG ## :: ## BASE_NAME>;
%pythoncode %{
BASE_NAME ## _sptr.__repr__ = lambda self: "<gr_block %s (%d)>" % (self.name(), self.unique_id())
BASE_NAME = BASE_NAME.make;
%}
%enddef
GR_SWIG_BLOCK_MAGIC(osmosdr,sink_c);
%include "osmosdr/osmosdr_sink_c.h"
%include "osmosdr/source.h"
%include "osmosdr/sink.h"
OSMOSDR_SWIG_BLOCK_MAGIC2(osmosdr,source);
OSMOSDR_SWIG_BLOCK_MAGIC2(osmosdr,sink);