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

#include <RTLSDRCtrl.hxx>

Inheritance diagram for SoDa::RTLSDRCtrl:
SoDa::RadioControl SoDa::Thread SoDa::Base SoDa::Debug

Public Member Functions

 ~RTLSDRCtrl ()=default
RadioControlPtr getSelfPtr () override
bool isLOLocked (SoDa::RXTX rxtx) override
 Methods that ALL radios must implement.
double setLOFreq (double freq, SoDa::RXTX rxtx) override
double getLOFreq (SoDa::RXTX rxtx) override
 Return the current LO (front end) oscillator setting for RX or TX chain.
float setRFGain (float gain, SoDa::RXTX rxtx) override
 set tain on the RX or TX side
void setSampleRate (float rate, SoDa::RXTX rxtx) override
 Set the RX or TX sample rate.
float getSampleRate (SoDa::RXTX rxtx) override
 Get the current setting for the sample rate.
std::string getHardwareDescription () override
 report the model number and any other interesting features (like freq range) to be displayed on the UI and such.
std::vector< std::string > listAntennas (SoDa::RXTX rxtx) override
 report the antennas that are available.
void setAntenna (const std::string &ant, SoDa::RXTX rxtx) override
 Set the antenna choice.
std::string getAntenna (SoDa::RXTX rxtx) override
 Get the current selected antenna.
bool getTXEna () override
 get the state of the TXEna bit
bool getTXRelayOn () override
 get the state of the TX relay confirm bit
void setTXEna (bool, bool) override
 Enable or disable the transmit hardware chain, including the antenna relay and PA enable.
Public Member Functions inherited from SoDa::RadioControl
 RadioControl (ParamsPtr params, const std::string &name)
 Constructor Build a RadioControl thread.
void run () final
 start the thread
virtual void init ()
 perform initialization.
void subscribeToMailBoxes (const std::vector< MailBoxBasePtr > &mailboxes)
 implement the subscription method
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 RTLSDRCtrlPtr 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

 RTLSDRCtrl (RTLSDRDevPtr dev_in, ParamsPtr params)
Protected Member Functions inherited from SoDa::RadioControl
virtual void execCommand (CommandPtr cmd) final
 Parse an incoming command and dispatch.
virtual void execGetCommand (CommandPtr cmd) final
 Parse an incoming GET command and dispatch.
void execSetCommand (CommandPtr cmd) final
 Parse an incoming SET command and dispatch.
void execRepCommand (CommandPtr cmd) final
 Parse an incoming REPort command and dispatch.
double getTime ()
 get the number of seconds since the "Epoch"
void setFreq (double freq, SoDa::RXTX rxtx)
 Set the recieve or transmit frequency to 'freq' This includes setting the PLL front end synthesizer, the FPGA resident digital synthesizer (if it exists) and the RX baseband or TX baseband oscillator.
void setTXRXMode (Command::RxTxState rxtxst, bool full_duplex)
 Initiate the actions that will turn on the transmitter and (optionally) disable the receiver.
virtual bool setClockSource (Command::ClockSource src)
 Some radios support multiple choices for the main reference clock source.
virtual Command::ClockSource getClockSource ()
 Some radios support multiple choices for the main reference clock source.
double findGoodRXLO (double freq, double cur_lo_freq)
 see setFreq - this is a helper to find a good LO frequency that puts the IF in a range that is convenient for the spectrum display.
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

int sodaGainToRTL (float soda_gain) const
 Map SoDaRadio gain (-30..0 dB) to the nearest discrete RTL gain step.

Private Attributes

RTLSDRDevPtr rtl
double rx_lo_freq
 last RX center frequency written (Hz)
float rx_sample_rate
 current sample rate (Hz)
std::vector< int > gain_steps
 valid tuner gains in tenths of dB
std::string hw_description
std::weak_ptr< RTLSDRCtrlself

Static Private Attributes

static constexpr float HW_RATE = 2048000.0f
 RTL2832U actual USB delivery rate (2.048 MSPS)

Additional Inherited Members

Static Public Attributes inherited from SoDa::Debug
static std::mutex debug_msg_mutex
Protected Attributes inherited from SoDa::RadioControl
ParamsPtr params
CmdMBoxPtr cmd_stream
 command stream channel
CmdMBox::Subscription cmd_subs
 subscriber ID for this thread's connection to the command channel
double first_gettime
 timestamps are relative to the first timestamp.
double rx_rf_gain
 rf gain for RX front end amp/attenuator
double tx_rf_gain
 rf gain for final TX amp
bool tx_on
 if true, we are transmitting.
double cur_rx_lo_freq
 The current receiver LO frequency.
double cur_rx_if_freq
 difference between rx
double cur_tx_lo_freq
 The current requested transmitter LO frequency.
