SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
RadioControl.hxx
Go to the documentation of this file.
1#pragma once
2/*
3Copyright (c) 2026 Matthew H. Reilly (kb1vc)
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are
8met:
9
10 Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in
14 the documentation and/or other materials provided with the
15 distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
46
47#include "SoDaBase.hxx"
48#include "SoDaThread.hxx"
49#include "Command.hxx"
50#include "Params.hxx"
51#include <SoDa/MailBox.hxx>
52
53namespace SoDa {
54 class RadioControl;
55 typedef std::shared_ptr<RadioControl> RadioControlPtr;
56
69 class RadioControl : public SoDa::Thread {
70 public:
78 RadioControl(ParamsPtr params, const std::string & name);
79
86 void run() final;
87
91 virtual void init() { }
92
94 void subscribeToMailBoxes(const std::vector<MailBoxBasePtr> & mailboxes);
95
97
98 protected:
108 virtual void execCommand(CommandPtr cmd) final;
109
118 virtual void execGetCommand(CommandPtr cmd) final;
119
128 void execSetCommand(CommandPtr cmd) final;
129
138 void execRepCommand(CommandPtr cmd) final;
139
142 double getTime();
143
144
145 private:
146 // These are the command handlers. They call virtual methods provided
147 // by specific radio modules. They can't be over-ridden.
153 virtual void reportAntennas() final;
154
155
163 bool isLocked(SoDa::RXTX rxtx);
164
167 void auxRun() { }
171
172
173 protected:
175
181 virtual bool isLOLocked(SoDa::RXTX rxtx) = 0;
182
192 virtual std::vector<std::string> listAntennas(SoDa::RXTX rxtx) = 0;
193
200 virtual void setAntenna(const std::string & ant, SoDa::RXTX rxtx) = 0;
201
208 virtual std::string getAntenna(SoDa::RXTX rxtx) = 0;
209
216 virtual void setSampleRate(float rate, SoDa::RXTX rxtx) = 0;
217
224 virtual float getSampleRate(SoDa::RXTX rxtx) = 0;
225
242 virtual float setRFGain(float gain, SoDa::RXTX rxtx) = 0;
243
276 virtual double setLOFreq(double freq, SoDa::RXTX rxtx) = 0;
277
278
284 virtual double getLOFreq(SoDa::RXTX rxtx) = 0;
285
338 void setFreq(double freq, SoDa::RXTX rxtx);
339
342 virtual bool getTXEna() = 0;
345 virtual bool getTXRelayOn() = 0;
346
355 virtual void setTXEna(bool tx_on, bool full_duplex) = 0;
356
358
395 void setTXRXMode(Command::RxTxState rxtxst, bool full_duplex);
396
411
412
423
430 virtual std::string getHardwareDescription() = 0;
431
432
433 protected:
434
446 double findGoodRXLO(double freq, double cur_lo_freq);
447
449 CmdMBox::Subscription cmd_subs;
450
452
453 // gain settings
454 double rx_rf_gain;
455 double tx_rf_gain;
456
457 // state of the box
458 bool tx_on;
459
464
465 static const double tx_freq_rxmode_offset;
466
468 std::string tx_ant;
469
470 std::string motherboard_name;
471
472 // transverter local oscillator support.
478
479 // enables verbose messages
481 };
482}
483
The Baseclass for all SoDa objects, and useful commonly used classes.
The Baseclass for all SoDa thread objects.
RxTxState
Transmit/Receive state changes go through stages.
Definition Command.hxx:79
ClockSource
some radios support two sources for the master oscillator reference.
Definition Command.hxx:71
Though libuhd is designed to be re-entrant, there are some indications that all control functions (se...
double cur_rx_if_freq
difference between rx
double tvrt_lo_gain
output power for the second transmit channel (used for transverter LO)
virtual void setSampleRate(float rate, SoDa::RXTX rxtx)=0
Set the RX or TX sample rate.
double tvrt_lo_fe_freq
the frequency of the second transmit channel front-end oscillator
double rx_rf_gain
rf gain for RX front end amp/attenuator
virtual double getLOFreq(SoDa::RXTX rxtx)=0
Return the current LO (front end) oscillator setting for RX or TX chain.
virtual bool setClockSource(Command::ClockSource src)
Some radios support multiple choices for the main reference clock source.
void auxRun()
Methods that a radio MAY implement (see above)
double tx_samp_rate
sample rate to TX chain.
virtual bool getTXRelayOn()=0
get the state of the TX relay confirm bit
virtual RadioControlPtr getSelfPtr()=0
virtual double setLOFreq(double freq, SoDa::RXTX rxtx)=0
double getTime()
get the number of seconds since the "Epoch"
virtual float setRFGain(float gain, SoDa::RXTX rxtx)=0
set tain on the RX or TX side
void execRepCommand(CommandPtr cmd) final
Parse an incoming REPort command and dispatch.
void setTXRXMode(Command::RxTxState rxtxst, bool full_duplex)
Initiate the actions that will turn on the transmitter and (optionally) disable the receiver.
virtual std::string getHardwareDescription()=0
report the model number and any other interesting features (like freq range) to be displayed on the U...
double cur_rx_lo_freq
The current receiver LO frequency.
double tx_rf_gain
rf gain for final TX amp
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 conven...
std::string tx_ant
TX antenna choice (usually has to be TX or TX/RX1?
void run() final
start the thread
void subExecSetCommand(CommandPtr cmd)
void subscribeToMailBoxes(const std::vector< MailBoxBasePtr > &mailboxes)
implement the subscription method
virtual Command::ClockSource getClockSource()
Some radios support multiple choices for the main reference clock source.
static const double tx_freq_rxmode_offset
tx offset when in RX mode
bool tvrt_lo_mode
if true, set the transmit frequency, with some knowledge of the tvrt LO.
CmdMBoxPtr cmd_stream
command stream channel
bool tx_on
if true, we are transmitting.
virtual void setTXEna(bool tx_on, bool full_duplex)=0
Enable or disable the transmit hardware chain, including the antenna relay and PA enable.
virtual std::string getAntenna(SoDa::RXTX rxtx)=0
Get the current selected antenna.
void subExecGetCommand(CommandPtr cmd)
void execSetCommand(CommandPtr cmd) final
Parse an incoming SET command and dispatch.
virtual bool getTXEna()=0
get the state of the TXEna bit
double cur_tx_lo_freq
The current requested transmitter LO frequency.
virtual bool isLOLocked(SoDa::RXTX rxtx)=0
Methods that ALL radios must implement.
void setFreq(double freq, SoDa::RXTX rxtx)
Set the recieve or transmit frequency to 'freq' This includes setting the PLL front end synthesizer,...
RadioControl(ParamsPtr params, const std::string &name)
Constructor Build a RadioControl thread.
CmdMBox::Subscription cmd_subs
subscriber ID for this thread's connection to the command channel
double tvrt_lo_freq
the frequency of the second transmit channel oscillator
virtual float getSampleRate(SoDa::RXTX rxtx)=0
Get the current setting for the sample rate.
virtual std::vector< std::string > listAntennas(SoDa::RXTX rxtx)=0
report the antennas that are available.
virtual void execGetCommand(CommandPtr cmd) final
Parse an incoming GET command and dispatch.
bool isLocked(SoDa::RXTX rxtx)
checked state of front-end LO and back-end IF chain NCO.
virtual void execCommand(CommandPtr cmd) final
Parse an incoming command and dispatch.
virtual void init()
perform initialization.
bool tvrt_lo_capable
if true, this unit can implement a local transverter oscillator.
double cur_tx_if_freq
the TX LO frequency reported by the RadioTX front end.
std::string motherboard_name
The model name of the radio.
void subExecRepCommand(CommandPtr cmd)
bool debug_mode
print stuff when we are in debug mode
virtual void reportAntennas() final
write all antenna names to the report message channel Get these from the listAntennas call.
virtual void setAntenna(const std::string &ant, SoDa::RXTX rxtx)=0
Set the antenna choice.
double first_gettime
timestamps are relative to the first timestamp.
The Thread baseclass for all SoDa thread objects.
std::shared_ptr< RadioControl > RadioControlPtr
RXTX
We often need to distinguis between the RX and TX device.
Definition SoDaBase.hxx:69
std::shared_ptr< Params > ParamsPtr
Definition Params.hxx:42
std::shared_ptr< Command > CommandPtr
Definition Command.hxx:41
std::shared_ptr< CmdMBox > CmdMBoxPtr
Definition SoDaBase.hxx:79