GNU Radio's TEST Package

soapy_sink_c.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2015 Josh Blum <josh@joshknows.com>
4 * Copyright 2013 Dimitri Stolnikov <horiz0n@gmx.net>
5 *
6 * GNU Radio is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3, or (at your option)
9 * any later version.
10 *
11 * GNU Radio is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Radio; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street,
19 * Boston, MA 02110-1301, USA.
20 */
21#ifndef INCLUDED_SOAPY_SINK_C_H
22#define INCLUDED_SOAPY_SINK_C_H
23
24#include <gnuradio/block.h>
25#include <gnuradio/sync_block.h>
26
27#include "osmosdr/ranges.h"
28#include "sink_iface.h"
29
30 class soapy_sink_c;
31
32 namespace SoapySDR
33{
34 class Device;
35 class Stream;
36}
37
38/*
39 * We use std::shared_ptr's instead of raw pointers for all access
40 * to gr_blocks (and many other data structures). The shared_ptr gets
41 * us transparent reference counting, which greatly simplifies storage
42 * management issues. This is especially helpful in our hybrid
43 * C++ / Python system.
44 *
45 * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
46 *
47 * As a convention, the _sptr suffix indicates a std::shared_ptr
48 */
49 typedef std::shared_ptr<soapy_sink_c> soapy_sink_c_sptr;
50
51/*!
52 * \brief Return a shared_ptr to a new instance of soapy_sink_c.
53 *
54 * To avoid accidental use of raw pointers, soapy_sink_c's
55 * constructor is private. make_soapy_sink_c is the public
56 * interface for creating new instances.
57 */
58soapy_sink_c_sptr make_soapy_sink_c (const std::string & args = "");
59
60 class soapy_sink_c :
61 public gr::sync_block,
62 public sink_iface
63{
64 private:
65 // The friend declaration allows soapy_make_sink_c to
66 // access the private constructor.
67 friend soapy_sink_c_sptr make_soapy_sink_c (const std::string & args);
68
69 soapy_sink_c (const std::string & args); // private constructor
70
71 ~soapy_sink_c(void);
72
73 public:
74 bool start();
75 bool stop();
76
77 int work( int noutput_items,
78 gr_vector_const_void_star &input_items,
79 gr_vector_void_star &output_items );
80
81 static std::vector< std::string > get_devices();
82
83 size_t get_num_channels( void );
84 osmosdr::meta_range_t get_sample_rates( void );
85 double set_sample_rate( double rate );
86 double get_sample_rate( void );
87 osmosdr::freq_range_t get_freq_range( size_t chan);
88 double set_center_freq( double freq, size_t chan);
89 double get_center_freq( size_t chan);
90 double set_freq_corr( double ppm, size_t chan);
91 double get_freq_corr( size_t chan);
92std::vector<std::string> get_gain_names( size_t chan);
93 osmosdr::gain_range_t get_gain_range( size_t chan);
94 osmosdr::gain_range_t get_gain_range( const std::string & name,
95 size_t chan);
96 bool set_gain_mode( bool automatic, size_t chan);
97 bool get_gain_mode( size_t chan);
98 double set_gain( double gain, size_t chan);
99 double set_gain( double gain,
100 const std::string & name,
101 size_t chan);
102 double get_gain( size_t chan);
103 double get_gain( const std::string & name, size_t chan);
104 double set_if_gain( double gain, size_t chan);
105 double set_bb_gain( double gain, size_t chan);
106std::vector< std::string > get_antennas( size_t chan);
107std::string set_antenna( const std::string & antenna,
108 size_t chan);
109std::string get_antenna( size_t chan);
110 void set_dc_offset( const std::complex<double> &offset, size_t chan);
111 void set_iq_balance( const std::complex<double> &balance, size_t chan);
112 double set_bandwidth( double bandwidth, size_t chan);
113 double get_bandwidth( size_t chan);
114 osmosdr::freq_range_t get_bandwidth_range( size_t chan);
115 void set_time_source(const std::string &source,
116 const size_t mboard);
117std::string get_time_source(const size_t mboard);
118std::vector<std::string> get_time_sources(const size_t mboard);
119 void set_clock_source(const std::string &source,
120 const size_t mboard);
121std::string get_clock_source(const size_t mboard);
122std::vector<std::string> get_clock_sources(const size_t mboard);
123 double get_clock_rate(size_t mboard);
124 void set_clock_rate(double rate, size_t mboard);
125::osmosdr::time_spec_t get_time_now(size_t mboard);
126::osmosdr::time_spec_t get_time_last_pps(size_t mboard);
127 void set_time_now(const ::osmosdr::time_spec_t &time_spec,
128 size_t mboard);
129 void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec);
130 void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec);
131
132 private:
133 SoapySDR::Device *_device;
134 SoapySDR::Stream *_stream;
135 size_t _nchan;
136};
137
138#endif /* INCLUDED_SOAPY_SINK_C_H */
osmosdr::time_spec_t
Definition: time_spec.h:39
sink_iface
Definition: sink_iface.h:33
soapy_sink_c
Definition: soapy_sink_c.h:63
soapy_sink_c::get_time_now
::osmosdr::time_spec_t get_time_now(size_t mboard)
soapy_sink_c::set_clock_source
void set_clock_source(const std::string &source, const size_t mboard)
soapy_sink_c::set_time_now
void set_time_now(const ::osmosdr::time_spec_t &time_spec, size_t mboard)
soapy_sink_c::get_devices
static std::vector< std::string > get_devices()
soapy_sink_c::set_time_next_pps
void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec)
soapy_sink_c::set_gain_mode
bool set_gain_mode(bool automatic, size_t chan)
soapy_sink_c::get_time_last_pps
::osmosdr::time_spec_t get_time_last_pps(size_t mboard)
soapy_sink_c::get_clock_source
std::string get_clock_source(const size_t mboard)
soapy_sink_c::get_gain_range
osmosdr::gain_range_t get_gain_range(const std::string &name, size_t chan)
soapy_sink_c::get_freq_range
osmosdr::freq_range_t get_freq_range(size_t chan)
soapy_sink_c::get_bandwidth_range
osmosdr::freq_range_t get_bandwidth_range(size_t chan)
soapy_sink_c::set_time_source
void set_time_source(const std::string &source, const size_t mboard)
soapy_sink_c::get_antennas
std::vector< std::string > get_antennas(size_t chan)
soapy_sink_c::get_bandwidth
double get_bandwidth(size_t chan)
soapy_sink_c::get_clock_sources
std::vector< std::string > get_clock_sources(const size_t mboard)
soapy_sink_c::get_gain_range
osmosdr::gain_range_t get_gain_range(size_t chan)
soapy_sink_c::get_gain
double get_gain(size_t chan)
soapy_sink_c::stop
bool stop()
soapy_sink_c::get_sample_rates
osmosdr::meta_range_t get_sample_rates(void)
soapy_sink_c::get_antenna
std::string get_antenna(size_t chan)
soapy_sink_c::set_dc_offset
void set_dc_offset(const std::complex< double > &offset, size_t chan)
soapy_sink_c::set_iq_balance
void set_iq_balance(const std::complex< double > &balance, size_t chan)
soapy_sink_c::set_center_freq
double set_center_freq(double freq, size_t chan)
soapy_sink_c::get_gain_names
std::vector< std::string > get_gain_names(size_t chan)
soapy_sink_c::get_time_sources
std::vector< std::string > get_time_sources(const size_t mboard)
soapy_sink_c::set_antenna
std::string set_antenna(const std::string &antenna, size_t chan)
soapy_sink_c::get_center_freq
double get_center_freq(size_t chan)
soapy_sink_c::start
bool start()
soapy_sink_c::set_if_gain
double set_if_gain(double gain, size_t chan)
soapy_sink_c::get_freq_corr
double get_freq_corr(size_t chan)
soapy_sink_c::set_bb_gain
double set_bb_gain(double gain, size_t chan)
soapy_sink_c::get_clock_rate
double get_clock_rate(size_t mboard)
soapy_sink_c::set_sample_rate
double set_sample_rate(double rate)
soapy_sink_c::get_sample_rate
double get_sample_rate(void)
soapy_sink_c::set_gain
double set_gain(double gain, const std::string &name, size_t chan)
soapy_sink_c::get_gain_mode
bool get_gain_mode(size_t chan)
soapy_sink_c::set_time_unknown_pps
void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec)
soapy_sink_c::get_time_source
std::string get_time_source(const size_t mboard)
soapy_sink_c::make_soapy_sink_c
friend soapy_sink_c_sptr make_soapy_sink_c(const std::string &args)
Return a shared_ptr to a new instance of soapy_sink_c.
soapy_sink_c::set_freq_corr
double set_freq_corr(double ppm, size_t chan)
soapy_sink_c::work
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
soapy_sink_c::get_num_channels
size_t get_num_channels(void)
soapy_sink_c::get_gain
double get_gain(const std::string &name, size_t chan)
soapy_sink_c::set_gain
double set_gain(double gain, size_t chan)
soapy_sink_c::set_clock_rate
void set_clock_rate(double rate, size_t mboard)
soapy_sink_c::set_bandwidth
double set_bandwidth(double bandwidth, size_t chan)
SoapySDR
Definition: soapy_sink_c.h:33
ranges.h
sink_iface.h
make_soapy_sink_c
soapy_sink_c_sptr make_soapy_sink_c(const std::string &args="")
Return a shared_ptr to a new instance of soapy_sink_c.
osmosdr::meta_range_t
Definition: ranges.h:75