SoDaRadio-5.0.3-master:8901fb5
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
SoDa::Command Class Reference

This is a list of all the commands that can "do something" to one or more components in the SoDa radio. More...

#include <Command.hxx>

Inheritance diagram for SoDa::Command:
SoDa::MBoxMessage

Public Types

enum  CmdType { SET, GET, REP, NONE }
 Commands are of the form, SET, GET, or REPort some parameter. More...
 
enum  CmdTarget {
  RX_TUNE_FREQ, RX_FE_FREQ, RX_RETUNE_FREQ, RX_LO3_FREQ,
  TX_TUNE_FREQ, TX_FE_FREQ, TX_RETUNE_FREQ, RX_SAMP_RATE,
  TX_SAMP_RATE, RX_ANT, TX_ANT, RX_RF_GAIN,
  TX_RF_GAIN, RX_AF_GAIN, RX_AF_SIDETONE_GAIN, TX_AF_GAIN,
  TX_STATE, RX_STATE, TX_BEACON, TX_CW_TEXT,
  TX_CW_SPEED, TX_CW_FLUSHTEXT, TX_CW_MARKER, TX_CW_EMPTY,
  RX_MODE, TX_MODE, RX_BW, RBW,
  SPEC_CENTER_FREQ, SPEC_RANGE_LOW, SPEC_RANGE_HI, SPEC_STEP,
  SPEC_BUF_LEN, SPEC_DIMS, SPEC_AVG_WINDOW, SPEC_UPDATE_RATE,
  CLOCK_SOURCE, LO_CHECK, LO_OFFSET, RX_AF_FILTER,
  RX_AF_FILTER_SHAPE, GPS_LATLON, GPS_UTC, GPS_LOCK,
  SDR_VERSION, DBG_REP, HWMB_REP, STOP,
  TVRT_LO_ENABLE, TVRT_LO_DISABLE, TVRT_LO_CONFIG, STATUS_MESSAGE,
  TX_AUDIO_IN, TX_AUDIO_FILT_ENA, RX_GAIN_RANGE, TX_GAIN_RANGE,
  RX_ANT_NAME, TX_ANT_NAME, MOD_SEL_ENTRY, AF_FILT_ENTRY,
  INIT_SETUP_COMPLETE, CW_CHAR_SENT, NULL_CMD
}
 Each command has a "target" state that it is meant to modify, query, or report. More...
 
enum  ModulationType {
  LSB, USB, CW_U, CW_L,
  AM, WBFM, NBFM
}
 modulation selector targets take one of these values More...
 
enum  AudioFilterBW {
  BW_100, BW_500, BW_2000, BW_6000,
  BW_PASS, BW_NULL
}
 these are the possible audio filter bandwidths More...
 
enum  UnitSelector {
  BaseBandRX, BaseBandTX, RFRX, RFTX,
  CWTX, CTRL
}
 a selector to identify a particular unit for debug reports More...
 
enum  TXAudioSelector { MIC, NOISE }
 a selector to identify the Audio TX input (MIC, NOISE...) More...
 

Public Member Functions

 Command (CmdType _ct, CmdTarget _tgt)
 Constructor for commands with no parameters. More...
 
 Command (CmdType _ct, CmdTarget _tgt, int p0, int p1=0, int p2=0, int p3=0)
 Constructor for commands with integer parameters. More...
 
 Command (CmdType _ct, CmdTarget _tgt, double p0, double p1=0.0, double p2=0.0, double p3=0.0)
 Constructor for commands with double float parameters. More...
 
 Command (CmdType _ct, CmdTarget _tgt, const std::string &_str_arg, unsigned int _tag=0)
 Constructor for commands with a string parameter. More...
 
 Command (CmdType _ct, CmdTarget _tgt, const char *cp, unsigned int _tag=0)
 Constructor for commands with a string parameter. More...
 
 Command (const Command &cc)
 Copy Constructor. More...
 
 Command ()
 Constructor – create an empty command. More...
 
 ~Command ()
 Destructor. More...
 
std::string toString () const
 return a string that displays the command More...
 
- Public Member Functions inherited from SoDa::MBoxMessage
 MBoxMessage ()
 
void setReaderCount (unsigned int rc)
 
bool readyToDie ()
 
bool decReaderCount ()
 
