SoDaRadio-5.0.3-master:8901fb5
Command.hxx
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012,2017 Matthew H. Reilly (kb1vc)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef COMMAND_HDR
30 #define COMMAND_HDR
31 
32 #include <string>
33 #include "MultiMBox.hxx"
34 #include <string.h>
35 
36 
37 namespace SoDa {
47  class Command : public MBoxMessage {
48  public:
53  enum CmdType { SET, GET, REP, NONE };
54 
58  enum CmdTarget {
69 
80 
90 
97 
98 
109 
116 
123 
133 
142 
155 
168 
183 
191 
202 
209 
229 
236 
243 
260 
265 
270  RBW,
271 
272  // and spectrum start/stop limits
278 
280 
283 
292 
306 
308 
310 
327 
336 
345 
354 
363 
372 
382 
392 
405 
415 
420 
425 
430 
435 
440 
445 
446 
451 
456 
461 
467 
468 
473  };
474 
479 
484 
489 
494 
502  {
503  cmd = _ct;
504  target = _tgt;
505  parm_type = ' ';
507  }
508 
520  int p0,
521  int p1 = 0,
522  int p2 = 0,
523  int p3 = 0)
524  {
525  cmd = _ct;
526  target = _tgt;
527  iparms[0] = p0;
528  iparms[1] = p1;
529  iparms[2] = p2;
530  iparms[3] = p3;
531  parm_type = 'I';
533  }
534 
546  double p0,
547  double p1 = 0.0,
548  double p2 = 0.0,
549  double p3 = 0.0)
550  {
551  cmd = _ct;
552  target = _tgt;
553  dparms[0] = p0;
554  dparms[1] = p1;
555  dparms[2] = p2;
556  dparms[3] = p3;
557  parm_type = 'D';
559  }
560 
569  Command(CmdType _ct, CmdTarget _tgt, const std::string & _str_arg, unsigned int _tag = 0)
570  {
571  cmd = _ct;
572  target = _tgt;
573  tag = _tag;
574  const char * cp = _str_arg.c_str();
575  int i;
576  for(i = 0; i < 64; i++) {
577  sparm[i] = *cp;
578  if(*cp == '\000') break;
579  cp++;
580  }
581  parm_type = 'S';
583  }
584 
593  Command(CmdType _ct, CmdTarget _tgt, const char * cp, unsigned int _tag = 0)
594  {
595  cmd = _ct;
596  target = _tgt;
597  tag = _tag;
598  int i;
599  for(i = 0; i < 64; i++) {
600  sparm[i] = *cp;
601  if(*cp == '\000') break;
602  cp++;
603  }
604  parm_type = 'S';
606  }
607 
613  Command(const Command & cc) {
614  cmd = cc.cmd;
615  target = cc.target;
616  strncpy(sparm, cc.sparm, 64);
617  dparms[0] = cc.dparms[0];
618  dparms[1] = cc.dparms[1];
619  dparms[2] = cc.dparms[2];
620  dparms[3] = cc.dparms[3];
621  iparms[0] = cc.iparms[0];
622  iparms[1] = cc.iparms[1];
623  iparms[2] = cc.iparms[2];
624  iparms[3] = cc.iparms[3];
625  id = -1 * command_sequence_number++;
626  parm_type = cc.parm_type;
627  }
628 
633  cmd = NONE;
634  target = NULL_CMD;
635  parm_type = 'I';
636  iparms[0] = 0;
637  tag = 0;
638  }
639 
644  }
645 
646 
652  static Command * parseCommandString(std::string str);
653 
658  std::string toString() const;
659 
664  static int getMaxStringLen() { return 64; }
665 
666  unsigned int tag;
667  union {
668  int iparms[4];
669  double dparms[4];
670  char sparm[64];
671  };
674 
675  int id;
676  char parm_type;
677 
679 
680  static bool table_needs_init;
681  static std::map<std::string, CmdTarget> target_map_s2v;
682  static std::map<CmdTarget, std::string> target_map_v2s;
683 
686  static void initTables();
687  };
688 }
689 
690 
691 #endif
tweak the waterfall display parameters like resolution bandwidth
Definition: Command.hxx:270
On receipt of a TVRT_LO_DISABLE command, turn the LO output on TX2 off.
Definition: Command.hxx:391
Not many choices for TX ant, just TX.
Definition: Command.hxx:154
Enable the TX audio bandpass filter (limit to 2.5 kHz) for SSB/AM/FM.
Definition: Command.hxx:424
int id
a sequential ID for each command – used in debugging and sequencing
Definition: Command.hxx:675
low spectrum frequency range
Definition: Command.hxx:274
turn transmitter on and off.
Definition: Command.hxx:197
Sample rate for RX is typically 600 KHz or better to allow a reasonable span for the waterfall and pe...
Definition: Command.hxx:132
RX audio gain setting.
Definition: Command.hxx:175
UnitSelector
a selector to identify a particular unit for debug reports
Definition: Command.hxx:488
Command()
Constructor – create an empty command.
Definition: Command.hxx:632
Sample rate for TX needs to be fast enough for reasonable FM We set it to 625000 just because there d...
Definition: Command.hxx:141
Set the TX final amplifier.
Definition: Command.hxx:167
Set the RX front end attenuator/amp.
Definition: Command.hxx:161
Set the modulation mode for the receive chain.
Definition: Command.hxx:251
TXAudioSelector
a selector to identify the Audio TX input (MIC, NOISE...)
Definition: Command.hxx:493
This is an LO check command - use it for finding the actual microwave LO frequency.
Definition: Command.hxx:299
int iparms[4]
integer parameters
Definition: Command.hxx:668
Report when GPS is locked.
Definition: Command.hxx:335
Report min max TX Gain setting (dparm[0,1] = min, max)
Definition: Command.hxx:434
Set the RX front end (1st LO, the 2nd IF LO), and the 3rd LO in a more-or-less optimal way to positio...
Definition: Command.hxx:68
Set the modulation mode for the transmit chain.
Definition: Command.hxx:259
Report when CW TX envelope buffer was empty (cmd enables report)
Definition: Command.hxx:242
Report the motherboard name (the model name of the USRP)
Definition: Command.hxx:362
Command(CmdType _ct, CmdTarget _tgt)
Constructor for commands with no parameters.
Definition: Command.hxx:501
all spec info in one call, cf, span, and buflen
Definition: Command.hxx:279
CmdType
Commands are of the form, SET, GET, or REPort some parameter.
Definition: Command.hxx:53
CmdTarget target
the thing we&#39;re touching
Definition: Command.hxx:673
Report UTC (time) from GPS receiver.
Definition: Command.hxx:326
TX Carrier Control – send a dead carrier.
Definition: Command.hxx:208
Ignored for now.
Definition: Command.hxx:201
unsigned int tag
used to pair an int with a string or other param.
Definition: Command.hxx:666
Initiate a debug dump.
Definition: Command.hxx:353
Report a string/name pair for modulation mode.
Definition: Command.hxx:450
Command(CmdType _ct, CmdTarget _tgt, const std::string &_str_arg, unsigned int _tag=0)
Constructor for commands with a string parameter.
Definition: Command.hxx:569
freqency step
Definition: Command.hxx:276
indicate to GUI that we&#39;ve sent all the initial configuration information
Definition: Command.hxx:460
Report min max RX Gain setting (dparm[0,1] = min, max)
Definition: Command.hxx:429
static int getMaxStringLen()
how long can a string parameter to a command be?
Definition: Command.hxx:664
static int command_sequence_number
sequential ID applied to each command
Definition: Command.hxx:678
Flush outstanding CW text strings from pending buffer.
Definition: Command.hxx:228
On receipt of a STOP command, all threads should exit their run loop.
Definition: Command.hxx:371
static std::map< CmdTarget, std::string > target_map_v2s
mapping for toString
Definition: Command.hxx:682
This is a list of all the commands that can "do something" to one or more components in the SoDa radi...
Definition: Command.hxx:47
how many FFT samples contribute to a spectrum report
Definition: Command.hxx:281
Same effect as TX_TUNE_FREQ.
Definition: Command.hxx:115
AudioFilterBW
these are the possible audio filter bandwidths
Definition: Command.hxx:483
char sparm[64]
a buffer holding the string
Definition: Command.hxx:670
ModulationType
modulation selector targets take one of these values
Definition: Command.hxx:478
Report LAT and LON from GPS receiver.
Definition: Command.hxx:318
the center frequency (command from GUI)
Definition: Command.hxx:273
The STATUS_MESSAGE carries a payload of up to 64 characters.
Definition: Command.hxx:414
Set the RX front end 1st LO and the 2nd IF LO.
Definition: Command.hxx:79
Report TX antenna choice (asciiz string, uint tag)
Definition: Command.hxx:444
char parm_type
is this a double, int, string?
Definition: Command.hxx:676
Command(const Command &cc)
Copy Constructor.
Definition: Command.hxx:613
TX CW text control – a buffer of up to 8 characters.
Definition: Command.hxx:215
RX ant choices are TX/RX, and RX2.
Definition: Command.hxx:148
CmdTarget
Each command has a "target" state that it is meant to modify, query, or report.
Definition: Command.hxx:58
static bool table_needs_init
if true, we need to call initTables()
Definition: Command.hxx:680
CmdType cmd
the command type (SET, GET, REP)
Definition: Command.hxx:672
double dparms[4]
double float parameters
Definition: Command.hxx:669
static std::map< std::string, CmdTarget > target_map_s2v
mapping for parseCommandString
Definition: Command.hxx:681
how many FFT samples between spectrum reports
Definition: Command.hxx:282
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.
Definition: Command.hxx:291
send character count from start-of-time each time we send a character.
Definition: Command.hxx:466
Tune the 3rd LO, if the current FE frequency is such that the desired frequency is between RX_FE_FREQ...
Definition: Command.hxx:89
Set speed of CW generator.
Definition: Command.hxx:221
Report the SDR (SoDa server program) version info.
Definition: Command.hxx:344
tweak the AF chain – filter settings
Definition: Command.hxx:264
Tune the 3rd LO (in SoDa::USRPRX).
Definition: Command.hxx:96
Set the TX front end (1st LO, the 2nd IF LO), and the 3rd LO in a more-or-less optimal way to positio...
Definition: Command.hxx:108
Command(CmdType _ct, CmdTarget _tgt, const char *cp, unsigned int _tag=0)
Constructor for commands with a string parameter.
Definition: Command.hxx:593
static Command * parseCommandString(std::string str)
convert a string to a command
Definition: Command.cxx:171
RX audio gain for sidetone (CW) monitor.
Definition: Command.hxx:182
number of samples in the buffer.
Definition: Command.hxx:277
Command(CmdType _ct, CmdTarget _tgt, int p0, int p1=0, int p2=0, int p3=0)
Constructor for commands with integer parameters.
Definition: Command.hxx:519
Report a string/name pair for AF filter bandwidth.
Definition: Command.hxx:455
Report RX antenna choice (asciiz string, uint tag)
Definition: Command.hxx:439
high spectrum frequency range
Definition: Command.hxx:275
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.
Definition: Command.hxx:545
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.
Definition: Command.hxx:381
static void initTables()
setup maps to support parseCommandString and toString
Definition: Command.cxx:39
On receipt of a TVRT_LO_CONFIG command , set the TX2 channel frequency to dparam[0] and the TX2 outpu...
Definition: Command.hxx:404
Same effect as TX_TUNE_FREQ.
Definition: Command.hxx:122
std::string toString() const
return a string that displays the command
Definition: Command.cxx:230
this is a GET/REP command – BaseBandRX takes FFT centered around 0 and reports largest peak within 5...
Definition: Command.hxx:305
~Command()
Destructor.
Definition: Command.hxx:643
Select the transmit chain audio input (for SSB, AM, and FM)
Definition: Command.hxx:419
Put a marker in the CW text stream, report its "passing".
Definition: Command.hxx:235