SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
SoDa::RTLSDRRX Class Reference

#include <RTLSDRRX.hxx>

Inheritance diagram for SoDa::RTLSDRRX:
SoDa::RadioRX SoDa::Thread SoDa::Base SoDa::Debug

Public Member Functions

 ~RTLSDRRX ()=default
void init () override
 perform initialization.
void setNCOFreq (double freq) override
 Methods that ALL radios must implement.
bool downConvert () override
 A receiver must accept input data from the rx_stream and beat it against its NCO to produce output on its if_stream.
void startStream () override
 flush the input rx data stream and set the stream_processing flag to on.
void stopStream () override
 flush the input rx data stream and set the stream_processing flag to off
bool streamEnabled () override
 test the processing stream flag
void enableIFStreamer (bool enable) override
 Enable IF streamer - This passes the incoming RF sample buffer onto the IF stream where it can be consumed by the periodogram widget or anybody else.
Public Member Functions inherited from SoDa::RadioRX
 RadioRX (ParamsPtr params)
 Constructor Build a RadioRX thread.
void run () final
 start the thread
Public Member Functions inherited from SoDa::Thread
void registerThread (SoDa::ThreadPtr me)
void operator() ()
void start ()
 Execute the thread's run loop.
void join ()
 more properly "Wait for this thread to exit its run loop".
void execCommand (CommandPtr cmd)
 Execute (dispatch) a message removed from the command stream to one of the basic Command handler functions.
virtual void shutDown ()
 optional method that performs cleanup – may not delete.
void sleep_ms (unsigned int milliseconds)
void sleep_us (unsigned int microseconds)
uint32_t getID ()
 Get the process/thread ID for this thread – helps with figuring out who caused a segfault.
Public Member Functions inherited from SoDa::Base
 Base (const std::string &oname)
 The constructor – pass a name for the object.
void registerSelf (BasePtr ptr)
std::string & getObjName ()
 get the name of this object
BasePtr findSoDaObject (const std::string &oname)
 find a SoDa Object by name.
double getTime ()
 Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS).
BasePtr getSelfPtr ()
 get a pointer to myself.
Public Member Functions inherited from SoDa::Debug
 Debug (std::string _unit_name=std::string("UNKNOWN"))
 Debug (const char *_unit_name_cstr)
 Debug (unsigned int _debug_level, std::string _unit_name=std::string("UNKNOWN"))
 Debug (unsigned int _debug_level, const char *_unit_name_cstr)
void debugMsg (const std::string &msg, unsigned int threshold=1)
void debugMsg (const SoDa::Format &fmt, unsigned int threshold=1)
void debugMsg (const char *msg, unsigned int threshold=1)
void setDebugLevel (unsigned int v)
unsigned int getDebugLevel ()

Static Public Member Functions

static RTLSDRRXPtr make (RTLSDRDevPtr dev_in, ParamsPtr params)
Static Public Member Functions inherited from SoDa::Debug
static void setDefaultLevel (unsigned int v)
static unsigned int getDefaultLevel ()
static void setGlobalLevel (unsigned int v)
static unsigned int getGlobalLevel ()

Protected Member Functions

 RTLSDRRX (RTLSDRDevPtr dev_in, ParamsPtr params)
Protected Member Functions inherited from SoDa::RadioRX
virtual void execGetCommand (CommandPtr cmd) final
 Parse an incoming GET command and dispatch.
virtual void execSetCommand (CommandPtr cmd) final
 Parse an incoming SET command and dispatch.
virtual void execRepCommand (CommandPtr cmd) final
 Parse an incoming REPort command and dispatch.
double getTime ()
 get the number of seconds since the "Epoch"
virtual void subscribeToMailBoxes (const std::vector< MailBoxBasePtr > &mailboxes) final
 SoDa Threads must subscribe to at least the control mailbox.
Protected Member Functions inherited from SoDa::Thread
 Thread (const std::string &oname, const std::string &version=std::string("12.2.0"))
 make the thread object.
Protected Member Functions inherited from SoDa::Debug
std::string curDateTime ()

Private Member Functions

void doMixer (std::vector< std::complex< float > > &buf)

Static Private Member Functions

static void asyncCallback (unsigned char *buf, uint32_t len, void *ctx)

Private Attributes

RTLSDRDevPtr rtl
unsigned int rs_in_size
 exact resampler input size (at 2.048 MSPS)
unsigned int rs_out_size
 resampler output size (at 625 kSPS)
unsigned int rf_buf_size
 publish chunk size (30000 samples at 625 kSPS)
double rx_sample_rate
 625 kSPS — used for IF NCO phase increment