double cur_tx_if_freq
 the TX LO frequency reported by the RadioTX front end.
double tx_samp_rate
 sample rate to TX chain.
std::string tx_ant
 TX antenna choice (usually has to be TX or TX/RX1?
std::string motherboard_name
 The model name of the radio.
bool tvrt_lo_capable
 if true, this unit can implement a local transverter oscillator.
bool tvrt_lo_mode
 if true, set the transmit frequency, with some knowledge of the tvrt LO.
double tvrt_lo_gain
 output power for the second transmit channel (used for transverter LO)
double tvrt_lo_freq
 the frequency of the second transmit channel oscillator
double tvrt_lo_fe_freq
 the frequency of the second transmit channel front-end oscillator
bool debug_mode
 print stuff when we are in debug mode
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::RadioControl
static const double tx_freq_rxmode_offset
 tx offset when in RX mode
Static Protected Attributes inherited from SoDa::Debug
static unsigned int default_debug_level
static unsigned int global_debug_level

Detailed Description

Definition at line 57 of file RTLSDRCtrl.hxx.

Constructor & Destructor Documentation

◆ RTLSDRCtrl()

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

References SoDa::RadioControl::params.

Referenced by make().

◆ ~RTLSDRCtrl()

SoDa::RTLSDRCtrl::~RTLSDRCtrl ( )
default

Member Function Documentation

◆ getAntenna()

std::string SoDa::RTLSDRCtrl::getAntenna ( SoDa::RXTX rxtx)
overridevirtual

Get the current selected antenna.

Parameters
rxtxrx/tx selection
Returns
a string corresponding to the chosen antenna. It will be in the list returned by listAntennas.

Implements SoDa::RadioControl.

◆ getHardwareDescription()

std::string SoDa::RTLSDRCtrl::getHardwareDescription ( )
overridevirtual

report the model number and any other interesting features (like freq range) to be displayed on the UI and such.

Returns
a string describing the hardware.

Implements SoDa::RadioControl.

◆ getLOFreq()

double SoDa::RTLSDRCtrl::getLOFreq ( SoDa::RXTX rxtx)
overridevirtual

Return the current LO (front end) oscillator setting for RX or TX chain.

Parameters
rxtxselect receiver or transmitter
Returns
frequency (Analog LO and DDS/FPGA)

Implements SoDa::RadioControl.

◆ getSampleRate()

float SoDa::RTLSDRCtrl::getSampleRate ( SoDa::RXTX rxtx)
overridevirtual

Get the current setting for the sample rate.

Parameters
rxtxchoose RX chain or TX chain
Returns
the sample rate (samples/sec)

Implements SoDa::RadioControl.

◆ getSelfPtr()

RadioControlPtr SoDa::RTLSDRCtrl::getSelfPtr ( )
inlineoverridevirtual

Implements SoDa::RadioControl.

Definition at line 71 of file RTLSDRCtrl.hxx.

References self.

◆ getTXEna()

bool SoDa::RTLSDRCtrl::getTXEna ( )
inlineoverridevirtual

get the state of the TXEna bit

Returns
true if the TX relay is activated.

Implements SoDa::RadioControl.

Definition at line 94 of file RTLSDRCtrl.hxx.

◆ getTXRelayOn()

bool SoDa::RTLSDRCtrl::getTXRelayOn ( )
inlineoverridevirtual

get the state of the TX relay confirm bit

Returns
true if the TX relay sense input is asserted

Implements SoDa::RadioControl.

Definition at line 95 of file RTLSDRCtrl.hxx.

◆ isLOLocked()

bool SoDa::RTLSDRCtrl::isLOLocked ( SoDa::RXTX rxtx)
overridevirtual

Methods that ALL radios must implement.

is the identified (rx or tx) front-end LO locked? If not, set the tuning frequency to "the right thing"

Parameters
rxtxRX, TX

Implements SoDa::RadioControl.

◆ listAntennas()

std::vector< std::string > SoDa::RTLSDRCtrl::listAntennas ( SoDa::RXTX rxtx)
overridevirtual

report the antennas that are available.

we'll use this to let the GUI know what the choices are.

Parameters
rxtxselect which port RX, or TX
Returns
list of antennas for rx/tx This will later be used in the RadioControl initialization command sequence from "reportModes"

Implements SoDa::RadioControl.

◆ make()

RTLSDRCtrlPtr SoDa::RTLSDRCtrl::make ( RTLSDRDevPtr dev_in,
ParamsPtr params )
inlinestatic

Definition at line 64 of file RTLSDRCtrl.hxx.

References RTLSDRCtrl(), and SoDa::RadioControl::params.

◆ setAntenna()

void SoDa::RTLSDRCtrl::setAntenna ( const std::string & ant,
SoDa::RXTX rxtx )
overridevirtual

Set the antenna choice.

Use "ant" if it is in the list of alternatives. Otherwise, choose the first alternative.

Parameters
antthe requested antenna
rxtxrx/tx selection

Implements SoDa::RadioControl.

◆ setLOFreq()

double SoDa::RTLSDRCtrl::setLOFreq ( double freq,
SoDa::RXTX rxtx )
overridevirtual
   @brief Set the front-end (LO + DDS) frequency to 'freq'
   This includes setting the PLL front end synthesizer
   as well as the FPGA resident digital synthesizer.

   @param freq targeto frequency (analog LO and DDS in the FPGA)
   @param rxtx select receiver or transmitter

   @return The actual LO frequency.

   The actual LO frequency may differ from the requested frequency by a small
   margin. Some radios may have a tuning step that is more than a few Hz. In this
   case we adjust the LO in the RX and TX objects. (This may be a bigger deal for the
   TX object as we like to do all the modulation there at baseband and assume the
   hardware takes care of the carrier frequency. 

   Typically, the call for a receive request would look like this:

   actual_lo_freq = setLOFreq(144.215e6, SoDa::RX)

   If the target LO can tune in 20 kHz intervals, the actual LO would be 144.100e6 and
   the if_freq would be 115e3 Hz. This would allow a "clean" window from 144.115 Mhz to

g * 144.325 MHz in the spectrogram display. The LO would need to be changed if the next frequency was greater than 144.240 or less than 144.205 (I think)

On the transmit side, the offset may be dictated by the frequency stepping increment in the front-end LO.

To keep everything civilized, setLOFreq should never be called by any other agent than the RadioControl object. (Not even its sub-classes.)

Implements SoDa::RadioControl.

◆ setRFGain()

float SoDa::RTLSDRCtrl::setRFGain ( float gain,
SoDa::RXTX rxtx )
overridevirtual

set tain on the RX or TX side

The radio implementation is responsible for mapping the gain to the appropriate control settings.

The range for gain is -30 to 0 in dB. 0 is maximum power or maximum front end RX gain. The device may support a more limited range, say -15 to 0 dB. In this case, any gain value less than -15 is treated as -15. For devices that support a greater range, the supported range is still -30 to 0.

Parameters
gaingain - if not in range, we'll pick something good
rxtxreceive or transmit?
Returns
the actual gain setting

Implements SoDa::RadioControl.

◆ setSampleRate()

void SoDa::RTLSDRCtrl::setSampleRate ( float rate,
SoDa::RXTX rxtx )
overridevirtual

Set the RX or TX sample rate.

Parameters
ratesample rate (in samples/sec)
rxtxchoose RX chain or TX chain

Implements SoDa::RadioControl.

◆ setTXEna()

void SoDa::RTLSDRCtrl::setTXEna ( bool tx_on,
bool full_duplex )
inlineoverridevirtual

Enable or disable the transmit hardware chain, including the antenna relay and PA enable.

In half-duplex mode the RX chain should also be muted.

Parameters
tx_onif true, enable the TX hardware; if false, disable it.
full_duplexif true, leave the RX chain active while transmitting.

Implements SoDa::RadioControl.

Definition at line 96 of file RTLSDRCtrl.hxx.

◆ sodaGainToRTL()

int SoDa::RTLSDRCtrl::sodaGainToRTL ( float soda_gain) const
private

Map SoDaRadio gain (-30..0 dB) to the nearest discrete RTL gain step.

Member Data Documentation

◆ gain_steps

std::vector<int> SoDa::RTLSDRCtrl::gain_steps
private

valid tuner gains in tenths of dB

Definition at line 106 of file RTLSDRCtrl.hxx.

◆ hw_description

std::string SoDa::RTLSDRCtrl::hw_description
private

Definition at line 107 of file RTLSDRCtrl.hxx.

◆ HW_RATE

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

RTL2832U actual USB delivery rate (2.048 MSPS)

Definition at line 99 of file RTLSDRCtrl.hxx.

◆ rtl

RTLSDRDevPtr SoDa::RTLSDRCtrl::rtl
private

Definition at line 101 of file RTLSDRCtrl.hxx.

◆ rx_lo_freq

double SoDa::RTLSDRCtrl::rx_lo_freq
private

last RX center frequency written (Hz)

Definition at line 103 of file RTLSDRCtrl.hxx.

◆ rx_sample_rate

float SoDa::RTLSDRCtrl::rx_sample_rate
private

current sample rate (Hz)

Definition at line 104 of file RTLSDRCtrl.hxx.

◆ self

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

Definition at line 109 of file RTLSDRCtrl.hxx.

Referenced by getSelfPtr().


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