GNU Radio's TEST Package
miri_source_c.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_MIRI_SOURCE_C_H
21 #define INCLUDED_MIRI_SOURCE_C_H
22 
23 #include <gnuradio/sync_block.h>
24 
25 #include <gnuradio/thread/thread.h>
26 
27 #include <mutex>
28 #include <condition_variable>
29 
30 #include "source_iface.h"
31 
32 class miri_source_c;
33 typedef struct mirisdr_dev mirisdr_dev_t;
34 
35 typedef std::shared_ptr<miri_source_c> miri_source_c_sptr;
36 
37 /*!
38  * \brief Return a shared_ptr to a new instance of miri_source_c.
39  *
40  * To avoid accidental use of raw pointers, miri_source_c's
41  * constructor is private. make_miri_source_c is the public
42  * interface for creating new instances.
43  */
44 miri_source_c_sptr make_miri_source_c (const std::string & args = "");
45 
46 /*!
47  * \brief Provides a stream of complex samples.
48  * \ingroup block
49  */
51  public gr::sync_block,
52  public source_iface
53 {
54 private:
55  // The friend declaration allows make_miri_source_c to
56  // access the private constructor.
57 
58  friend miri_source_c_sptr make_miri_source_c (const std::string & args);
59 
60  /*!
61  * \brief Provides a stream of complex samples.
62  */
63  miri_source_c (const std::string & args); // private constructor
64 
65  public:
66  ~miri_source_c (); // public destructor
67 
68  int work( int noutput_items,
69  gr_vector_const_void_star &input_items,
70  gr_vector_void_star &output_items );
71 
72  static std::vector< std::string > get_devices();
73 
74  size_t get_num_channels( void );
75 
77  double set_sample_rate( double rate );
78  double get_sample_rate( void );
79 
81  double set_center_freq( double freq, size_t chan = 0 );
82  double get_center_freq( size_t chan = 0 );
83  double set_freq_corr( double ppm, size_t chan = 0 );
84  double get_freq_corr( size_t chan = 0 );
85 
86  std::vector<std::string> get_gain_names( size_t chan = 0 );
88  osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 );
89  bool set_gain_mode( bool automatic, size_t chan = 0 );
90  bool get_gain_mode( 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 private:
101  static void _mirisdr_callback(unsigned char *buf, uint32_t len, void *ctx);
102  void mirisdr_callback(unsigned char *buf, uint32_t len);
103  static void _mirisdr_wait(miri_source_c *obj);
104  void mirisdr_wait();
105 
106  mirisdr_dev_t *_dev;
107  gr::thread::thread _thread;
108  unsigned short **_buf;
109  unsigned int *_buf_lens;
110  unsigned int _buf_num;
111  unsigned int _buf_head;
112  unsigned int _buf_used;
113  std::mutex _buf_mutex;
114  std::condition_variable _buf_cond;
115  bool _running;
116 
117  unsigned int _buf_offset;
118  int _samp_avail;
119 
120  bool _auto_gain;
121  unsigned int _skipped;
122 };
123 
124 #endif /* INCLUDED_MIRI_SOURCE_C_H */
Provides a stream of complex samples.
Definition: miri_source_c.h:53
bool get_gain_mode(size_t chan=0)
double set_freq_corr(double ppm, size_t chan=0)
std::string get_antenna(size_t chan=0)
double set_gain(double gain, size_t chan=0)
friend miri_source_c_sptr make_miri_source_c(const std::string &args)
Return a shared_ptr to a new instance of miri_source_c.
size_t get_num_channels(void)
double set_gain(double gain, const std::string &name, size_t chan=0)
double get_center_freq(size_t chan=0)
double get_gain(const std::string &name, size_t chan=0)
std::vector< std::string > get_gain_names(size_t chan=0)
std::vector< std::string > get_antennas(size_t chan=0)
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
double set_sample_rate(double rate)
double get_freq_corr(size_t chan=0)
std::string set_antenna(const std::string &antenna, size_t chan=0)
osmosdr::gain_range_t get_gain_range(size_t chan=0)
osmosdr::freq_range_t get_freq_range(size_t chan=0)
double get_gain(size_t chan=0)
osmosdr::gain_range_t get_gain_range(const std::string &name, size_t chan=0)
double get_sample_rate(void)
bool set_gain_mode(bool automatic, size_t chan=0)
osmosdr::meta_range_t get_sample_rates(void)
static std::vector< std::string > get_devices()
double set_center_freq(double freq, size_t chan=0)
Definition: source_iface.h:33
miri_source_c_sptr make_miri_source_c(const std::string &args="")
Return a shared_ptr to a new instance of miri_source_c.
struct mirisdr_dev mirisdr_dev_t
Definition: miri_source_c.h:33
Definition: ranges.h:75