std::atomic< bool > streaming {false}
bool if_streaming_enabled
std::atomic< unsigned int > diag_reads {0}
 async callback invocations
unsigned int diag_resamp_runs
 total resampler invocations
unsigned int diag_published
 total rf_buf_size blocks published
SoDa::ReSamplerPtr hw_resampler
 2.048 MSPS → 625 kSPS
std::mutex raw_accu_mutex
std::vector< std::complex< float > > raw_accu
 IQ accumulator filled by async callback.
std::vector< std::complex< float > > rs_in
 exact-size input to resampler (rs_in_size)
std::vector< std::complex< float > > rs_out
 resampler output (rs_out_size)
std::vector< std::complex< float > > accu
 accumulates resampled IQ for rf_buf_size publish
std::thread async_rx_thread
QuadratureOscillator IF_osc
std::weak_ptr< RTLSDRRXself

Static Private Attributes

static constexpr float HW_RATE = 2048000.0f
static constexpr unsigned int READ_BYTES = 16384
static constexpr unsigned int RAW_ACCU_MAX = 8

Additional Inherited Members

Static Public Attributes inherited from SoDa::Debug
static std::mutex debug_msg_mutex
Protected Attributes inherited from SoDa::RadioRX
ParamsPtr params
CDatMBoxPtr rx_stream
CDatMBoxPtr if_stream
CmdMBoxPtr cmd_stream
CmdMBox::Subscription cmd_subs
double current_IF_tuning
 current IF NCO frequency
Protected Attributes inherited from SoDa::Thread
std::weak_ptr< Threadself
 A pointer to ourself.
Protected Attributes inherited from SoDa::Debug
std::string unit_name
 the name of the unit reporting status
unsigned int debug_level
 the debug level (threshold) for messages
Static Protected Attributes inherited from SoDa::Debug
static unsigned int default_debug_level
static unsigned int global_debug_level

Detailed Description

Definition at line 63 of file RTLSDRRX.hxx.

Constructor & Destructor Documentation

◆ RTLSDRRX()

SoDa::RTLSDRRX::RTLSDRRX ( RTLSDRDevPtr dev_in,
ParamsPtr params )
protected

References SoDa::RadioRX::params.

Referenced by make().

◆ ~RTLSDRRX()

SoDa::RTLSDRRX::~RTLSDRRX ( )
default

Member Function Documentation

◆ asyncCallback()

void SoDa::RTLSDRRX::asyncCallback ( unsigned char * buf,
uint32_t len,
void * ctx )
staticprivate

◆ doMixer()

void SoDa::RTLSDRRX::doMixer ( std::vector< std::complex< float > > & buf)
private

◆ downConvert()

bool SoDa::RTLSDRRX::downConvert ( )
overridevirtual

A receiver must accept input data from the rx_stream and beat it against its NCO to produce output on its if_stream.

If the stream_processing flag is off, any rx_input data will be dumped.

Returns
true if the receiver had input data ready to convert, false otherwise.

Implements SoDa::RadioRX.

◆ enableIFStreamer()

void SoDa::RTLSDRRX::enableIFStreamer ( bool enable)
inlineoverridevirtual

Enable IF streamer - This passes the incoming RF sample buffer onto the IF stream where it can be consumed by the periodogram widget or anybody else.

Parameters
enableif true, send RF sample buffer onto if_stream, otherwise, don't.

Implements SoDa::RadioRX.

Definition at line 85 of file RTLSDRRX.hxx.

References if_streaming_enabled.

◆ init()

void SoDa::RTLSDRRX::init ( )
overridevirtual

perform initialization.

Not all modules need to implement this.

Reimplemented from SoDa::RadioRX.

◆ make()

RTLSDRRXPtr SoDa::RTLSDRRX::make ( RTLSDRDevPtr dev_in,
ParamsPtr params )
inlinestatic

Definition at line 70 of file RTLSDRRX.hxx.

References RTLSDRRX(), and SoDa::RadioRX::params.

◆ setNCOFreq()

void SoDa::RTLSDRRX::setNCOFreq ( double freq)
overridevirtual

Methods that ALL radios must implement.

Set the last LO (convert to baseband) frequency for the NCO.

This is called in response to a RX_NCO_FREQ message from the RadioControl thread.

Parameters
freqLO3 frequency its front-end frequency so that it can adjust its own oscillator.

Implements SoDa::RadioRX.

◆ startStream()

void SoDa::RTLSDRRX::startStream ( )
overridevirtual

flush the input rx data stream and set the stream_processing flag to on.

Implements SoDa::RadioRX.

◆ stopStream()

void SoDa::RTLSDRRX::stopStream ( )
overridevirtual

