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