SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
PlutoRX.hxx
Go to the documentation of this file.
1#pragma once
2/*
3Copyright (c) 2026 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
51
52#include "RadioRX.hxx"
53#include "SoDaBase.hxx"
54#include "Params.hxx"
56#include <SoDa/ReSampler.hxx>
57#include <iio.h>
58#include <memory>
59#include <vector>
60#include <complex>
61
62namespace SoDa {
63 class PlutoRX;
64 typedef std::shared_ptr<PlutoRX> PlutoRXPtr;
65
66 class PlutoRX : public RadioRX {
67 protected:
69
70 public:
72
74 auto ret = std::shared_ptr<PlutoRX>(new PlutoRX(params));
75 ret->self = ret;
76 ret->registerThread(ret);
77 return ret;
78 }
79
84 void setNCOFreq(double freq) override;
85
91 bool downConvert() override;
92
94 void startStream() override;
95
97 void stopStream() override;
98
99 bool streamEnabled() override;
100
102 void enableIFStreamer(bool enable) override;
103
104 private:
105 void doMixer(std::vector<std::complex<float>> & buf);
106
107 // IIO streaming objects — owned by this thread.
108 iio_context * ctx;
109 iio_device * dev;
110 iio_channel * rx_i_chan;
111 iio_channel * rx_q_chan;
112 iio_buffer * rxbuf;
113
114 unsigned int hw_buf_size;
115 unsigned int rs_out_size;
116 unsigned int rf_buf_size;
117
119
122
123 SoDa::ReSamplerPtr hw_resampler;
124
125 std::vector<std::complex<float>> hw_cf;
126 std::vector<std::complex<float>> rs_out;
127 std::vector<std::complex<float>> accu;
128
130
131 std::weak_ptr<PlutoRX> self;
132 };
133}
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.
void enableIFStreamer(bool enable) override
Control whether raw RF samples are forwarded to the IF stream.
static PlutoRXPtr make(ParamsPtr params)
Definition PlutoRX.hxx:73
void stopStream() override
Disarm the streaming flag; IIO DMA continues draining silently.
bool if_streaming_enabled
true → push raw RF copies to if_stream
Definition PlutoRX.hxx:121
iio_device * dev
cf-ad9361-lpc
Definition PlutoRX.hxx:109
QuadratureOscillator IF_osc
Definition PlutoRX.hxx:129
void doMixer(std::vector< std::complex< float > > &buf)
iio_channel * rx_i_chan
voltage0 (input) — I component
Definition PlutoRX.hxx:110
unsigned int hw_buf_size
IIO buffer size in samples (at 2.5 MSPS)
Definition PlutoRX.hxx:114
void setNCOFreq(double freq) override
Update the IF NCO frequency used by the complex mixer.
bool downConvert() override
Refill the IIO buffer (2.5 MSPS), resample to 625 kSPS, mix, and publish 30000-sample CBufs to rx_str...
std::vector< std::complex< float > > hw_cf
SC16→float conversion (hw_buf_size)
Definition PlutoRX.hxx:125
std::vector< std::complex< float > > rs_out
resampler output (rs_out_size)
Definition PlutoRX.hxx:126
std::weak_ptr< PlutoRX > self
Definition PlutoRX.hxx:131
iio_context * ctx
Definition PlutoRX.hxx:108
double rx_sample_rate
625 kSPS — used for IF NCO phase increment
Definition PlutoRX.hxx:118
unsigned int rs_out_size
hw_resampler output size (at 625 kSPS)
Definition PlutoRX.hxx:115
iio_buffer * rxbuf
Definition PlutoRX.hxx:112
unsigned int rf_buf_size
publish chunk size for BaseBandRX (30000)
Definition PlutoRX.hxx:116
iio_channel * rx_q_chan
voltage1 (input) — Q component
Definition PlutoRX.hxx:111
std::vector< std::complex< float > > accu
accumulator for 30000-sample publish
Definition PlutoRX.hxx:127
void startStream() override
Arm the streaming flag so downConvert() publishes samples.
SoDa::ReSamplerPtr hw_resampler
2.5 MSPS → 625 kSPS
Definition PlutoRX.hxx:123
PlutoRX(ParamsPtr params)
bool streamEnabled() override
test the processing stream flag
bool streaming
true after startStream(); samples published
Definition PlutoRX.hxx:120
sin/cos oscillator to drive TX signal chain
RadioRX(ParamsPtr params)
Constructor Build a RadioRX thread.
ParamsPtr params
Definition RadioRX.hxx:91
std::shared_ptr< PlutoRX > PlutoRXPtr
Definition PlutoRX.hxx:64
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42