flush the input rx data stream and set the stream_processing flag to off

Implements SoDa::RadioRX.

◆ streamEnabled()

bool SoDa::RTLSDRRX::streamEnabled ( )
inlineoverridevirtual

test the processing stream flag

Returns
true if rx data should be down converted

Implements SoDa::RadioRX.

Definition at line 84 of file RTLSDRRX.hxx.

References streaming.

Member Data Documentation

◆ accu

std::vector<std::complex<float> > SoDa::RTLSDRRX::accu
private

accumulates resampled IQ for rf_buf_size publish

Definition at line 116 of file RTLSDRRX.hxx.

◆ async_rx_thread

std::thread SoDa::RTLSDRRX::async_rx_thread
private

Definition at line 118 of file RTLSDRRX.hxx.

◆ diag_published

unsigned int SoDa::RTLSDRRX::diag_published
private

total rf_buf_size blocks published

Definition at line 108 of file RTLSDRRX.hxx.

◆ diag_reads

std::atomic<unsigned int> SoDa::RTLSDRRX::diag_reads {0}
private

async callback invocations

Definition at line 106 of file RTLSDRRX.hxx.

◆ diag_resamp_runs

unsigned int SoDa::RTLSDRRX::diag_resamp_runs
private

total resampler invocations

Definition at line 107 of file RTLSDRRX.hxx.

◆ HW_RATE

float SoDa::RTLSDRRX::HW_RATE = 2048000.0f
staticconstexprprivate

Definition at line 93 of file RTLSDRRX.hxx.

◆ hw_resampler

SoDa::ReSamplerPtr SoDa::RTLSDRRX::hw_resampler
private

2.048 MSPS → 625 kSPS

Definition at line 110 of file RTLSDRRX.hxx.

◆ IF_osc

QuadratureOscillator SoDa::RTLSDRRX::IF_osc
private

Definition at line 120 of file RTLSDRRX.hxx.

◆ if_streaming_enabled

bool SoDa::RTLSDRRX::if_streaming_enabled
private

Definition at line 104 of file RTLSDRRX.hxx.

Referenced by enableIFStreamer().

◆ raw_accu

std::vector<std::complex<float> > SoDa::RTLSDRRX::raw_accu
private

IQ accumulator filled by async callback.

Definition at line 113 of file RTLSDRRX.hxx.

◆ RAW_ACCU_MAX

unsigned int SoDa::RTLSDRRX::RAW_ACCU_MAX = 8
staticconstexprprivate

Definition at line 95 of file RTLSDRRX.hxx.

◆ raw_accu_mutex

std::mutex SoDa::RTLSDRRX::raw_accu_mutex
private

Definition at line 112 of file RTLSDRRX.hxx.

◆ READ_BYTES

unsigned int SoDa::RTLSDRRX::READ_BYTES = 16384
staticconstexprprivate

Definition at line 94 of file RTLSDRRX.hxx.

◆ rf_buf_size

unsigned int SoDa::RTLSDRRX::rf_buf_size
private

publish chunk size (30000 samples at 625 kSPS)

Definition at line 99 of file RTLSDRRX.hxx.

◆ rs_in

std::vector<std::complex<float> > SoDa::RTLSDRRX::rs_in
private

exact-size input to resampler (rs_in_size)

Definition at line 114 of file RTLSDRRX.hxx.

◆ rs_in_size

unsigned int SoDa::RTLSDRRX::rs_in_size
private

exact resampler input size (at 2.048 MSPS)

Definition at line 97 of file RTLSDRRX.hxx.

◆ rs_out

std::vector<std::complex<float> > SoDa::RTLSDRRX::rs_out
private

resampler output (rs_out_size)

Definition at line 115 of file RTLSDRRX.hxx.

◆ rs_out_size

unsigned int SoDa::RTLSDRRX::rs_out_size
private

resampler output size (at 625 kSPS)

Definition at line 98 of file RTLSDRRX.hxx.

◆ rtl

RTLSDRDevPtr SoDa::RTLSDRRX::rtl
private

Definition at line 91 of file RTLSDRRX.hxx.

◆ rx_sample_rate

double SoDa::RTLSDRRX::rx_sample_rate
private

625 kSPS — used for IF NCO phase increment

Definition at line 101 of file RTLSDRRX.hxx.

◆ self

std::weak_ptr<RTLSDRRX> SoDa::RTLSDRRX::self
private

Definition at line 122 of file RTLSDRRX.hxx.

◆ streaming

std::atomic<bool> SoDa::RTLSDRRX::streaming {false}
private

Definition at line 103 of file RTLSDRRX.hxx.

Referenced by streamEnabled().


The documentation for this class was generated from the following file: