![]() |
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 <USRPCtrl.hxx>
Public Member Functions | |
| uhd::usrp::multi_usrp::sptr | getUSRP () |
| return a pointer to the multi_usrp object – used by RX and TX processes to find the associated USRP widget. | |
| bool | isLOLocked (SoDa::RXTX rxtx) |
| is the identified (rx or tx) front-end LO locked? | |
| double | setLOFreq (double freq, SoDa::RXTX rxtx) |
| 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. | |
| double | getLOFreq (SoDa::RXTX rxtx) |
| Return the current LO (front end) oscillator setting for RX or TX chain. | |
| float | setRFGain (float gain, SoDa::RXTX rxtx) |
| set tain on the RX or TX side | |
| void | setSampleRate (float rate, SoDa::RXTX rxtx) |
| Set the RX or TX sample rate. | |
| float | getSampleRate (SoDa::RXTX rxtx) |
| Get the current setting for the sample rate. | |
| std::string | getHardwareDescription () |
| report the model number and any other interesting features (like freq range) to be displayed on the UI and such. | |
| bool | setClockSource (Command::ClockSource src) |
| Some radios support multiple choices for the main reference clock source. | |
| Command::ClockSource | getClockSource () |
| Some radios support multiple choices for the main reference clock source. | |
| RadioControlPtr | getSelfPtr () |
| get a pointer to myself (for things like exception handlers.) | |
| void | setTXEna (bool enable, bool full_duplex) 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 USRPCtrlPtr | make (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 | |
| USRPCtrl (ParamsPtr params) | |
| Constructor Build a USRPCtrl thread. | |
| uhd::tune_result_t | checkLock (uhd::tune_request_t &req, char sel, uhd::tune_result_t &cur) |
| is the identified (rx or tx) front-end LO locked? | |
| std::vector< std::string > | listAntennas (SoDa::RXTX rxtx) |
| report the antennas that are available. | |
| void | setAntenna (const std::string &ant, SoDa::RXTX rxtx) |
| Set the antenna choice. | |
| std::string | getAntenna (SoDa::RXTX rxtx) |
| Get the current selected antenna. | |
| 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. | |
| 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 |
| bool | is_B2xx |
| The B200 and B210 need some special handling, as they don't have frontend lock indications (as of 3.7.0) and need a special sample rate. | |
| bool | is_B210 |
| the B210 has two tx channels – use the second for a Transverter LO – see USRPLO | |
| 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< 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 | |
Private Member Functions | |
| void | initControlGPIO () |
| Initialize the GPIO control registers to set the direction and enables for the TX/RX relay output and sense input. | |
| bool | getTXEna () |
| get the state of the TXEna bit | |
| bool | getTXRelayOn () |
| get the state of the TX relay confirm bit | |
| void | locSetTXEna (bool val) |
| hardware-level TX relay and front-end control | |
| void | setTXFrontEndEnable (bool val) |
| set TX enable property on front-end module – not present in all daughtercards... | |
| void | applyTargetFreqCorrection (double target_freq, double avoid_freq, uhd::tune_request_t *tune_req) |
| applyTargetFreqCorrection adjusts the requested frequency, if necessary, to avoid a birdie caused by a multiple of the step size within the passband. | |
| void | testIntNMode (bool force_int_N, bool force_frac_N) |
| Test for support for integer-N synthesis. | |
Private Attributes | |
| uhd::usrp::multi_usrp::sptr | usrp |
| to which USRP unit is this connected? | |
| uhd::usrp::dboard_iface::sptr | dboard |
| the daughterboard we're controlling | |
| SoDa::USRPPropTree * | tx_fe_subtree |
| property tree from daughtercard module | |
| SoDa::USRPPropTree * | rx_fe_subtree |
| property tree from daughtercard module | |
| bool | tx_fe_has_enable |
| can we access tx_fe_subtree/enabled ? | |
| bool | rx_fe_has_enable |
| can we access rx_fe_subtree/enabled ? | |
| bool | tx_has_lo_locked_sensor |
| does the tx frond end have an lo_locked sensor? | |
| bool | rx_has_lo_locked_sensor |
| does the rx frond end have an lo_locked sensor? | |
| bool | supports_tx_gpio |
| does this unit support GPIO signals? (B2xx does not as of 3.7.0) | |
| uhd::tune_result_t | last_rx_tune_result |
| RX tune result – actual LO and DSP freq. | |
| uhd::tune_result_t | last_tx_tune_result |
| TX tune result. | |
| uhd::tune_result_t | saved_rx_tune_result |
| previous RX tune result – used for transverter LO "calibration" function | |
| 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 | |
| uhd::gain_range_t | rx_rf_gain_range |
| property of the device – what is the min/maximum RX gain setting? | |
| uhd::gain_range_t | tx_rf_gain_range |
| property of the device – what is the min/maximum TX gain setting? | |
| uhd::freq_range_t | rx_rf_freq_range |
| property of the device – what is the min/maximum RX frequency? | |
| uhd::freq_range_t | tx_rf_freq_range |
| property of the device – what is the min/maximum TX frequency? | |
| bool | tx_on |
| if true, we are transmitting. | |
| double | last_rx_req_freq |
| remember the last setting – useful for "calibration check" | |
| double | tx_freq |
| remember current tx freq | |
| double | tx_freq_rxmode_offset |
| when in RX mode, move tx off frequency to put the tx birdie out of band, when in TX mode, this is 0 | |
| double | tx_samp_rate |
| sample rate to USRP 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 USRP unit. | |
| bool | debug_mode |
| print stuff when we are in debug mode | |
| bool | supports_IntN_Mode |
| if true, this unit can tune the front-end LO | |
| SoDa::USRPTRControl * | tr_control |
| external control widget for TR switching and other things. | |
| std::weak_ptr< USRPCtrl > | self |
Static Private Attributes | |
| static const unsigned int | TX_RELAY_CTL |
| we use TX_IO bit 12 to turn on the TX relay we use TX_IO bit 11 to monitor the TX relay | |
| static const unsigned int | TX_RELAY_MON |
| mask for RELAY sense bit | |
| static const double | rxmode_offset |
| tx offset when in RX mode | |
Additional Inherited Members | |
| Static Public Attributes inherited from SoDa::Debug | |
| static std::mutex | debug_msg_mutex |
| 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 |
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.
USRPCtrl does that.
USRPCtrl 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.
Definition at line 74 of file USRPCtrl.hxx.
|
protected |
|
private |
applyTargetFreqCorrection adjusts the requested frequency, if necessary, to avoid a birdie caused by a multiple of the step size within the passband.
It will also adjust the stepsize.
| target_freq | – target tuning frequency |
| avoid_freq | – the frequency that we must avoid by at least 1MHz |
| tune_req | – tune request record. |
|
protected |
is the identified (rx or tx) front-end LO locked?
If not, set the tuning frequency to "the right thing"
| req | the requested frequency (and tuning discipline) |
| sel | 'r' for RX LO, 't' for TX LO |
| cur | tuning result, if the LO was locked. |
|
protectedvirtual |
Get the current selected antenna.
| rxtx | rx/tx selection |
Implements SoDa::RadioControl.
|
virtual |
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.
Reimplemented from SoDa::RadioControl.
|
virtual |
report the model number and any other interesting features (like freq range) to be displayed on the UI and such.
Implements SoDa::RadioControl.
|
virtual |
Return the current LO (front end) oscillator setting for RX or TX chain.
| rxtx | select receiver or transmitter |
Implements SoDa::RadioControl.
|
virtual |
Get the current setting for the sample rate.
| rxtx | choose RX chain or TX chain |
Implements SoDa::RadioControl.
|
inlinevirtual |
get a pointer to myself (for things like exception handlers.)
Implements SoDa::RadioControl.
Definition at line 206 of file USRPCtrl.hxx.
References self.
|
privatevirtual |
get the state of the TXEna bit
Implements SoDa::RadioControl.
|
privatevirtual |
get the state of the TX relay confirm bit
Implements SoDa::RadioControl.
|
inline |
return a pointer to the multi_usrp object – used by RX and TX processes to find the associated USRP widget.
Definition at line 93 of file USRPCtrl.hxx.
References usrp.
|
private |
Initialize the GPIO control registers to set the direction and enables for the TX/RX relay output and sense input.
|
virtual |
is the identified (rx or tx) front-end LO locked?
If not, set the tuning frequency to "the right thing"
| rxtx | RX, TX |
Implements SoDa::RadioControl.
|
protectedvirtual |
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 |
Implements SoDa::RadioControl.
|
private |
hardware-level TX relay and front-end control
| val | true to enable the transmitter, false otherwise. |
Referenced by setTXEna().
|
inlinestatic |
Definition at line 83 of file USRPCtrl.hxx.
References USRPCtrl(), and params.
|
protectedvirtual |
Set the antenna choice.
Use "ant" if it is in the list of alternatives. Otherwise, choose the first alternative.
| ant | the requested antenna |
| rxtx | select receiver or transmitter |
Implements SoDa::RadioControl.
|
virtual |
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.
| src | if src is in the sources list, set the reference source to src |
Reimplemented from SoDa::RadioControl.
|
virtual |
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.
| freq | target frequency (LO and DDS and RadioRX/TX NCO combined) |
| rxtx | select receiver or transmitter |
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 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.
|
virtual |
set tain on the RX or TX side
| gain | gain - if not in range, we'll pick something good |
| rxtx | receive or transmit? |
Implements SoDa::RadioControl.
|
virtual |
Set the RX or TX sample rate.
| rate | sample rate (in samples/sec) |
| rxtx | choose RX chain or TX chain |
Implements SoDa::RadioControl.
|
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.
| tx_on | if true, enable the TX hardware; if false, disable it. |
| full_duplex | if true, leave the RX chain active while transmitting. |
Implements SoDa::RadioControl.
Definition at line 208 of file USRPCtrl.hxx.
References locSetTXEna(), and tx_on.
|
private |
set TX enable property on front-end module – not present in all daughtercards...
| val | true to enable transmitter front end, false otherwise. |
|
private |
Test for support for integer-N synthesis.
| force_int_N | force LO tuning to use integer-N synthesis |
| force_frac_N | force LO tuning to use fractional-N synthesis |
|
private |
the daughterboard we're controlling
Definition at line 267 of file USRPCtrl.hxx.
|
private |
print stuff when we are in debug mode
Definition at line 344 of file USRPCtrl.hxx.
|
private |
timestamps are relative to the first timestamp.
Definition at line 315 of file USRPCtrl.hxx.
|
protected |
the B210 has two tx channels – use the second for a Transverter LO – see USRPLO
Definition at line 220 of file USRPCtrl.hxx.
|
protected |
The B200 and B210 need some special handling, as they don't have frontend lock indications (as of 3.7.0) and need a special sample rate.
Definition at line 219 of file USRPCtrl.hxx.
|
private |
remember the last setting – useful for "calibration check"
Definition at line 330 of file USRPCtrl.hxx.
|
private |
RX tune result – actual LO and DSP freq.
Definition at line 311 of file USRPCtrl.hxx.
|
private |
TX tune result.
Definition at line 312 of file USRPCtrl.hxx.
|
private |
The model name of the USRP unit.
Definition at line 341 of file USRPCtrl.hxx.
|
protected |
Definition at line 214 of file USRPCtrl.hxx.
Referenced by USRPCtrl(), and make().
|
private |
can we access rx_fe_subtree/enabled ?
Definition at line 276 of file USRPCtrl.hxx.
|
private |
property tree from daughtercard module
Definition at line 271 of file USRPCtrl.hxx.
|
private |
does the rx frond end have an lo_locked sensor?
Definition at line 278 of file USRPCtrl.hxx.
|
private |
property of the device – what is the min/maximum RX frequency?
Definition at line 324 of file USRPCtrl.hxx.
|
private |
rf gain for RX front end amp/attenuator
Definition at line 318 of file USRPCtrl.hxx.
|
private |
property of the device – what is the min/maximum RX gain setting?
Definition at line 321 of file USRPCtrl.hxx.
|
staticprivate |
tx offset when in RX mode
Definition at line 336 of file USRPCtrl.hxx.
|
private |
previous RX tune result – used for transverter LO "calibration" function
Definition at line 313 of file USRPCtrl.hxx.
|
private |
Definition at line 373 of file USRPCtrl.hxx.
Referenced by getSelfPtr().
|
private |
if true, this unit can tune the front-end LO
in integer-N mode (as opposed to fractional-N) to improve rejection of spurious signals and drop the noise floor a bit.
Definition at line 364 of file USRPCtrl.hxx.
|
private |
does this unit support GPIO signals? (B2xx does not as of 3.7.0)
Definition at line 282 of file USRPCtrl.hxx.
|
private |
external control widget for TR switching and other things.
A pointer to myself – useful for exceptions and such
Definition at line 370 of file USRPCtrl.hxx.
|
private |
TX antenna choice (usually has to be TX or TX/RX1?
Definition at line 339 of file USRPCtrl.hxx.
|
private |
can we access tx_fe_subtree/enabled ?
Definition at line 275 of file USRPCtrl.hxx.
|
private |
property tree from daughtercard module
Definition at line 269 of file USRPCtrl.hxx.
|
private |
remember current tx freq
Definition at line 334 of file USRPCtrl.hxx.
|
private |
when in RX mode, move tx off frequency to put the tx birdie out of band, when in TX mode, this is 0
Definition at line 335 of file USRPCtrl.hxx.
|
private |
does the tx frond end have an lo_locked sensor?
Definition at line 277 of file USRPCtrl.hxx.
|
private |
if true, we are transmitting.
Definition at line 328 of file USRPCtrl.hxx.
Referenced by setTXEna().
|
staticprivate |
we use TX_IO bit 12 to turn on the TX relay we use TX_IO bit 11 to monitor the TX relay
mask for RELAY control bit
Definition at line 308 of file USRPCtrl.hxx.
|
staticprivate |
mask for RELAY sense bit
Definition at line 309 of file USRPCtrl.hxx.
|
private |
property of the device – what is the min/maximum TX frequency?
Definition at line 325 of file USRPCtrl.hxx.
|
private |
rf gain for final TX amp
Definition at line 319 of file USRPCtrl.hxx.
|
private |
property of the device – what is the min/maximum TX gain setting?
Definition at line 322 of file USRPCtrl.hxx.
|
private |
sample rate to USRP TX chain.
Definition at line 338 of file USRPCtrl.hxx.
|
private |
to which USRP unit is this connected?
Definition at line 266 of file USRPCtrl.hxx.
Referenced by getUSRP().