GNU Radio's TEST Package
source.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Dimitri Stolnikov <horiz0n@gmx.net>
4  *
5  * GNU Radio is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3, or (at your option)
8  * any later version.
9  *
10  * GNU Radio is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with GNU Radio; see the file COPYING. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street,
18  * Boston, MA 02110-1301, USA.
19  */
20 #ifndef INCLUDED_OSMOSDR_SOURCE_H
21 #define INCLUDED_OSMOSDR_SOURCE_H
22 
23 #include <osmosdr/api.h>
24 #include <osmosdr/ranges.h>
25 #include <osmosdr/time_spec.h>
26 #include <gnuradio/hier_block2.h>
27 
28 namespace osmosdr {
29 
30 class source;
31 
32 /*!
33  * \brief Provides a stream of complex samples.
34  * \ingroup block
35  *
36  * This uses the preferred technique: subclassing gr::hier_block2.
37  */
38 class OSMOSDR_API source : virtual public gr::hier_block2
39 {
40 public:
41  typedef boost::shared_ptr< source > sptr;
42 
43  /*!
44  * \brief Return a shared_ptr to a new instance of source.
45  *
46  * To avoid accidental use of raw pointers, source's
47  * constructor is private. osmosdr::source::make is the public
48  * interface for creating new instances.
49  *
50  * \param args the address to identify the hardware
51  * \return a new osmosdr source block object
52  */
53  static sptr make( const std::string & args = "" );
54 
55  /*!
56  * Get the number of channels the underlying radio hardware offers.
57  * \return the number of available channels
58  */
59  virtual size_t get_num_channels( void ) = 0;
60 
61  /*!
62  * \brief seek file to \p seek_point relative to \p whence
63  *
64  * \param seek_point sample offset in file
65  * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
66  * \return true on success
67  */
68  virtual bool seek( long seek_point, int whence, size_t chan = 0 ) = 0;
69 
70  /*!
71  * Get the possible sample rates for the underlying radio hardware.
72  * \return a range of rates in Sps
73  */
75 
76  /*!
77  * Set the sample rate for the underlying radio hardware.
78  * This also will select the appropriate IF bandpass, if applicable.
79  * \param rate a new rate in Sps
80  */
81  virtual double set_sample_rate( double rate ) = 0;
82 
83  /*!
84  * Get the sample rate for the underlying radio hardware.
85  * This is the actual sample rate and may differ from the rate set.
86  * \return the actual rate in Sps
87  */
88  virtual double get_sample_rate( void ) = 0;
89 
90  /*!
91  * Get the tunable frequency range for the underlying radio hardware.
92  * \param chan the channel index 0 to N-1
93  * \return the frequency range in Hz
94  */
95  virtual osmosdr::freq_range_t get_freq_range( size_t chan = 0 ) = 0;
96 
97  /*!
98  * Tune the underlying radio hardware to the desired center frequency.
99  * This also will select the appropriate RF bandpass.
100  * \param freq the desired frequency in Hz
101  * \param chan the channel index 0 to N-1
102  * \return the actual frequency in Hz
103  */
104  virtual double set_center_freq( double freq, size_t chan = 0 ) = 0;
105 
106  /*!
107  * Get the center frequency the underlying radio hardware is tuned to.
108  * This is the actual frequency and may differ from the frequency set.
109  * \param chan the channel index 0 to N-1
110  * \return the frequency in Hz
111  */
112  virtual double get_center_freq( size_t chan = 0 ) = 0;
113 
114  /*!
115  * Set the frequency correction value in parts per million.
116  * \param ppm the desired correction value in parts per million
117  * \param chan the channel index 0 to N-1
118  * \return correction value in parts per million
119  */
120  virtual double set_freq_corr( double ppm, size_t chan = 0 ) = 0;
121 
122  /*!
123  * Get the frequency correction value.
124  * \param chan the channel index 0 to N-1
125  * \return correction value in parts per million
126  */
127  virtual double get_freq_corr( size_t chan = 0 ) = 0;
128 
129  /*!
130  * Get the gain stage names of the underlying radio hardware.
131  * \param chan the channel index 0 to N-1
132  * \return a vector of strings containing the names of gain stages
133  */
134  virtual std::vector<std::string> get_gain_names( size_t chan = 0 ) = 0;
135 
136  /*!
137  * Get the settable overall gain range for the underlying radio hardware.
138  * \param chan the channel index 0 to N-1
139  * \return the gain range in dB
140  */
141  virtual osmosdr::gain_range_t get_gain_range( size_t chan = 0 ) = 0;
142 
143  /*!
144  * Get the settable gain range for a specific gain stage.
145  * \param name the name of the gain stage
146  * \param chan the channel index 0 to N-1
147  * \return the gain range in dB
148  */