![]() |
SoDaRadio-12.2.0-cut_dependencies:6c82803
|
Though libuhd is designed to be re-entrant, there are some indications that all control functions (set_freq, gain, and other operations) should originate from a single thread. More...
#include <RadioControl.hxx>
Public Member Functions | |
| 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 | |
| virtual RadioControlPtr | getSelfPtr ()=0 |
| 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 () |
Protected Member Functions | |
| 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" | |
| virtual bool | isLOLocked (SoDa::RXTX rxtx)=0 |
| Methods that ALL radios must implement. | |
| virtual std::vector< std::string > | listAntennas (SoDa::RXTX rxtx)=0 |
| report the antennas that are available. | |
| virtual void | setAntenna (const std::string &ant, SoDa::RXTX rxtx)=0 |
| Set the antenna choice. | |
| virtual std::string | getAntenna (SoDa::RXTX rxtx)=0 |
| Get the current selected antenna. | |
| virtual void | setSampleRate (float rate, SoDa::RXTX rxtx)=0 |
| Set the RX or TX sample rate. | |
| virtual float | getSampleRate (SoDa::RXTX rxtx)=0 |
| Get the current setting for the sample rate. | |
| virtual float | setRFGain (float gain, SoDa::RXTX rxtx)=0 |
| set tain on the RX or TX side | |
| virtual double | setLOFreq (double freq, SoDa::RXTX rxtx)=0 |
| virtual double | getLOFreq (SoDa::RXTX rxtx)=0 |
| Return the current LO (front end) oscillator setting for RX or TX chain. | |
| 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. | |
| virtual bool | getTXEna ()=0 |
| get the state of the TXEna bit | |
| virtual bool | getTXRelayOn ()=0 |
| get the state of the TX relay confirm bit | |
| virtual void | setTXEna (bool tx_on, bool full_duplex)=0 |
| Enable or disable the transmit hardware chain, including the antenna relay and PA enable. | |
| 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. | |
| virtual std::string | getHardwareDescription ()=0 |
| report the model number and any other interesting features (like freq range) to be displayed on the UI and such. | |
| 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 () |
Protected Attributes | |
| 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< Thread > | self |
| 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 | |
| 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 |
Private Member Functions | |
| virtual void | reportAntennas () final |
| write all antenna names to the report message channel Get these from the listAntennas call. | |
| bool | isLocked (SoDa::RXTX rxtx) |
| checked state of front-end LO and back-end IF chain NCO. | |
| void | auxRun () |
| Methods that a radio MAY implement (see above) | |
| void | subExecGetCommand (CommandPtr cmd) |
| void | subExecSetCommand (CommandPtr cmd) |
| void | subExecRepCommand (CommandPtr cmd) |
Additional Inherited Members | |
| 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 () |
| Static Public Attributes inherited from SoDa::Debug | |
| static std::mutex | debug_msg_mutex |
Though libuhd is designed to be re-entrant, there are some indications that all control functions (set_freq, gain, and other operations) should originate from a single thread.
RadioRX listens on the Command Stream message channel for requests from other components (including the SoDa::UI listener) and dumps status and completion reports back onto the command stream channel.
RadioControl does that.
RadioControl listens on the Command Stream message channel for requests from other components (including the SoDa::UI listener) and dumps status and completion reports back onto the command stream channel.
A Receiver does no processing to the incoming RF signal other than
Definition at line 69 of file RadioControl.hxx.
| SoDa::RadioControl::RadioControl | ( | ParamsPtr | params, |
| const std::string & | name ) |
Constructor Build a RadioControl thread.
| params | Pointer to a parameter object with all the initial settings |
| name | the name given to the thread. and identification for the attached radio |
References params.
|
inlineprivate |
Methods that a radio MAY implement (see above)
Definition at line 167 of file RadioControl.hxx.
References auxRun().
Referenced by auxRun().
|
finalprotectedvirtual |
Parse an incoming command and dispatch.
If a subclass needs to handle any command type, it should declare its own subExecCommand method.
| cmd | a command record |
|
finalprotectedvirtual |
Parse an incoming GET command and dispatch.
If a subclass needs to handle any command type, it should declare its own subExecCommand method.
| cmd | a command record |
Reimplemented from SoDa::Thread.
|
finalprotectedvirtual |
Parse an incoming REPort command and dispatch.
If a subclass needs to handle any command type, it should declare its own subExecRepCommand method.
| cmd | a command record |
Reimplemented from SoDa::Thread.
|
finalprotectedvirtual |
Parse an incoming SET command and dispatch.
If a subclass needs to handle any command type, it should declare its own subExecSetCommand method.
| cmd | a command record |
Reimplemented from SoDa::Thread.
|
protected |
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.
| freq | desired final frequency |
| cur_lo_freq | the last LO frequency sent to the front-end. |
freq is within the "good window" of cur_lo_freq. Otherwise, return a good LO freq that puts freq in the good window.
|
protectedpure virtual |
Get the current selected antenna.
| rxtx | rx/tx selection |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedvirtual |
Some radios support multiple choices for the main reference clock source.
As an example, the USRP N200 can lock its master clock to an external 10 MHz reference or to an internal TCXO.
There is a default implementation of this method that returns "Internal"
Reimplemented in SoDa::USRPCtrl.
|
protectedpure virtual |
report the model number and any other interesting features (like freq range) to be displayed on the UI and such.
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedpure virtual |
Return the current LO (front end) oscillator setting for RX or TX chain.
| rxtx | select receiver or transmitter |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedpure virtual |
Get the current setting for the sample rate.
| rxtx | choose RX chain or TX chain |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
pure virtual |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protected |
get the number of seconds since the "Epoch"
|
protectedpure virtual |
get the state of the TXEna bit
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedpure virtual |
get the state of the TX relay confirm bit
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
inlinevirtual |
perform initialization.
Not all modules need to implement this.
Reimplemented in SoDa::PlutoCtrl.
Definition at line 91 of file RadioControl.hxx.
References init().
Referenced by init().
|
private |
checked state of front-end LO and back-end IF chain NCO.
| rxtx | which is it? RX or TX |
References isLocked().
Referenced by isLocked().
|
protectedpure virtual |
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"
| rxtx | RX, TX |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedpure virtual |
report the antennas that are available.
we'll use this to let the GUI know what the choices are.
| rxtx | select which port RX, or TX |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
finalprivatevirtual |
write all antenna names to the report message channel Get these from the listAntennas call.
|
finalvirtual |
start the thread
If a subclass needs to perform its own work, it should declare an auxRun method.
Reimplemented from SoDa::Thread.
|
protectedpure virtual |
Set the antenna choice.
Use "ant" if it is in the list of alternatives. Otherwise, choose the first alternative.
| ant | the requested antenna |
| rxtx | rx/tx selection |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedvirtual |
Some radios support multiple choices for the main reference clock source.
As an example, the USRP N200 can lock its master clock to an external 10 MHz reference or to an internal TCXO.
This method chooses that reference source.
There is a default implementation of this method that returns "Internal"
| src | if src is in the sources list, set the reference source to src |
Reimplemented in SoDa::USRPCtrl.
|
protected |
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.
| freq | target frequency |
| rxtx | select receiver or transmitter |
This calls the actual radio control object's setLOFreq method.
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.
The RX LO frequency differs from the requested frequency to move the DC spike in the IF spectrum away from the requested frequency. setFreq ensures the requested frequency (freq) is at least 100 kHz above the LO frequency and no more than 200 kHz above the LO frequency. (This is less about the RF sample rate and more about keeping a nice window around the tuned frequency so the periodogram or waterfall display is helpful. )
So we now have the concept of an IF frequency. The IF frequency is the difference between the LO frequency and the requested frequency. We assume that the TX chain will always have an IF frequency of 0 Hz. The RX chain will have an IF frequency of freq - setLOFreq()
In both cases, setFreq will send a SET, RX_IF_OSC or SET, TX_IF_OSC command to the RX or TX threads. The RX or TX thread must send back REP, xx_IF_OSC with the setting that it accepted. RadioControl will not report LO locked until both the hardware device reports that it is locked and the REP, xx_IF_OSC message has returned.
Typically, the call for a receive request would look like this:
if_freq = setFreq(144.215e6, SoDa::RX, 0)
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 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, setFreq should never be called by any other agent than the RadioControl object. (Not even its sub-classes.)
|
protectedpure virtual |
@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.)
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedpure virtual |
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.
| gain | gain - if not in range, we'll pick something good |
| rxtx | receive or transmit? |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedpure virtual |
Set the RX or TX sample rate.
| rate | sample rate (in samples/sec) |
| rxtx | choose RX chain or TX chain |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
|
protectedpure virtual |
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.
| tx_on | if true, enable the TX hardware; if false, disable it. |
| full_duplex | if true, leave the RX chain active while transmitting. |
Implemented in SoDa::PlutoCtrl, SoDa::RTLSDRCtrl, and SoDa::USRPCtrl.
References tx_on.
|
protected |
Initiate the actions that will turn on the transmitter and (optionally) disable the receiver.
Or enable the receiver and turn off the transmitter.
This is a multistep process and looks like this:
To turn TX ON. (RadioControl receives TX_STATE TX_ON_0, full_duplex_flag (Entries marked with X are performed by RadioControl, others must be implemented in the model controller's setTXRXMode function.
On receiving a SET TX_STATE TX_ON_1 CW_TX turns itself on. All other TX_xxx values turn off CW_TX
On receiving TX_ON_1 BaseBandTX turns on the audio input stream (unless we're in cw mode)
On receiving a SET TX_STATE TX_ON_1 BaseBandRX flushes all its buffers unless in full duplex turn on the sidetone stream, if appropriate
To turn TX OFF and RX ON (RadioControl receives TX_STATE TX_OFF_0, full_duplex_flag)
| rxtxst | RXTX (TX on/off) state - one of TX_ON_0, TX_ON_1, TX_OFF_0, TX_OFF_1 |
| full_duplex | if true, leave RX on while transmitter is enabled. |
|
inlineprivate |
Definition at line 168 of file RadioControl.hxx.
|
inlineprivate |
Definition at line 170 of file RadioControl.hxx.
|
inlineprivate |
Definition at line 169 of file RadioControl.hxx.
|
virtual |
implement the subscription method
Implements SoDa::Thread.
|
protected |
command stream channel
Definition at line 448 of file RadioControl.hxx.
|
protected |
subscriber ID for this thread's connection to the command channel
Definition at line 449 of file RadioControl.hxx.
|
protected |
difference between rx
Definition at line 461 of file RadioControl.hxx.
|
protected |
The current receiver LO frequency.
Definition at line 460 of file RadioControl.hxx.
|
protected |
the TX LO frequency reported by the RadioTX front end.
Definition at line 463 of file RadioControl.hxx.
|
protected |
The current requested transmitter LO frequency.
Definition at line 462 of file RadioControl.hxx.
|
protected |
print stuff when we are in debug mode
Definition at line 480 of file RadioControl.hxx.
|
protected |
timestamps are relative to the first timestamp.
Definition at line 451 of file RadioControl.hxx.
|
protected |
The model name of the radio.
Definition at line 470 of file RadioControl.hxx.
|
protected |
Definition at line 99 of file RadioControl.hxx.
Referenced by SoDa::PlutoCtrl::PlutoCtrl(), RadioControl(), SoDa::RTLSDRCtrl::RTLSDRCtrl(), SoDa::PlutoCtrl::make(), and SoDa::RTLSDRCtrl::make().
|
protected |
rf gain for RX front end amp/attenuator
Definition at line 454 of file RadioControl.hxx.
|
protected |
if true, this unit can implement a local transverter oscillator.
Definition at line 473 of file RadioControl.hxx.
|
protected |
the frequency of the second transmit channel front-end oscillator
Definition at line 477 of file RadioControl.hxx.
|
protected |
the frequency of the second transmit channel oscillator
Definition at line 476 of file RadioControl.hxx.
|
protected |
output power for the second transmit channel (used for transverter LO)
Definition at line 475 of file RadioControl.hxx.
|
protected |
if true, set the transmit frequency, with some knowledge of the tvrt LO.
Definition at line 474 of file RadioControl.hxx.
|
protected |
TX antenna choice (usually has to be TX or TX/RX1?
Definition at line 468 of file RadioControl.hxx.
|
staticprotected |
tx offset when in RX mode
Definition at line 465 of file RadioControl.hxx.
|
protected |
if true, we are transmitting.
Definition at line 458 of file RadioControl.hxx.
Referenced by setTXEna().
|
protected |
rf gain for final TX amp
Definition at line 455 of file RadioControl.hxx.
|
protected |
sample rate to TX chain.
Definition at line 467 of file RadioControl.hxx.