GNU Radio's OSMOSDR 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 #include <boost/thread/mutex.hpp>
27 #include <boost/thread/condition_variable.hpp>
28 
29 #include <gnuradio/sync_block.h>
30 
31 #include <libairspyhf/airspyhf.h>
32 
33 #include "source_iface.h"
34 
35 class airspyhf_source_c;
36 
37 typedef boost::shared_ptr<airspyhf_source_c> airspyhf_source_c_sptr;
38 
39 /*!
40  * \brief Return a shared_ptr to a new instance of airspyhf_source_c.
41  *
42  * To avoid accidental use of raw pointers, airspyhf_source_c's
43  * constructor is private. make_airspyhf_source_c is the public
44  * interface for creating new instances.
45  */
46 airspyhf_source_c_sptr make_airspyhf_source_c (const std::string & args = "");
47 
48 /*!
49  * \brief Provides a stream of complex samples.
50  * \ingroup block
51  */
53  public gr::sync_block,
54  public source_iface
55 {
56 private:
57  // The friend declaration allows make_airspyhf_source_c to
58  // access the private constructor.
59 
60  friend airspyhf_source_c_sptr make_airspyhf_source_c (const std::string & args);
61 
62  airspyhf_source_c (const std::string & args);
63 
64 public:
66 
67  bool start();
68  bool stop();
69 
70  int work( int noutput_items,
71  gr_vector_const_void_star &input_items,
72  gr_vector_void_star &output_items );
73 
74  static std::vector< std::string > get_devices();
75 
76  size_t get_num_channels( void );
77 
79  double set_sample_rate( double rate );
80  double get_sample_rate( void );
81 
82  osmosdr::freq_range_t get_freq_range( size_t chan = 0 );
83  double set_center_freq( double freq, size_t chan = 0 );
84  double get_center_freq( size_t chan = 0 );
85  double set_freq_corr( double ppm, size_t chan = 0 );
86  double get_freq_corr( size_t chan = 0 );
87 
88  std::vector<std::string> get_gain_names( size_t chan = 0 );
89  osmosdr::gain_range_t get_gain_range( size_t chan = 0 );
90  osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 );
91  double set_gain( double gain, size_t chan = 0 );
92  double set_gain( double gain, const std::string & name, size_t chan = 0 );
93  double get_gain( size_t chan = 0 );
94  double get_gain( const std::string & name, size_t chan = 0 );
95 
96  std::vector< std::string > get_antennas( size_t chan = 0 );
97  std::string set_antenna( const std::string & antenna, size_t chan = 0 );
98  std::string get_antenna( size_t chan = 0 );
99 
100 
101 private:
102  static int _airspyhf_rx_callback(airspyhf_transfer_t* transfer);
103  int airspyhf_rx_callback(void *samples, int sample_count);
104 
105  airspyhf_device *_dev;
106 
107  boost::circular_buffer<gr_complex> *_fifo;
108  boost::mutex _fifo_lock;
109  boost::condition_variable _samp_avail;
110 
111  std::vector< std::pair<double, uint32_t> > _sample_rates;
112  double _sample_rate;
113  double _center_freq;
114  double _freq_corr;
115 };
116 
117 #endif /* INCLUDED_AIRSPY_SOURCE_C_H */
airspyhf_source_c::make_airspyhf_source_c
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.
airspyhf_source_c::get_devices
static std::vector< std::string > get_devices()
airspyhf_source_c::set_antenna
std::string set_antenna(const std::string &antenna, size_t chan=0)
make_airspyhf_source_c
airspyhf_source_c_sptr make_airspyhf_source_c(const std::string &args="")
Return a shared_ptr to a new instance of airspyhf_source_c.
airspyhf_source_c::set_sample_rate
double set_sample_rate(double rate)
airspyhf_source_c::start
bool start()
airspyhf_source_c::get_center_freq
double get_center_freq(size_t chan=0)
airspyhf_source_c::set_gain
double set_gain(double gain, size_t chan=0)
airspyhf_source_c::get_freq_corr
double get_freq_corr(size_t chan=0)
airspyhf_source_c::get_antennas
std::vector< std::string > get_antennas(size_t chan=0)
airspyhf_source_c::set_center_freq
double set_center_freq(double freq, size_t chan=0)
airspyhf_source_c
Provides a stream of complex samples.
Definition: airspyhf_source_c.h:52
airspyhf_source_c::~airspyhf_source_c
~airspyhf_source_c()
airspyhf_source_c::get_sample_rate
double get_sample_rate(void)
airspyhf_source_c::get_num_channels
size_t get_num_channels(void)
airspyhf_source_c::get_gain_range
osmosdr::gain_range_t get_gain_range(size_t chan=0)
airspyhf_source_c::get_gain_names
std::vector< std::string > get_gain_names(size_t chan=0)
source_iface.h
airspyhf_source_c::get_freq_range
osmosdr::freq_range_t get_freq_range(size_t chan=0)
airspyhf_source_c::get_antenna
std::string get_antenna(size_t chan=0)
osmosdr::meta_range_t
Definition: ranges.h:75
source_iface
Definition: source_iface.h:32
airspyhf_source_c::stop
bool stop()
airspyhf_source_c::get_gain
double get_gain(size_t chan=0)
airspyhf_source_c::work
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
airspyhf_source_c::get_sample_rates
osmosdr::meta_range_t get_sample_rates(void)
airspyhf_source_c::set_freq_corr
double set_freq_corr(double ppm, size_t chan=0)