SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
USRPTX.hxx
Go to the documentation of this file.
1#pragma once
2/*
3Copyright (c) 2012,2013,2014, 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#include "SoDaBase.hxx"
30#include "Params.hxx"
31#include "RadioTX.hxx"
32#include <SoDa/ReSampler.hxx>
33#include <vector>
34#include <complex>
35
36#include <uhd/usrp/multi_usrp.hpp>
37#include <uhd/stream.hpp>
38
39#include <SoDa/MailBox.hxx>
40#include <queue>
41#include <memory>
42
43namespace SoDa {
44 class USRPTX;
45 typedef std::shared_ptr<USRPTX> USRPTXPtr;
46
58 class USRPTX : public RadioTX {
59 protected:
67 USRPTX(ParamsPtr params, uhd::usrp::multi_usrp::sptr _usrp);
68
69 public:
70 static USRPTXPtr make(ParamsPtr params, uhd::usrp::multi_usrp::sptr _usrp) {
71 auto ret = std::shared_ptr<USRPTX>(new USRPTX(params, _usrp));
72 ret->self = ret;
73 ret->registerThread(ret);
74 return ret;
75 }
76
89 bool transmitSwitch(bool tx_on);
90
97 void init() { };
98
107 bool put(CBufPtr buf);
108
113 RadioTXPtr getSelfPtr() { return self.lock(); }
114
115 private:
116 uhd::usrp::multi_usrp::sptr usrp;
117
118 uhd::stream_args_t * stream_args;
119 uhd::tx_streamer::sptr tx_bits;
120 uhd::tx_metadata_t tx_md;
121
122 std::weak_ptr<USRPTX> self;
123
124 // Optional 4:1 upsampling — active when hw wire rate is 2.5 MS/s
126 SoDa::ReSamplerPtr hw_resampler;
127 std::vector<std::complex<float>> accu;
128 std::vector<std::complex<float>> rs_in;
129 std::vector<std::complex<float>> hw_cf;
130 unsigned int rs_in_size;
131 unsigned int hw_buf_size;
132 };
133
134}
The Baseclass for all SoDa objects, and useful commonly used classes.
RadioTX(ParamsPtr params, const std::string &name)
Constructor for RF Transmit/modulator process.
The Transmit RF Path.
Definition USRPTX.hxx:58
std::vector< std::complex< float > > accu
accumulator for 625 kS/s input
Definition USRPTX.hxx:127
uhd::tx_metadata_t tx_md
metadata describing USRP transmit buffer
Definition USRPTX.hxx:120
RadioTXPtr getSelfPtr()
used for exception processing and such.
Definition USRPTX.hxx:113
unsigned int hw_buf_size
resampler output / UHD send size (2.5 MS/s)
Definition USRPTX.hxx:131
uhd::usrp::multi_usrp::sptr usrp
the radio.
Definition USRPTX.hxx:116
static USRPTXPtr make(ParamsPtr params, uhd::usrp::multi_usrp::sptr _usrp)
Definition USRPTX.hxx:70
void init()
Some initialization must occurr after all the components are created.
Definition USRPTX.hxx:97
std::weak_ptr< USRPTX > self
Definition USRPTX.hxx:122
USRPTX(ParamsPtr params, uhd::usrp::multi_usrp::sptr _usrp)
Constructor for RF Transmit/modulator process.
bool put(CBufPtr buf)
The TX hardware unit doesn't do much at all.
unsigned int rs_in_size
resampler input block size (625 kS/s)
Definition USRPTX.hxx:130
uhd::tx_streamer::sptr tx_bits
USRP (UHD) transmit stream handle.
Definition USRPTX.hxx:119
std::vector< std::complex< float > > rs_in
one resampler input block
Definition USRPTX.hxx:128
bool needs_resample
Definition USRPTX.hxx:125
std::vector< std::complex< float > > hw_cf
resampler output at 2.5 MS/s
Definition USRPTX.hxx:129
bool transmitSwitch(bool tx_on)
most transmit chains will require multiple stages to enable the transmitter.
SoDa::ReSamplerPtr hw_resampler
Definition USRPTX.hxx:126
uhd::stream_args_t * stream_args
Definition USRPTX.hxx:118
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42
std::shared_ptr< CBuf > CBufPtr
Definition SoDaBase.hxx:64
std::shared_ptr< RadioTX > RadioTXPtr
Definition RadioTX.hxx:57
std::shared_ptr< USRPTX > USRPTXPtr
Definition USRPTX.hxx:45