SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
USRPRX.hxx
Go to the documentation of this file.
1#pragma once
2/*
3Copyright (c) 2012, Matthew H. Reilly (kb1vc)
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:
9
10 Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30#include "RadioRX.hxx"
31#include "SoDaBase.hxx"
32#include "SoDaThread.hxx"
33
34#include "Command.hxx"
35#include "Params.hxx"
36#include "UI.hxx"
38#include <SoDa/ReSampler.hxx>
39#include <vector>
40#include <complex>
41#include <uhd/usrp/multi_usrp.hpp>
42#include <uhd/stream.hpp>
43
44#include <SoDa/MailBox.hxx>
45
46#include <memory>
47
48namespace SoDa {
49 class USRPRX;
50 typedef std::shared_ptr<USRPRX> USRPRXPtr;
51
57 class USRPRX : public SoDa::RadioRX {
58 protected:
66 USRPRX(ParamsPtr params, uhd::usrp::multi_usrp::sptr usrp);
67 public:
68 static USRPRXPtr make(ParamsPtr params, uhd::usrp::multi_usrp::sptr _usrp) {
69 auto ret = std::shared_ptr<USRPRX>(new USRPRX(params, _usrp));
70 ret->self = ret;
71 ret->registerThread(ret);
72 return ret;
73 }
74
83 void setNCOFreq(double freq);
84
94
99
104
109
115
122 void enableIFStreamer(bool enable);
123
124 private:
133
138
139 // state for the USRP widget
140 uhd::rx_streamer::sptr rx_bits;
141 uhd::usrp::multi_usrp::sptr usrp;
142
143 unsigned int rx_buffer_size;
144
145 // are we collecting?
147
149
150 // pointer to user interface box -- we send it FFT snapshots
152
153 // IF tuner
157
158 // spectrum reporting
160
161 //debug hooks
162 int outf[2];
164
165 std::ofstream rf_dumpfile;
166 std::ofstream if_dumpfile;
167
168 std::weak_ptr<USRPRX> self;
169
170 // Optional 4:1 downsampling — active when hw wire rate is 2.5 MS/s
172 SoDa::ReSamplerPtr hw_resampler;
173 std::vector<std::complex<float>> hw_cf;
174 std::vector<std::complex<float>> rs_out;
175 std::vector<std::complex<float>> accu;
176 unsigned int hw_buf_size;
177 unsigned int rs_out_size;
178 unsigned int rf_buf_size;
179 };
180}
181
Thread class that provides the common IF receive functions for any supported radio (USRP/Adalm/Pluto/...
The Baseclass for all SoDa objects, and useful commonly used classes.
The Baseclass for all SoDa thread objects.
ModulationType
modulation selector targets take one of these values
Definition Command.hxx:532
sin/cos oscillator to drive TX signal chain
ParamsPtr params
Definition RadioRX.hxx:91
The Receive RF Path.
Definition USRPRX.hxx:57
bool downConvert()
A receiver must accept input data from the rx_stream and beat it against its NCO to produce output on...
std::ofstream rf_dumpfile
Definition USRPRX.hxx:165
double current_IF_tuning
Definition USRPRX.hxx:155
std::vector< std::complex< float > > rs_out
decimated output at 625 kS/s
Definition USRPRX.hxx:174
int outf[2]
Definition USRPRX.hxx:162
uhd::usrp::multi_usrp::sptr usrp
Definition USRPRX.hxx:141
bool enable_spectrum_report
Definition USRPRX.hxx:159
static USRPRXPtr make(ParamsPtr params, uhd::usrp::multi_usrp::sptr _usrp)
Definition USRPRX.hxx:68
void actualStartStream()
The USRP never stops the RX streamer once it starts.
unsigned int hw_buf_size
samples per recv at hw rate
Definition USRPRX.hxx:176
double rx_sample_rate
Definition USRPRX.hxx:156
QuadratureOscillator IF_osc
Definition USRPRX.hxx:154
SoDa::ReSamplerPtr hw_resampler
Definition USRPRX.hxx:172
std::weak_ptr< USRPRX > self
Definition USRPRX.hxx:168
bool audio_rx_stream_enabled
Definition USRPRX.hxx:146
void setNCOFreq(double freq)
Set the last LO (convert to baseband) frequency for the NCO.
bool needs_resample
Definition USRPRX.hxx:171
void enableIFStreamer(bool enable)
Enable IF streamer - This passes the incoming RF sample buffer onto the IF stream where it can be con...
std::vector< std::complex< float > > accu
accumulator → rf_buf_size chunks
Definition USRPRX.hxx:175
uhd::rx_streamer::sptr rx_bits
Definition USRPRX.hxx:140
std::ofstream if_dumpfile
Definition USRPRX.hxx:166
SoDa::Command::ModulationType rx_modulation
Definition USRPRX.hxx:148
unsigned int rx_buffer_size
Definition USRPRX.hxx:143
unsigned int rf_buf_size
publish chunk (30000 samples at 625 kS/s)
Definition USRPRX.hxx:178
unsigned int rs_out_size
resampler output block size
Definition USRPRX.hxx:177
USRPRX(ParamsPtr params, uhd::usrp::multi_usrp::sptr usrp)
The constructor.
void startStream()
flush the input rx data stream and set the stream_processing flag to on.
bool streamEnabled()
test the processing stream flag
void stopStream()
we never stop a USRP stream until the radio shuts down
std::vector< std::complex< float > > hw_cf
raw samples at hw rate
Definition USRPRX.hxx:173
void doMixer(SoDa::CBufPtr inout)
implement a complex down converter with complex multiplication
void closeStream()
stop and close down the USRP input stream
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42
std::shared_ptr< USRPRX > USRPRXPtr
Definition USRPRX.hxx:50
std::shared_ptr< CBuf > CBufPtr
Definition SoDaBase.hxx:64