Agora  1.2.0
Agora project
radio_soapysdr.h
Go to the documentation of this file.
1 
6 #ifndef RADIO_SOAPYSDR_H_
7 #define RADIO_SOAPYSDR_H_
8 
9 #include <memory>
10 
11 #include "SoapySDR/Device.hpp"
12 #include "config.h"
13 #include "radio.h"
14 #include "radio_data_plane.h"
15 
16 class RadioSoapySdr : public Radio {
17  public:
18  explicit RadioSoapySdr(RadioDataPlane::DataPlaneType rx_dp_type);
19  ~RadioSoapySdr() final;
20 
21  void Init(const Config* cfg, size_t id, const std::string& serial,
22  const std::vector<size_t>& enabled_channels, bool hw_framer) final;
23  void Setup(const std::vector<double>& tx_gains,
24  const std::vector<double>& rx_gains) final;
25  void Activate(Radio::ActivationTypes type = Radio::ActivationTypes::kActivate,
26  long long act_time_ns = 0, size_t samples = 0) final;
27  void Deactivate() final;
28  void Close() final;
29  void Flush() final;
30 
31  int Tx(const void* const* tx_buffs, size_t tx_size, Radio::TxFlags tx_flags,
32  long long& tx_time_ns) final;
33 
34  int Rx(std::vector<std::vector<std::complex<int16_t>>>& rx_data,
35  size_t rx_size, RxFlags& out_flags, long long& rx_time_ns) final;
36 
37  int Rx(std::vector<std::vector<std::complex<int16_t>>*>& rx_buffs,
38  size_t rx_size, RxFlags& out_flags, long long& rx_time_ns) final;
39 
40  int Rx(std::vector<void*>& rx_locs, size_t rx_size, RxFlags& out_flags,
41  long long& rx_time_ns) final;
42 
43  void SetTimeAtTrigger(long long time_ns = 0) final;
44  long long GetTimeNs() final;
45  //End of generic interface
46 
47  void ConfigureTddModeBs(bool is_ref_radio) final;
48  void ConfigureTddModeUe() final;
49  void ClearSyncDelay() final;
50  void PrintSettings() const final;
51  void Trigger() final;
52  void ReadSensor() const final;
53  void AdjustDelay(const std::string& delay) final;
54 
55  // Calibration helper functions
56  void InitRefTx(size_t channel, double freq);
57  void InitCalRx(size_t channel, double center_freq);
58  void ResetTxGains();
59  void ResetRxGains();
60  void SetTxCalGain(size_t channel);
61  void SetRxGain(size_t channel, const std::string& gain_stage, double value);
62  void SetTxGain(size_t channel, const std::string& gain_stage, double value);
63  void StartRefTx(size_t channel);
64  void StopRefTx(size_t channel);
65  void SetDcOffset(int direction, size_t channel, std::complex<double> dc_corr);
66  void SetIQBalance(int direction, size_t channel,
67  std::complex<double> i_qcorr);
68  //Sets both tx and rx, is this ok?
69  void SetFreqBb(size_t channel, double freq);
70  void SetFreqRf(size_t channel, double freq);
71  //End Calibration Routines
72  void InitAgc(bool enabled, size_t setting);
73 
74  std::vector<std::complex<float>> SnoopSamples(size_t channel,
75  size_t read_size);
76 
77  inline SoapySDR::Device* SoapyDevice() const { return dev_; }
78  inline const std::string& IpAddress() const { return ip_address_; }
79 
80  private:
81  void Correlator(bool enable);
82 
83  SoapySDR::Device* dev_;
84  std::string ip_address_;
85  std::unique_ptr<RadioDataPlane> rxp_;
86  SoapySDR::Stream* txs_;
88 };
89 
90 #endif // RADIO_SOAPYSDR_H_
Radio::Init
virtual void Init(const Config *cfg, size_t id, const std::string &serial, const std::vector< size_t > &enabled_channels, bool hw_framer)=0
Definition: radio.cc:46
radio.h
Defination file for the Radio class.
RadioDataPlane::DataPlaneType
DataPlaneType
Definition: radio_data_plane.h:18
Radio::Id
size_t Id() const
Definition: radio.h:27
FrameStats::FrameIdentifier
const std::string & FrameIdentifier() const
Definition: framestats.h:70
kSoapyMakeMaxAttempts
static constexpr size_t kSoapyMakeMaxAttempts
Definition: radio_soapysdr.cc:17
Config::Freq
double Freq() const
Definition: config.h:57
RadioSoapySdr::StopRefTx
void StopRefTx(size_t channel)
Definition: radio_soapysdr.cc:772
Config::SampsPerSymbol
size_t SampsPerSymbol() const
Definition: config.h:234
RadioSoapySdr::ResetTxGains
void ResetTxGains()
Definition: radio_soapysdr.cc:722
Config::Rate
double Rate() const
Definition: config.h:58
Config::UeChannel
std::string UeChannel() const
Definition: config.h:114
Config::NumChannels
size_t NumChannels() const
Definition: config.h:98
RadioSoapySdr::rxp_
std::unique_ptr< RadioDataPlane > rxp_
Definition: radio_soapysdr.h:85
RadioSoapySdr::ResetRxGains
void ResetRxGains()
Definition: radio_soapysdr.cc:732
RadioSoapySdr::SnoopSamples
std::vector< std::complex< float > > SnoopSamples(size_t channel, size_t read_size)
Definition: radio_soapysdr.cc:756
FrameStats::GetPilotSymbol
size_t GetPilotSymbol(size_t location) const
Definition: framestats.cc:122
Config::OfdmTxZeroPrefix
size_t OfdmTxZeroPrefix() const
Definition: config.h:211
RadioSoapySdr::IpAddress
const std::string & IpAddress() const
Definition: radio_soapysdr.h:78
Radio::EnabledChannels
const std::vector< size_t > & EnabledChannels() const
Definition: radio.h:71
RadioSoapySdr::InitCalRx
void InitCalRx(size_t channel, double center_freq)
Definition: radio_soapysdr.cc:713
RadioSoapySdr::ip_address_
std::string ip_address_
Definition: radio_soapysdr.h:84
kIrisDriverRelMinAPI
static constexpr int kIrisDriverRelMinAPI
Definition: radio_soapysdr.cc:30
RadioSoapySdr::SetTxCalGain
void SetTxCalGain(size_t channel)
Definition: radio_soapysdr.cc:742
Catch::Generators::value
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:3999
RadioSoapySdr::SetTimeAtTrigger
void SetTimeAtTrigger(long long time_ns=0) final
Definition: radio_soapysdr.cc:579
RadioSoapySdr::ReadSensor
void ReadSensor() const final
Definition: radio_soapysdr.cc:559
kSoapyMinorMinAPI
static constexpr int kSoapyMinorMinAPI
Definition: radio_soapysdr.cc:23
RadioSoapySdr::SetDcOffset
void SetDcOffset(int direction, size_t channel, std::complex< double > dc_corr)
Definition: radio_soapysdr.cc:777
kIrisDriverDayMinAPI
static constexpr int kIrisDriverDayMinAPI
Definition: radio_soapysdr.cc:29
Radio::ActivationTypes
ActivationTypes
Definition: radio.h:23
Config::Beacon
const std::vector< uint32_t > & Beacon() const
Definition: config.h:350
RadioSoapySdr::SoapyDevice
SoapySDR::Device * SoapyDevice() const
Definition: radio_soapysdr.h:77
spdlog::level::info
@ info
Definition: common.h:215
AGORA_LOG_ERROR
#define AGORA_LOG_ERROR(...)
Definition: logger.h:39
kIrisDriverYearMinAPI
static constexpr int kIrisDriverYearMinAPI
Definition: radio_soapysdr.cc:27
Config::BwFilter
double BwFilter() const
Definition: config.h:62
flags
list flags
Definition: .ycm_extra_conf.py:39
Config::Frame
const FrameStats & Frame() const
Definition: config.h:340
matplotlibcpp::fill
bool fill(const std::vector< Numeric > &x, const std::vector< Numeric > &y, const std::map< std::string, std::string > &keywords)
Definition: matplotlibcpp.h:790
Config::RadioRfFreq
double RadioRfFreq() const
Definition: config.h:61
Radio::HwFramer
bool HwFramer() const
Definition: radio.h:29
AGORA_LOG_TRACE
#define AGORA_LOG_TRACE(...)
Definition: logger.h:92
Radio::SerialNumber
const std::string & SerialNumber() const
Definition: radio.h:28
RadioSoapySdr::Rx
int Rx(std::vector< std::vector< std::complex< int16_t >>> &rx_data, size_t rx_size, RxFlags &out_flags, long long &rx_time_ns) final
Definition: radio_soapysdr.cc:522
Config::Nco
double Nco() const
Definition: config.h:59
RadioSoapySdr::ClearSyncDelay
void ClearSyncDelay() final
Definition: radio_soapysdr.cc:706
RadioSoapySdr::dev_
SoapySDR::Device * dev_
Definition: radio_soapysdr.h:83
kPrintRadioSettings
static constexpr bool kPrintRadioSettings
Definition: radio_soapysdr.cc:18
kSoapyBuildMinAPI
static constexpr int kSoapyBuildMinAPI
Definition: radio_soapysdr.cc:24
RadioSoapySdr::Flush
void Flush() final
Definition: radio_soapysdr.cc:972
RadioSoapySdr::SetFreqRf
void SetFreqRf(size_t channel, double freq)
Definition: radio_soapysdr.cc:796
RadioSoapySdr::Deactivate
void Deactivate() final
Definition: radio_soapysdr.cc:469
RadioSoapySdr::correlator_enabled_
bool correlator_enabled_
Definition: radio_soapysdr.h:87
RadioSoapySdr::Activate
void Activate(Radio::ActivationTypes type=Radio::ActivationTypes::kActivate, long long act_time_ns=0, size_t samples=0) final
Definition: radio_soapysdr.cc:419
RadioSoapySdr::Trigger
void Trigger() final
Definition: radio_soapysdr.cc:557
Radio::Close
virtual void Close()=0
Definition: radio.cc:35
Radio
Definition: radio.h:15
Radio::TxFlags
TxFlags
Definition: radio.h:20
RadioSoapySdr::InitRefTx
void InitRefTx(size_t channel, double freq)
Definition: radio_soapysdr.cc:708
fmt::v8::detail::find
auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2258
radio_soapysdr.h
Defination file for the RadioSoapySdr class.
RadioSoapySdr::Init
void Init(const Config *cfg, size_t id, const std::string &serial, const std::vector< size_t > &enabled_channels, bool hw_framer) final
Definition: radio_soapysdr.cc:108
i
for i
Definition: generate_data.m:107
extract_version.reg
reg
Definition: extract_version.py:9
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::detail::void
j template void())
Definition: json.hpp:4744
RadioSoapySdr::SetRxGain
void SetRxGain(size_t channel, const std::string &gain_stage, double value)
Definition: radio_soapysdr.cc:751
kIrisDriverMonthMinAPI
static constexpr int kIrisDriverMonthMinAPI
Definition: radio_soapysdr.cc:28
Radio::cfg_
const Config * cfg_
Definition: radio.h:78
Catch::cout
std::ostream & cout()
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::basic_json::dump
string_t dump(const int indent=-1, const char indent_char=' ', const bool ensure_ascii=false, const error_handler_t error_handler=error_handler_t::strict) const
serialization
Definition: json.hpp:20228
comms-lib.h
Communications Library: a) Generate pilot/preamble sequences b) OFDM modulation.
RadioSoapySdr::GetTimeNs
long long GetTimeNs() final
Definition: radio_soapysdr.cc:596
RadioSoapySdr::InitAgc
void InitAgc(bool enabled, size_t setting)
Definition: radio_soapysdr.cc:945
CommsLib::Hadamard2
static int Hadamard2(int i, int j)
Definition: comms-lib.h:95
kUseUHD
static constexpr bool kUseUHD
Definition: symbols.h:162
RadioSoapySdr::SetIQBalance
void SetIQBalance(int direction, size_t channel, std::complex< double > i_qcorr)
Definition: radio_soapysdr.cc:782
start
end start
Definition: inspect_agora_results.m:95
RadioSoapySdr::txs_
SoapySDR::Stream * txs_
Definition: radio_soapysdr.h:86
RadioSoapySdr::SetFreqBb
void SetFreqBb(size_t channel, double freq)
Definition: radio_soapysdr.cc:791
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::basic_json
a class to store JSON values
Definition: json.hpp:3367
Radio::RxFlags
RxFlags
Definition: radio.h:19
s
s
Definition: simulate_performance.m:3
symbols.h
kUhdInitTimeSec
static constexpr size_t kUhdInitTimeSec
Definition: radio_soapysdr.cc:33
RadioSoapySdr::AdjustDelay
void AdjustDelay(const std::string &delay) final
Definition: radio_soapysdr.cc:787
Config::Beamsweep
bool Beamsweep() const
Definition: config.h:105
RadioDataPlane
Definition: radio_data_plane.h:16
Utils::Uint32tocfloat
static std::vector< std::complex< float > > Uint32tocfloat(const std::vector< uint32_t > &in, const std::string &order)
Definition: utils.cc:243
Config::NumUeChannels
size_t NumUeChannels() const
Definition: config.h:99
Config
Definition: config.h:26
AGORA_LOG_INFO
#define AGORA_LOG_INFO(...)
Definition: logger.h:62
AGORA_LOG_FRAME
#define AGORA_LOG_FRAME(...)
Definition: logger.h:72
RadioSoapySdr::PrintSettings
void PrintSettings() const final
Definition: radio_soapysdr.cc:609
AGORA_LOG_WARN
#define AGORA_LOG_WARN(...)
Definition: logger.h:53
Config::BeaconLen
size_t BeaconLen() const
Definition: config.h:103
to_string
std::string to_string() const
Definition: eth_common.h:64
config.h
Declaration file for the configuration class which importants json configuration values into class va...
Config::SingleGain
bool SingleGain() const
Definition: config.h:63
RadioSoapySdr::Correlator
void Correlator(bool enable)
Definition: radio_soapysdr.cc:955
rx_data
case QPSK rx_data
Definition: generate_data.m:160
RadioSoapySdr::ConfigureTddModeBs
void ConfigureTddModeBs(bool is_ref_radio) final
Definition: radio_soapysdr.cc:801
kAttnMax
static constexpr double kAttnMax
Definition: radio_soapysdr.cc:19
RadioSoapySdr::RadioSoapySdr
RadioSoapySdr(RadioDataPlane::DataPlaneType rx_dp_type)
Definition: radio_soapysdr.cc:35
RadioSoapySdr::Setup
void Setup(const std::vector< double > &tx_gains, const std::vector< double > &rx_gains) final
Definition: radio_soapysdr.cc:291
Config::NumRadios
size_t NumRadios() const
Definition: config.h:95
kDebugRadioTX
static constexpr bool kDebugRadioTX
Definition: symbols.h:208
mm_gui.sched
sched
Definition: mm_gui.py:111
max
max(y1, y1_1)
RadioSoapySdr::SetTxGain
void SetTxGain(size_t channel, const std::string &gain_stage, double value)
Definition: radio_soapysdr.cc:746
RadioSoapySdr::Tx
int Tx(const void *const *tx_buffs, size_t tx_size, Radio::TxFlags tx_flags, long long &tx_time_ns) final
Definition: radio_soapysdr.cc:486
RadioSoapySdr::~RadioSoapySdr
~RadioSoapySdr() final
Definition: radio_soapysdr.cc:81
RadioSoapySdr::ConfigureTddModeUe
void ConfigureTddModeUe() final
Definition: radio_soapysdr.cc:878
RadioSoapySdr::StartRefTx
void StartRefTx(size_t channel)
Definition: radio_soapysdr.cc:765
Config::BeaconAnt
size_t BeaconAnt() const
Definition: config.h:102
RadioSoapySdr::Close
void Close() final
Definition: radio_soapysdr.cc:89
Config::Pilot
const std::vector< uint32_t > & Pilot() const
Definition: config.h:349
kSoapyMajorMinAPI
static constexpr int kSoapyMajorMinAPI
Definition: radio_soapysdr.cc:22
RadioSoapySdr
Definition: radio_soapysdr.h:16
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::detail2::end
end_tag end(T &&...)
FrameStats::NumTotalSyms
size_t NumTotalSyms() const
Definition: framestats.cc:93
radio_data_plane.h
Declaration file for the RadioDataPlane Class.
fmt::v8::detail::type
type
Definition: core.h:1131
Config::Coeffs
const std::vector< uint32_t > & Coeffs() const
Definition: config.h:347