forked from sdr/gr-osmosdr
176 lines
4.5 KiB
C++
176 lines
4.5 KiB
C++
/* -*- c++ -*- */
|
|
/*
|
|
* Copyright 2012 Dimitri Stolnikov <horiz0n@gmx.net>
|
|
*
|
|
* 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_source_c_impl.h>
|
|
#include <gr_io_signature.h>
|
|
|
|
#include <osmosdr_arg_helpers.h>
|
|
|
|
/*
|
|
* Create a new instance of osmosdr_source_c_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)
|
|
{
|
|
return gnuradio::get_initial_sptr(new osmosdr_source_c_impl (args));
|
|
}
|
|
|
|
/*
|
|
* The private constructor
|
|
*/
|
|
osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args)
|
|
: gr_hier_block2 ("osmosdr_source_c_impl",
|
|
gr_make_io_signature (0, 0, 0),
|
|
args_to_io_signature(args))
|
|
{
|
|
std::vector< std::string > arg_list = args_to_vector(args);
|
|
|
|
std::cout << "arg_list.size: " << arg_list.size() << std::endl;
|
|
|
|
BOOST_FOREACH(std::string arg, arg_list) {
|
|
dict_t dict = params_to_dict(arg);
|
|
|
|
std::cout << "" << std::endl;
|
|
BOOST_FOREACH( dict_t::value_type &entry, dict )
|
|
std::cout << "'" << entry.first << "' '" << entry.second << "'" << std::endl;
|
|
}
|
|
|
|
for ( int i = 0; i < 1; i++ ) {
|
|
std::string arg = boost::lexical_cast<std::string>(i);
|
|
|
|
rtl_source_c_sptr src = make_rtl_source_c( arg );
|
|
|
|
connect(src, 0, self(), i);
|
|
|
|
_srcs.push_back( src );
|
|
}
|
|
}
|
|
|
|
size_t osmosdr_source_c_impl::get_num_channels()
|
|
{
|
|
size_t channels = 0;
|
|
|
|
channels = _srcs[0]->get_num_channels();
|
|
|
|
return channels;
|
|
}
|
|
|
|
osmosdr::meta_range_t osmosdr_source_c_impl::get_sample_rates()
|
|
{
|
|
return _srcs[0]->get_sample_rates();
|
|
}
|
|
|
|
double osmosdr_source_c_impl::set_sample_rate(double rate)
|
|
{
|
|
return _srcs[0]->set_sample_rate(rate);
|
|
// return rate;
|
|
}
|
|
|
|
double osmosdr_source_c_impl::get_sample_rate()
|
|
{
|
|
return _srcs[0]->get_sample_rate();
|
|
}
|
|
|
|
osmosdr::freq_range_t osmosdr_source_c_impl::get_freq_range( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_freq_range( chan );
|
|
}
|
|
|
|
double osmosdr_source_c_impl::set_center_freq( double freq, size_t chan )
|
|
{
|
|
return _srcs[chan]->set_center_freq( freq, chan );
|
|
// return freq;
|
|
}
|
|
|
|
double osmosdr_source_c_impl::get_center_freq( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_center_freq( chan );
|
|
}
|
|
|
|
double osmosdr_source_c_impl::set_freq_corr( double ppm, size_t chan )
|
|
{
|
|
return _srcs[chan]->set_freq_corr( ppm, chan );
|
|
}
|
|
|
|
double osmosdr_source_c_impl::get_freq_corr( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_freq_corr( chan );
|
|
}
|
|
|
|
std::vector<std::string> osmosdr_source_c_impl::get_gain_names( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_gain_names( chan );
|
|
}
|
|
|
|
osmosdr::gain_range_t osmosdr_source_c_impl::get_gain_range( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_gain_range( chan );
|
|
}
|
|
|
|
osmosdr::gain_range_t osmosdr_source_c_impl::get_gain_range( const std::string & name, size_t chan )
|
|
{
|
|
return _srcs[chan]->get_gain_range( name, chan );
|
|
}
|
|
|
|
double osmosdr_source_c_impl::set_gain( double gain, size_t chan )
|
|
{
|
|
return _srcs[chan]->set_gain( gain, chan );
|
|
}
|
|
|
|
double osmosdr_source_c_impl::set_gain( double gain, const std::string & name, size_t chan)
|
|
{
|
|
return _srcs[chan]->set_gain( gain, name, chan );
|
|
}
|
|
|
|
double osmosdr_source_c_impl::get_gain( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_gain( chan );
|
|
}
|
|
|
|
double osmosdr_source_c_impl::get_gain( const std::string & name, size_t chan )
|
|
{
|
|
return _srcs[chan]->get_gain( name, chan );
|
|
}
|
|
|
|
std::vector< std::string > osmosdr_source_c_impl::get_antennas( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_antennas( chan );
|
|
}
|
|
|
|
std::string osmosdr_source_c_impl::set_antenna( const std::string & antenna, size_t chan )
|
|
{
|
|
return _srcs[chan]->set_antenna( antenna, chan );
|
|
}
|
|
|
|
std::string osmosdr_source_c_impl::get_antenna( size_t chan )
|
|
{
|
|
return _srcs[chan]->get_antenna( chan );
|
|
}
|