bool free (std::queue< MBoxMessage *> &free_list)
 
void setMBoxTag (void *tag)
 
bool checkMBoxTag (void *tag)
 

Static Public Member Functions

static CommandparseCommandString (std::string str)
 convert a string to a command More...
 
static int getMaxStringLen ()
 how long can a string parameter to a command be? More...
 
static void initTables ()
 setup maps to support parseCommandString and toString More...
 

Public Attributes

unsigned int tag
 used to pair an int with a string or other param. More...
 
union {
   int   iparms [4]
 integer parameters More...
 
   double   dparms [4]
 double float parameters More...
 
   char   sparm [64]
 a buffer holding the string More...
 
}; 
 
CmdType cmd
 the command type (SET, GET, REP) More...
 
CmdTarget target
 the thing we're touching More...
 
int id
 a sequential ID for each command – used in debugging and sequencing More...
 
char parm_type
 is this a double, int, string? More...
 

Static Public Attributes

static int command_sequence_number = 0
 sequential ID applied to each command More...
 
static bool table_needs_init = true
 if true, we need to call initTables() More...
 
static std::map< std::string, CmdTargettarget_map_s2v
 mapping for parseCommandString More...
 
static std::map< CmdTarget, std::string > target_map_v2s
 mapping for toString More...
 

Detailed Description

This is a list of all the commands that can "do something" to one or more components in the SoDa radio.

