GNU Radio's TEST Package
airspyhf_source_c.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2013 Dimitri Stolnikov <horiz0n@gmx.net>
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 #ifndef INCLUDED_AIRSPYHF_SOURCE_C_H
23 #define INCLUDED_AIRSPYHF_SOURCE_C_H
24 
25 #include <boost/circular_buffer.hpp>
26 
27 #include <mutex>
28 #include <condition_variable>
29 
30 #include <gnuradio/sync_block.h>
31 
32 #include <libairspyhf/airspyhf.h>
33 
34 #include "source_iface.h"
35 
36 class airspyhf_source_c;
37 
38 typedef std::shared_ptr<airspyhf_source_c> airspyhf_source_c_sptr;
39 
40 /*!
41  * \brief Return a shared_ptr to a new instance of airspyhf_source_c.
42  *
43  * To avoid accidental use of raw pointers, airspyhf_source_c's
44  * constructor is private. make_airspyhf_source_c is the public
45  * interface for creating new instances.
46  */
47 airspyhf_source_c_sptr make_airspyhf_source_c (const std::string & args = "");
48 
49 /*!
50  * \brief Provides a stream of complex samples.
51  * \ingroup block
52  */
54  public gr::sync_block,
55  public source_iface
56 {
57 private:
58  // The friend declaration allows make_airspyhf_source_c to
59  // access the private constructor.
60 
61  friend airspyhf_source_c_sptr make_airspyhf_source_c (const std::string & args);
62 
63  airspyhf_source_c (const std::string & args);
64 
65 public:
67 
68  bool start();
69  bool stop();
70 
71  int work( int noutput_items,
72  gr_vector_const_void_star &input_items,
73  gr_vector_void_star &output_items );
74 
75  static std::vector< std::string > get_devices();
76 
77  size_t get_num_channels( void );
78 
80  double set_sample_rate( double rate );
81  double get_sample_rate( void );
82 
84  double set_center_freq( double freq, size_t chan = 0 );
85  double get_center_freq( size_t chan = 0 );
86  double set_freq_corr( double ppm, size_t chan = 0 );
87  double get_freq_corr( size_t chan = 0 );
88 
89  std::vector<std::string> get_gain_names( size_t chan = 0 );
91  osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 );
92  double set_gain( double gain, size_t chan = 0 );
93  double set_gain( double gain, const std::string & name, size_t chan = 0 );
94  double get_gain( size_t chan = 0 );
95  double get_gain( const std::string & name, size_t chan = 0 );
96 
97  std::vector< std::string > get_antennas( size_t chan = 0 );
98  std::string set_antenna( const std::string & antenna, size_t chan = 0 );
99  std::string get_antenna( size_t chan = 0 );
100 
101 
102 private:
103  static int _airspyhf_rx_callback(airspyhf_transfer_t* transfer);
104  int airspyhf_rx_callback(void *samples, int sample_count);
105 
106  airspyhf_device *_dev;
107 
108  boost::circular_buffer<gr_complex> *_fifo;
109  std::mutex _fifo_lock;
110  std::condition_variable _samp_avail;
111 
112  std::vector< std::pair<double, uint32_t> > _sample_rates;
113  double _sample_rate;
114  double _center_freq;
115  double _freq_corr;
116 };
117 
118 #endif /* INCLUDED_AIRSPY_SOURCE_C_H */
airspyhf_source_c_sptr make_airspyhf_source_c(const std::string &args="")
Return a shared_ptr to a new instance of airspyhf_source_c.
Provides a stream of complex samples.
Definition: airspyhf_source_c.h:56
osmosdr::gain_range_t get_gain_range(size_t chan=0)
double get_center_freq(size_t chan=0)
double set_center_freq(double freq, size_t chan=0)
double get_freq_corr(size_t chan=0)
std::vector< std::string > get_gain_names(size_t chan=0)
double get_sample_rate(void)
std::string set_antenna(const std::string &antenna, size_t chan=0)
double get_gain(size_t chan=0)
double set_sample_rate(double rate)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
double set_gain(double gain, size_t chan=0)
osmosdr::gain_range_t get_gain_range(const std::string &name, size_t chan=0)
osmosdr::meta_range_t get_sample_rates(void)
friend airspyhf_source_c_sptr make_airspyhf_source_c(const std::string &args)
Return a shared_ptr to a new instance of airspyhf_source_c.
std::string get_antenna(size_t chan=0)
size_t get_num_channels(void)
double set_freq_corr(double ppm, size_t chan=0)
std::vector< std::string > get_antennas(size_t chan=0)
osmosdr::freq_range_t get_freq_range(size_t chan=0)
double get_gain(const std::string &name, size_t chan=0)
double set_gain(double gain, const std::string &name, size_t chan=0)
static std::vector< std::string > get_devices()
Definition: source_iface.h:33
Definition: ranges.h:75