GNU Radio's TEST Package
rtl_tcp_source_f.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Hoernchen <la@tfc-server.de>
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 
21 #ifndef RTL_TCP_SOURCE_F_H
22 #define RTL_TCP_SOURCE_F_H
23 
24 #include <gnuradio/sync_block.h>
25 #include <gnuradio/thread/thread.h>
26 
27 #if defined(_WIN32)
28 // if not posix, assume winsock
29 #pragma comment(lib, "ws2_32.lib")
30 #define USING_WINSOCK
31 #include <winsock2.h>
32 #include <ws2tcpip.h>
33 #define SHUT_RDWR 2
34 typedef char* optval_t;
35 #else
36 #include <netdb.h>
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <netinet/tcp.h>
41 #include <arpa/inet.h>
42 typedef void* optval_t;
43 #endif
44 
45 #ifdef _MSC_VER
46 #include <cstddef>
47 typedef ptrdiff_t ssize_t;
48 #endif //_MSC_VER
49 
50 /* copied from rtl sdr */
59 };
60 
61 class rtl_tcp_source_f;
62 typedef std::shared_ptr<rtl_tcp_source_f> rtl_tcp_source_f_sptr;
63 
64 rtl_tcp_source_f_sptr make_rtl_tcp_source_f (
65  size_t itemsize,
66  const char *host,
67  unsigned short port,
68  int payload_size,
69  bool eof = false,
70  bool wait = false);
71 
72 class rtl_tcp_source_f : public gr::sync_block
73 {
74 private:
75  size_t d_itemsize;
76  int d_payload_size; // maximum transmission unit (packet length)
77  bool d_eof; // zero-length packet is EOF
78  bool d_wait; // wait if data if not immediately available
79  int d_socket; // handle to socket
80  unsigned char *d_temp_buff; // hold buffer between calls
81  size_t d_temp_offset; // point to temp buffer location offset
82  float *d_LUT;
83 
84  unsigned int d_tuner_type;
85  unsigned int d_tuner_gain_count;
86  unsigned int d_tuner_if_gain_count;
87 
88 private:
89  rtl_tcp_source_f(size_t itemsize, const char *host,
90  unsigned short port, int payload_size, bool eof, bool wait);
91 
92  // The friend declaration allows make_source_c to
93  // access the private constructor.
94  friend rtl_tcp_source_f_sptr make_rtl_tcp_source_f (
95  size_t itemsize,
96  const char *host,
97  unsigned short port,
98  int payload_size,
99  bool eof,
100  bool wait);
101 
102 public:
104 
105  enum rtlsdr_tuner get_tuner_type() { return (enum rtlsdr_tuner) d_tuner_type; }
106  unsigned int get_tuner_gain_count() { return d_tuner_gain_count; }
107  unsigned int get_tuner_if_gain_count() { return d_tuner_if_gain_count; }
108 
109  int work(int noutput_items,
110  gr_vector_const_void_star &input_items,
111  gr_vector_void_star &output_items);
112 
113  void set_freq(int freq);
114  void set_sample_rate(int sample_rate);
115  void set_gain_mode(int manual);
116  void set_gain(int gain);
117  void set_freq_corr(int ppm);
118  void set_if_gain(int stage, int gain);
119  void set_agc_mode(int on);
120  void set_direct_sampling(int on);
121  void set_offset_tuning(int on);
122 };
123 
124 
125 #endif /* RTL_TCP_SOURCE_F_H */
Definition: rtl_tcp_source_f.h:73
void set_freq_corr(int ppm)
void set_gain_mode(int manual)
void set_if_gain(int stage, int gain)
unsigned int get_tuner_gain_count()
Definition: rtl_tcp_source_f.h:106
void set_gain(int gain)
void set_sample_rate(int sample_rate)
void set_offset_tuning(int on)
unsigned int get_tuner_if_gain_count()
Definition: rtl_tcp_source_f.h:107
void set_freq(int freq)
void set_direct_sampling(int on)
friend rtl_tcp_source_f_sptr make_rtl_tcp_source_f(size_t itemsize, const char *host, unsigned short port, int payload_size, bool eof, bool wait)
void set_agc_mode(int on)
enum rtlsdr_tuner get_tuner_type()
Definition: rtl_tcp_source_f.h:105
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
rtl_tcp_source_f_sptr make_rtl_tcp_source_f(size_t itemsize, const char *host, unsigned short port, int payload_size, bool eof=false, bool wait=false)
void * optval_t
Definition: rtl_tcp_source_f.h:42
rtlsdr_tuner
Definition: rtl_tcp_source_f.h:51
@ RTLSDR_TUNER_FC0013
Definition: rtl_tcp_source_f.h:55
@ RTLSDR_TUNER_R828D
Definition: rtl_tcp_source_f.h:58
@ RTLSDR_TUNER_E4000
Definition: rtl_tcp_source_f.h:53
@ RTLSDR_TUNER_UNKNOWN
Definition: rtl_tcp_source_f.h:52
@ RTLSDR_TUNER_FC0012
Definition: rtl_tcp_source_f.h:54
@ RTLSDR_TUNER_R820T
Definition: rtl_tcp_source_f.h:57
@ RTLSDR_TUNER_FC2580
Definition: rtl_tcp_source_f.h:56