The base class defines all the command types in an enum. Each command can take up to 4 double and 4 integer parameters. (This isn't very OO, but the intent is to keep the command packet format simple, stable, and universal.)

Definition at line 47 of file Command.hxx.

Member Enumeration Documentation

◆ AudioFilterBW

these are the possible audio filter bandwidths

Enumerator
BW_100 
BW_500 
BW_2000 
BW_6000 
BW_PASS 
BW_NULL 

Definition at line 483 of file Command.hxx.

◆ CmdTarget

Each command has a "target" state that it is meant to modify, query, or report.

Enumerator
RX_TUNE_FREQ 

Set the RX front end (1st LO, the 2nd IF LO), and the 3rd LO in a more-or-less optimal way to position the requested frequency at least 80 kHz above the target frequency.

param is frequency as a double

See also
SoDa::USRPCtrl
RX_FE_FREQ 

Set the RX front end 1st LO and the 2nd IF LO.

The 1st LO is an analog synthesizer and the 2nd LO drives the digital down converter in the USRP FPGA.

param is frequency as a double

See also
SoDa::USRPCtrl SoDa::UI
RX_RETUNE_FREQ 

Tune the 3rd LO, if the current FE frequency is such that the desired frequency is between RX_FE_FREQ + 50KHz and RX_FE_FREQ + 300KHz.

Otherwise, promote this to an RX_TUNE_FREQ request.

param is frequency as a double

RX_LO3_FREQ 

Tune the 3rd LO (in SoDa::USRPRX).

param is frequency as a double

TX_TUNE_FREQ 

Set the TX front end (1st LO, the 2nd IF LO), and the 3rd LO in a more-or-less optimal way to position the requested frequency at least 80 kHz above the target frequency.

param is frequency as a double

See also
SoDa::USRPCtrl
TX_FE_FREQ 

Same effect as TX_TUNE_FREQ.

param is frequency as a double

TX_RETUNE_FREQ 

Same effect as TX_TUNE_FREQ.

param is frequency as a double

RX_SAMP_RATE 

Sample rate for RX is typically 600 KHz or better to allow a reasonable span for the waterfall and periodogram.

It also gets us reasonably far away from the high noise region near the oscillators.

param is a double

TX_SAMP_RATE 

Sample rate for TX needs to be fast enough for reasonable FM We set it to 625000 just because there doesn't seem to be much utility to go any slower.

param is a double

RX_ANT 

RX ant choices are TX/RX, and RX2.

param is a string

TX_ANT 

Not many choices for TX ant, just TX.

param is a string

RX_RF_GAIN 

Set the RX front end attenuator/amp.

gain param is a double 0.0 < gain < 40.0

TX_RF_GAIN 

Set the TX final amplifier.

gain param is a double 0.0 < gain < 100.0

RX_AF_GAIN 

RX audio gain setting.

gain param is a double actual gain factor is 10^(0.1*param - 50)

RX_AF_SIDETONE_GAIN 

RX audio gain for sidetone (CW) monitor.

gain param is a double actual gain factor is 10^(0.1*param - 50)

TX_AF_GAIN 

TX mic gain.

gain param is a double actual gain factor is 10^(0.1*param - 50)

TX_STATE 

turn transmitter on and off.

param is integer 0 disables TX, 3 enables TX

RX_STATE 

Ignored for now.

TX_BEACON 

TX Carrier Control – send a dead carrier.

param is integer – nonzero enables beacon mode.

See also
SoDa::USRPTX
TX_CW_TEXT 

TX CW text control – a buffer of up to 8 characters.

param is a string of 8 chars

See also
SoDa::CWTX
TX_CW_SPEED 

Set speed of CW generator.

param is integer in WPM

See also
SoDa::CWTX
TX_CW_FLUSHTEXT 

Flush outstanding CW text strings from pending buffer.

REP – iparam[0] is the character count for the last character dropped from the buffer.

TX_CW_MARKER 

Put a marker in the CW text stream, report its "passing".

parameter is integer tag that will be reported in a TX_CW_MARKER REP

See also
CWTX
TX_CW_EMPTY 

Report when CW TX envelope buffer was empty (cmd enables report)

no parameter

RX_MODE 

Set the modulation mode for the receive chain.

param integer – (int) conversion of SoDa::Command::ModulationType

See also
USRPRX
TX_MODE 

Set the modulation mode for the transmit chain.

param integer – (int) conversion of SoDa::Command::ModulationType

See also
USRPTX
RX_BW 

tweak the AF chain – filter settings

RBW 

tweak the waterfall display parameters like resolution bandwidth

SPEC_CENTER_FREQ 

the center frequency (command from GUI)

SPEC_RANGE_LOW 

low spectrum frequency range

SPEC_RANGE_HI 

high spectrum frequency range

SPEC_STEP 

freqency step

SPEC_BUF_LEN 

number of samples in the buffer.

SPEC_DIMS 

all spec info in one call, cf, span, and buflen

SPEC_AVG_WINDOW 

how many FFT samples contribute to a spectrum report

SPEC_UPDATE_RATE 

how many FFT samples between spectrum reports

CLOCK_SOURCE 

The master clock oscillator source Reference oscilator selector set to 1 for external, 0 for internal rep = 1 for internal lock, 0 for unlock 3 for external lock, 2 for external unlocked.

LO_CHECK 

This is an LO check command - use it for finding the actual microwave LO frequency.

if the parameter is > 0, set the rx_lo to the dparm arg, and remember that we're in LOcheck mode.

LO_OFFSET 

this is a GET/REP command – BaseBandRX takes FFT centered around 0 and reports largest peak within 50KHz.

RX_AF_FILTER 

Audio Filter.

RX_AF_FILTER_SHAPE 

Audio Filter.

GPS_LATLON 

Report LAT and LON from GPS receiver.

params are double Latitude, Longitude

forms: REP

GPS_UTC 

Report UTC (time) from GPS receiver.

params are int HH, MM, SS

forms: REP

GPS_LOCK 

Report when GPS is locked.

param is int – 0 for unlocked, 1 for locked

forms: REP

SDR_VERSION 

Report the SDR (SoDa server program) version info.

string param

forms: REP

DBG_REP 

Initiate a debug dump.

param (int) ordinal of UnitSelector

forms: GET

HWMB_REP 

Report the motherboard name (the model name of the USRP)

rep – string param

forms: GET, REP

STOP 

On receipt of a STOP command, all threads should exit their run loop.

no param

forms: SET

TVRT_LO_ENABLE 

On receipt of a TVRT_LO_ENABLE command dump a perpetual constant IF stream of (1.0, 0.0) into the tx2 channel to get a steady output.

Ignore this command unless the radio is a B210.

forms: SET

TVRT_LO_DISABLE 

On receipt of a TVRT_LO_DISABLE command, turn the LO output on TX2 off.

Ignore this command unless the radio is a B210.

no param

forms: SET

TVRT_LO_CONFIG 

On receipt of a TVRT_LO_CONFIG command , set the TX2 channel frequency to dparam[0] and the TX2 output gain to dparam[1].

Ignore this command unless the radio is a B210.

param (double) output frequency param (double) output gain setting

forms: SET, REP

STATUS_MESSAGE 

The STATUS_MESSAGE carries a payload of up to 64 characters.

These will be displayed in a log window for the GUI.

param char[64]

forms: REP

TX_AUDIO_IN 

Select the transmit chain audio input (for SSB, AM, and FM)

TX_AUDIO_FILT_ENA 

Enable the TX audio bandpass filter (limit to 2.5 kHz) for SSB/AM/FM.

RX_GAIN_RANGE 

Report min max RX Gain setting (dparm[0,1] = min, max)

TX_GAIN_RANGE 

Report min max TX Gain setting (dparm[0,1] = min, max)

RX_ANT_NAME 

Report RX antenna choice (asciiz string, uint tag)

TX_ANT_NAME 

Report TX antenna choice (asciiz string, uint tag)

MOD_SEL_ENTRY 

Report a string/name pair for modulation mode.

AF_FILT_ENTRY 

Report a string/name pair for AF filter bandwidth.

INIT_SETUP_COMPLETE 

indicate to GUI that we've sent all the initial configuration information

CW_CHAR_SENT 

send character count from start-of-time each time we send a character.

sparm[0] is the sent character, tag is count from start

NULL_CMD 

No comment.

Definition at line 58 of file Command.hxx.

◆ CmdType

Commands are of the form, SET, GET, or REPort some parameter.

Enumerator
SET 
GET 
REP 
NONE 

Definition at line 53 of file Command.hxx.

◆ ModulationType

modulation selector targets take one of these values

Enumerator
LSB 
USB 
CW_U 
CW_L 
AM 
WBFM 
NBFM 

Definition at line 478 of file Command.hxx.

◆ TXAudioSelector

a selector to identify the Audio TX input (MIC, NOISE...)

Enumerator
MIC 
NOISE 

Definition at line 493 of file Command.hxx.

◆ UnitSelector

a selector to identify a particular unit for debug reports

Enumerator
BaseBandRX 
BaseBandTX 
RFRX 
RFTX 
CWTX 
CTRL 

Definition at line 488 of file Command.hxx.

Constructor & Destructor Documentation

◆ Command() [1/7]

SoDa::Command::Command ( CmdType  _ct,
CmdTarget  _tgt 
)
inline

Constructor for commands with no parameters.

Parameters
_ctthe command type (SET, GET, REPort)
_tgtthe state that we're setting, getting, reporting

Definition at line 501 of file Command.hxx.

References cmd, command_sequence_number, parm_type, and target.

◆ Command() [2/7]

SoDa::Command::Command ( CmdType  _ct,
CmdTarget  _tgt,
int  p0,
int  p1 = 0,
int  p2 = 0,
int  p3 = 0 
)
inline

Constructor for commands with integer parameters.

Parameters
_ctthe command type (SET, GET, REPort)
_tgtthe state that we're setting, getting, reporting
p0first integer parameter
p1second integer parameter
p2third integer parameter
p3fourth integer parameter

Definition at line 519 of file Command.hxx.

References cmd, command_sequence_number, iparms, parm_type, and target.

◆ Command() [3/7]

SoDa::Command::Command ( CmdType  _ct,
CmdTarget  _tgt,
double  p0,
double  p1 = 0.0,
double  p2 = 0.0,
double  p3 = 0.0 
)
inline

Constructor for commands with double float parameters.

Parameters
_ctthe command type (SET, GET, REPort)
_tgtthe state that we're setting, getting, reporting
p0first double float parameter
p1second double float parameter
p2third double float parameter
p3fourth double float parameter

Definition at line 545 of file Command.hxx.

References cmd, command_sequence_number, dparms, parm_type, and target.

◆ Command() [4/7]

SoDa::Command::Command ( CmdType  _ct,
CmdTarget  _tgt,
const std::string &  _str_arg,
unsigned int  _tag = 0 
)
inline

Constructor for commands with a string parameter.

Parameters
_ctthe command type (SET, GET, REPort)
_tgtthe state that we're setting, getting, reporting
_str_argthe string we're passing
_tagan integer tag to associate with the string.

Definition at line 569 of file Command.hxx.

References cmd, command_sequence_number, parm_type, sparm, tag, and target.

◆ Command() [5/7]

SoDa::Command::Command ( CmdType  _ct,
CmdTarget  _tgt,
const char *  cp,
unsigned int  _tag = 0 
)
inline

Constructor for commands with a string parameter.

Parameters
_ctthe command type (SET, GET, REPort)
_tgtthe state that we're setting, getting, reporting
cpthe asciiz string we're passing
_tagan integer tag to associate with the string.

Definition at line 593 of file Command.hxx.

References cmd, command_sequence_number, parm_type, sparm, tag, and target.

◆ Command() [6/7]

SoDa::Command::Command ( const Command cc)
inline

Copy Constructor.

Parameters
ccthe command we're copying

Definition at line 613 of file Command.hxx.

References cmd, command_sequence_number, dparms, iparms, parm_type, sparm, and target.

◆ Command() [7/7]

SoDa::Command::Command ( )
inline

Constructor – create an empty command.

Definition at line 632 of file Command.hxx.

References cmd, iparms, NONE, NULL_CMD, parm_type, tag, and target.

Referenced by parseCommandString().

◆ ~Command()

SoDa::Command::~Command ( )
inline

Destructor.

Definition at line 643 of file Command.hxx.

References parseCommandString(), and toString().

Member Function Documentation

◆ getMaxStringLen()

static int SoDa::Command::getMaxStringLen ( )
inlinestatic

how long can a string parameter to a command be?

Returns
the length of the longest string command argument

Definition at line 664 of file Command.hxx.

Referenced by SoDa::CWTX::enqueueText(), and GUISoDa::Listener::sendCW().

◆ initTables()

void SoDa::Command::initTables ( )
static

◆ parseCommandString()

SoDa::Command * SoDa::Command::parseCommandString ( std::string  str)
static

convert a string to a command

Parameters
strthe string to be parsed
Returns
a pointer to a new command

Definition at line 171 of file Command.cxx.

References Command(), initTables(), SET, table_needs_init, and target_map_s2v.

Referenced by ~Command().

◆ toString()

std::string SoDa::Command::toString ( ) const

return a string that displays the command

Returns
the string

Definition at line 230 of file Command.cxx.

References cmd, dparms, GET, initTables(), iparms, parm_type, REP, SET, sparm, table_needs_init, target, and target_map_v2s.

Referenced by SoDa::USRPCtrl::execSetCommand(), SoDa::UI::run(), SoDa::TestServer::run(), and ~Command().

Member Data Documentation

◆ @1

union { ... }

◆ cmd

CmdType SoDa::Command::cmd

◆ command_sequence_number

int SoDa::Command::command_sequence_number = 0
static

sequential ID applied to each command

Definition at line 678 of file Command.hxx.

Referenced by Command().

◆ dparms

double SoDa::Command::dparms[4]

◆ id

int SoDa::Command::id

a sequential ID for each command – used in debugging and sequencing

Definition at line 675 of file Command.hxx.

◆ iparms

int SoDa::Command::iparms[4]

◆ parm_type

char SoDa::Command::parm_type

is this a double, int, string?

Definition at line 676 of file Command.hxx.

Referenced by Command(), and toString().

◆ sparm

char SoDa::Command::sparm[64]

a buffer holding the string

Definition at line 670 of file Command.hxx.

Referenced by Command(), SoDa::CWTX::execSetCommand(), SoDa::USRPCtrl::execSetCommand(), GUISoDa::Listener::handleREP(), and toString().

◆ table_needs_init

bool SoDa::Command::table_needs_init = true
static

if true, we need to call initTables()

Definition at line 680 of file Command.hxx.

Referenced by initTables(), parseCommandString(), and toString().

◆ tag

unsigned int SoDa::Command::tag

used to pair an int with a string or other param.

Definition at line 666 of file Command.hxx.

Referenced by Command(), and GUISoDa::Listener::handleREP().

◆ target

CmdTarget SoDa::Command::target

◆ target_map_s2v

std::map< std::string, SoDa::Command::CmdTarget > SoDa::Command::target_map_s2v
static

mapping for parseCommandString

Definition at line 681 of file Command.hxx.

Referenced by initTables(), and parseCommandString().

◆ target_map_v2s

std::map< SoDa::Command::CmdTarget, std::string > SoDa::Command::target_map_v2s
static

mapping for toString

Definition at line 682 of file Command.hxx.

Referenced by initTables(), and toString().


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