SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
RadioTX.hxx
Go to the documentation of this file.
1#pragma once
2/*
3Copyright (c) 2012,2013,2014, 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#include "SoDaBase.hxx"
30#include "SoDaThread.hxx"
31#include "Command.hxx"
32#include "Params.hxx"
34
35#include <SoDa/MailBox.hxx>
36
37#include <memory>
38
39namespace SoDa {
56 class RadioTX;
57 typedef std::shared_ptr<RadioTX> RadioTXPtr;
58
59 class RadioTX : public SoDa::Thread {
60 public:
68 RadioTX(ParamsPtr params, const std::string & name);
69
70 private:
74 void run();
75
81 virtual void subscribeToMailBoxes(const std::vector<MailBoxBasePtr> & mailboxes) final;
82
89 virtual void init() { };
90
91 protected:
92 // All hardware transmitters must implement these functions:
105 virtual bool transmitSwitch(bool tx_on) = 0;
106
107
117 virtual bool put(CBufPtr buf) = 0;
118
123 virtual void subExecCommand(CommandPtr cmd) { }
124 virtual void subExecGetCommand(CommandPtr cmd) { }
125 virtual void subExecSetCommand(CommandPtr cmd) { }
126 virtual void subExecRepCommand(CommandPtr cmd) { }
127
128 virtual RadioTXPtr getSelfPtr() = 0;
129
131
133
134 private:
150
158 void setCWFreq(bool usb, double freq);
159
168 void doCW(CBufPtr out, FBufPtr envelope);
169
170 CDatMBox::Subscription tx_subs;
171 CmdMBox::Subscription cmd_subs;
172 FDatMBox::Subscription cw_subs;
173
177
178
181
186
188
190 unsigned int tx_buffer_size;
192
194 };
195
196}
The Baseclass for all SoDa objects, and useful commonly used classes.
The Baseclass for all SoDa thread objects.
ModulationType
modulation selector targets take one of these values
Definition Command.hxx:532
sin/cos oscillator to drive TX signal chain
void doCW(CBufPtr out, FBufPtr envelope)
given a keying envelope, impose it on the CW tone
double CW_tone_freq
Definition RadioTX.hxx:179
virtual void subExecGetCommand(CommandPtr cmd)
Definition RadioTX.hxx:124
double tx_sample_rate
sample rate for buffer going to USRP (UHD)
Definition RadioTX.hxx:189
virtual RadioTXPtr getSelfPtr()=0
virtual void subExecRepCommand(CommandPtr cmd)
Definition RadioTX.hxx:126
void execSetCommand(CommandPtr cmd)
handle SET commands from the command channel
unsigned int tx_buffer_size
size of buffer going to USRP
Definition RadioTX.hxx:190
bool beacon_mode
if true, we're transmitting a steady carrier
Definition RadioTX.hxx:185
virtual void subscribeToMailBoxes(const std::vector< MailBoxBasePtr > &mailboxes) final
SoDa Threads must subscribe to at least the control mailbox.
FDatMBox::Subscription cw_subs
subscription handle for cw envelope stream (from CW unit)
Definition RadioTX.hxx:172
CDatMBoxPtr tx_stream
transmit audio stream
Definition RadioTX.hxx:174
virtual void subExecCommand(CommandPtr cmd)
Some hardware radio modules might want to watch or publish to the command mailbox.
Definition RadioTX.hxx:123
CBufPtr cw_buf
working buffer for CW output
Definition RadioTX.hxx:184
CmdMBoxPtr cmd_stream
command stream
Definition RadioTX.hxx:176
Command::ModulationType tx_modulation
current modulation mode
Definition RadioTX.hxx:187
CmdMBox::Subscription cmd_subs
subscription handle for command stream
Definition RadioTX.hxx:171
FDatMBoxPtr cw_env_stream
envelope stream from text-to-CW converter (CW unit)
Definition RadioTX.hxx:175
void execGetCommand(CommandPtr cmd)
execute GET commands from the command channel
void run()
RadioTX run loop: handle commands, and modulate the tx carrier.
virtual void subExecSetCommand(CommandPtr cmd)
Definition RadioTX.hxx:125
QuadratureOscillator CW_osc
CW tone IQ oscillator.
Definition RadioTX.hxx:180
CDatMBox::Subscription tx_subs
subscription handle for transmit audio stream (from BaseBandTX)
Definition RadioTX.hxx:170
bool waiting_to_run_dry
When set, we should send out a report when we run out of CW buffer.
Definition RadioTX.hxx:193
virtual bool put(CBufPtr buf)=0
The TX hardware unit doesn't do much at all.
virtual void init()
Some initialization must occurr after all the components are created.
Definition RadioTX.hxx:89
CBufPtr zero_buf
envelope for dead silence.
Definition RadioTX.hxx:132
FBufPtr zero_env
zero amplitude envelope
Definition RadioTX.hxx:183
void execRepCommand(CommandPtr cmd)
handle Report commands from the command channel
bool tx_enabled
if true, we're transmitting.
Definition RadioTX.hxx:130
RadioTX(ParamsPtr params, const std::string &name)
Constructor for RF Transmit/modulator process.
virtual bool transmitSwitch(bool tx_on)=0
most transmit chains will require multiple stages to enable the transmitter.
FBufPtr beacon_env
steady constant amplitude envelope
Definition RadioTX.hxx:182
float cw_env_amplitude
used to set CW output envelope, constant at 0.7
Definition RadioTX.hxx:191
void setCWFreq(bool usb, double freq)
set the CW tone frequency to generate an IQ stream
The Thread baseclass for all SoDa thread objects.
std::shared_ptr< FBuf > FBufPtr
Definition SoDaBase.hxx:61
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
std::shared_ptr< CDatMBox > CDatMBoxPtr
Definition SoDaBase.hxx:91
std::shared_ptr< CBuf > CBufPtr
Definition SoDaBase.hxx:64
std::shared_ptr< FDatMBox > FDatMBoxPtr
Definition SoDaBase.hxx:85
std::shared_ptr< RadioTX > RadioTXPtr
Definition RadioTX.hxx:57