22 #include <lime/LimeSuite.h>
23 #include <ring_buffer.h>
27 #include <libconfig.h++>
28 #include "srslte/srslte.h"
44 : _buffer(bev::linear_ringbuffer::delayed_init {})
58 bool init(uint8_t device_index,
const char* sample_file,
const char* write_sample_file);
68 bool tune(uint32_t frequency, uint32_t sample_rate, uint32_t bandwidth,
double gain,
const std::string& antenna);
92 int getSamples(cf_t* data, uint32_t nsamples, srslte_timestamp_t* rx_time);
117 double get_buffer_level() {
if (!_buffer_ready) {
return 0; }
return static_cast<double>(_buffer.size()) /
static_cast<double>(_buffer.capacity()); }
127 uint32_t
rssi() {
return _rssi; }
131 void* _sdr =
nullptr;
133 const libconfig::Config& _cfg;
134 lms_stream_t _stream;
135 bev::linear_ringbuffer _buffer;
136 std::thread _readerThread;
143 std::string _antenna;
145 unsigned _underflows;
149 srslte_filesource_t file_source;
150 srslte_filesink_t file_sink;
152 std::chrono::steady_clock::time_point _last_read;
154 bool _high_watermark_reached =
false;
155 int _sleep_adjustment = 0;
157 unsigned _buffer_ms = 200;
158 bool _buffer_ready =
false;
159 bool _reading_from_file =
false;
160 bool _writing_to_file =
false;
double get_buffer_level()
Get current ringbuffer level (0 = empty .
double get_frequency()
Get current center frequency.
std::string get_antenna()
Get current antenna port.
bool tune(uint32_t frequency, uint32_t sample_rate, uint32_t bandwidth, double gain, const std::string &antenna)
Tune the SDR to the desired frequency, and set gain, filter and antenna parameters.
int getSamples(cf_t *data, uint32_t nsamples, srslte_timestamp_t *rx_time)
Store nsamples count samples into the buffer at data.
double get_sample_rate()
Get current sample rate.
bool init(uint8_t device_index, const char *sample_file, const char *write_sample_file)
Initializes the SDR interface and creates a ring buffer according to the params from Cfg.
bool setSampleRate(unsigned sample_rate)
Adjust the sample rate.
virtual ~LimeSdrReader()
Default destructor.
void start()
Start reading samples from the SDR.
unsigned get_filter_bw()
Get current filter bandwidth.
uint32_t rssi()
Get RSSI estimate (disabled at the moment)
void clear_buffer()
Clear all samples from the rx buffers.
void stop()
Stop reading samples from the SDR.
LimeSdrReader(const libconfig::Config &cfg)
Default constructor.
double get_gain()
Get current gain.
Interface to LimeSDR via LimeSuite.