GNU Radio's OsmoSDR 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 #define ssize_t int
46 
47 /* copied from rtl sdr */
56 };
57 
58 class rtl_tcp_source_f;
59 typedef boost::shared_ptr<rtl_tcp_source_f> rtl_tcp_source_f_sptr;
60 
61 rtl_tcp_source_f_sptr make_rtl_tcp_source_f (
62  size_t itemsize,
63  const char *host,
64  unsigned short port,
65  int payload_size,
66  bool eof = false,
67  bool wait = false);
68 
69 class rtl_tcp_source_f : public gr::sync_block
70 {
71 private:
72  size_t d_itemsize;
73  int d_payload_size; // maximum transmission unit (packet length)
74  bool d_eof; // zero-length packet is EOF
75  bool d_wait; // wait if data if not immediately available
76  int d_socket; // handle to socket
77  unsigned char *d_temp_buff; // hold buffer between calls
78  size_t d_temp_offset; // point to temp buffer location offset
79  float *d_LUT;
80 
81  unsigned int d_tuner_type;
82  unsigned int d_tuner_gain_count;
83  unsigned int d_tuner_if_gain_count;
84 
85 private:
86  rtl_tcp_source_f(size_t itemsize, const char *host,
87  unsigned short port, int payload_size, bool eof, bool wait);
88 
89  // The friend declaration allows make_source_c to
90  // access the private constructor.
91  friend rtl_tcp_source_f_sptr make_rtl_tcp_source_f (
92  size_t itemsize,
93  const char *host,
94  unsigned short port,
95  int payload_size,
96  bool eof,
97  bool wait);
98 
99 public:
101 
102  enum rtlsdr_tuner get_tuner_type() { return (enum rtlsdr_tuner) d_tuner_type; }
103  unsigned int get_tuner_gain_count() { return d_tuner_gain_count; }
104  unsigned int get_tuner_if_gain_count() { return d_tuner_if_gain_count; }
105 
106  int work(int noutput_items,
107  gr_vector_const_void_star &input_items,
108  gr_vector_void_star &output_items);
109 
110  void set_freq(int freq);
111  void set_sample_rate(int sample_rate);
112  void set_gain_mode(int manual);
113  void set_gain(int gain);
114  void set_freq_corr(int ppm);
115  void set_if_gain(int stage, int gain);
116  void set_agc_mode(int on);
117  void set_direct_sampling(int on);
118  void set_offset_tuning(int on);
119 };
120 
121 
122 #endif /* RTL_TCP_SOURCE_F_H */
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)
Definition: rtl_tcp_source_f.h:52
Definition: rtl_tcp_source_f.h:53
void set_agc_mode(int on)
void set_offset_tuning(int on)
Definition: rtl_tcp_source_f.h:50
void set_gain_mode(int manual)
Definition: rtl_tcp_source_f.h:49
Definition: rtl_tcp_source_f.h:69
void set_if_gain(int stage, int gain)
void set_freq(int freq)
enum rtlsdr_tuner get_tuner_type()
Definition: rtl_tcp_source_f.h:102
void set_sample_rate(int sample_rate)
void set_freq_corr(int ppm)
unsigned int get_tuner_if_gain_count()
Definition: rtl_tcp_source_f.h:104
Definition: rtl_tcp_source_f.h:54
Definition: rtl_tcp_source_f.h:55
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)
rtlsdr_tuner
Definition: rtl_tcp_source_f.h:48
void * optval_t
Definition: rtl_tcp_source_f.h:42
void set_direct_sampling(int on)
unsigned int get_tuner_gain_count()
Definition: rtl_tcp_source_f.h:103
Definition: rtl_tcp_source_f.h:51
void set_gain(int gain)