Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 3.10)
project(SoapyLoopback CXX)

find_package(SoapySDR "0.8.0" NO_MODULE REQUIRED)
Expand Down
20 changes: 14 additions & 6 deletions Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ SoapyLoopback::SoapyLoopback(const SoapySDR::Kwargs &args):
bufferedElems(0),
resetBuffer(false),
gainMin(0.0),
gainMax(0.0)
gainMax(0.0),
// TX/loopback state
_txActive(false),
_txBufferLength(DEFAULT_BUFFER_LENGTH),
_txNumBuffers(DEFAULT_NUM_BUFFERS),
_loopbackFormat(""),
_loopbackBytesPerSample(8), // Default to CF32, will be set in setupStream
_loopback_head(0),
_loopback_tail(0),
_loopback_count(0),
_loopback_overflow(false),
_loopbackEnabled(false)
{

}
Expand Down Expand Up @@ -96,7 +107,7 @@ size_t SoapyLoopback::getNumChannels(const int dir) const

bool SoapyLoopback::getFullDuplex(const int direction, const size_t channel) const
{
return false;
return true; // Support simultaneous TX and RX for loopback testing
}

/*******************************************************************
Expand All @@ -113,10 +124,7 @@ std::vector<std::string> SoapyLoopback::listAntennas(const int direction, const

void SoapyLoopback::setAntenna(const int direction, const size_t channel, const std::string &name)
{
if (direction != SOAPY_SDR_RX)
{
throw std::runtime_error("setAntena failed: RTL-SDR only supports RX");
}
// Accept any antenna setting for both RX and TX
}

std::string SoapyLoopback::getAntenna(const int direction, const size_t channel) const
Expand Down
27 changes: 27 additions & 0 deletions SoapyLoopback.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ class SoapyLoopback: public SoapySDR::Device
long long &timeNs,
const long timeoutUs = 100000);

int writeStream(
SoapySDR::Stream *stream,
const void * const *buffs,
const size_t numElems,
int &flags,
const long long timeNs = 0,
const long timeoutUs = 100000);

/*******************************************************************
* Direct buffer access API
******************************************************************/
Expand Down Expand Up @@ -306,4 +314,23 @@ class SoapyLoopback: public SoapySDR::Device
std::atomic<bool> resetBuffer;

double gainMin, gainMax;

// TX state
bool _txActive;
size_t _txBufferLength;
size_t _txNumBuffers;

// Loopback format tracking
std::string _loopbackFormat; // Store the format for loopback operations
size_t _loopbackBytesPerSample; // Bytes per sample for the loopback format

// Loopback ring buffer (TX writes here, RX reads from here)
std::mutex _loopback_mutex;
std::condition_variable _loopback_cond;
std::vector<Buffer> _loopback_buffs;
size_t _loopback_head;
size_t _loopback_tail;
std::atomic<size_t> _loopback_count;
std::atomic<bool> _loopback_overflow;
bool _loopbackEnabled; // when true, RX reads from loopback buffer instead of synthetic data
};
Loading