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  */
58 soapy_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 );
85 double set_sample_rate( double rate );
86 double get_sample_rate( void );
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);
92 std::vector<std::string> get_gain_names( 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);
106 std::vector< std::string > get_antennas( size_t chan);
107 std::string set_antenna( const std::string & antenna,
108  size_t chan);
109 std::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);
115 void set_time_source(const std::string &source,
116  const size_t mboard);
117 std::string get_time_source(const size_t mboard);
118 std::vector<std::string> get_time_sources(const size_t mboard);
119 void set_clock_source(const std::string &source,
120  const size_t mboard);
121 std::string get_clock_source(const size_t mboard);
122 std::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);
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 */
Definition: time_spec.h:39
Definition: sink_iface.h:33
Definition: soapy_sink_c.h:63
::osmosdr::time_spec_t get_time_now(size_t mboard)
void set_clock_source(const std::string &source, const size_t mboard)
void set_time_now(const ::osmosdr::time_spec_t &time_spec, size_t mboard)
std::vector< std::string > get_gain_names(size_t chan)
static std::vector< std::string > get_devices()
void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec)
bool set_gain_mode(bool automatic, size_t chan)
::osmosdr::time_spec_t get_time_last_pps(size_t mboard)
std::vector< std::string > get_time_sources(const size_t mboard)
std::string get_clock_source(const size_t mboard)
osmosdr::gain_range_t get_gain_range(const std::string &name, size_t chan)
osmosdr::freq_range_t get_freq_range(size_t chan)
osmosdr::freq_range_t get_bandwidth_range(size_t chan)
void set_time_source(const std::string &source, const size_t mboard)
std::vector< std::string > get_antennas(size_t chan)
double get_bandwidth(size_t chan)
osmosdr::gain_range_t get_gain_range(size_t chan)
double get_gain(size_t chan)
osmosdr::meta_range_t get_sample_rates(void)
std::string get_antenna(size_t chan)
void set_dc_offset(const std::complex< double > &offset, size_t chan)
void set_iq_balance(const std::complex< double > &balance, size_t chan)
double set_center_freq(double freq, size_t chan)
std::string set_antenna(const std::string &antenna, size_t chan)
double get_center_freq(size_t chan)
double set_if_gain(double gain, size_t chan)
double get_freq_corr(size_t chan)
double set_bb_gain(double gain, size_t chan)
double get_clock_rate(size_t mboard)
double set_sample_rate(double rate)
double get_sample_rate(void)
double set_gain(double gain, const std::string &name, size_t chan)
bool get_gain_mode(size_t chan)
void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec)
std::string get_time_source(const size_t mboard)
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.
double set_freq_corr(double ppm, size_t chan)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
std::vector< std::string > get_clock_sources(const size_t mboard)
size_t get_num_channels(void)
double get_gain(const std::string &name, size_t chan)
double set_gain(double gain, size_t chan)
void set_clock_rate(double rate, size_t mboard)
double set_bandwidth(double bandwidth, size_t chan)
Definition: soapy_sink_c.h:33
soapy_sink_c_sptr make_soapy_sink_c(const std::string &args="")
Return a shared_ptr to a new instance of soapy_sink_c.
Definition: ranges.h:75