SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
SoDaCLI: Command-Line Interface to SoDaServer

Overview

SoDaCLI is a read-eval-print-loop (REPL) that connects to a running SoDaServer process and lets you send and receive SoDa::Command messages from the command line. It is useful for scripted testing, manual exploration of radio parameters, and regression harnesses.

SoDaCLI talks to SoDaServer over the same Unix-domain command socket that the Qt GUI uses. It can optionally launch SoDaServer itself before connecting.

All input typed at the prompt and all messages received from the server are appended to CLIHarnessLog.md in the current working directory.

Building

SoDaCLI is built automatically as part of the normal CMake build:

cmake -B build .
cmake --build build --target SoDaCLI

The resulting binary is build/TestCLI/SoDaCLI.

Usage

Run the binary with no arguments. You will see a short command summary and then the prompt:

SoDaCLI -- command line interface to SoDaServer
START [server-args] -- launch server and connect
SET <target> [I|D|S] v -- send SET (int/double/string)
GET <target> -- send GET
REP <target> [I|D|S] v -- send REP
AUDIO LIST -- list available audio devices
AUDIO OUT [device] -- connect RX audio to speaker (muted)
AUDIO VOLUME <v> -- set output volume [0.0-1.0]
AUDIO IN [device] -- connect mic audio to TX (muted)
AUDIO GAIN <g> -- set input gain multiplier
AUDIO TEST [device] -- play 440 Hz tone at 0.2 amplitude (toggle)
RUN <filename> -- execute script
QUIT -- send STOP and exit

Command verbs are case-insensitive. Command target names (e.g. RX_TUNE_FREQ) are converted to upper-case automatically, so you may type them in any case.

Blank lines and lines beginning with # are ignored, which makes script files readable.

Commands

START

START [SoDaServer arguments...]

Forks and execs SoDaServer (found via PATH) with the supplied arguments, then waits up to 30 seconds for the server's command socket file to appear, and finally connects to it.

The socket base name is extracted from the --uds_name or -S argument if present; otherwise the SoDaServer default /tmp/SoDa_ is used, giving a command socket at /tmp/SoDa__cmd.

Example — connect to a USRP at IP address 192.168.10.2:

START --radio USRP --devargs addr=192.168.10.2 --uds_name /tmp/MySoDa_

SET

SET <target> [I|D|S] <value>

Sends a SET command to SoDaServer. The target name must appear in the SoDa::Command::CmdTarget enumeration (see Command.hxx).

The optional type indicator selects the parameter encoding:

When no type indicator is given the type is inferred from the value:

  • Known enum names → integer
  • Values containing . , e , or E → double
  • Anything else parseable as an integer → integer
  • Remaining tokens → string

Examples:

SET RX_TUNE_FREQ 144215000.0
SET RX_TUNE_FREQ D 144.215e6
SET RX_MODE USB
SET RX_MODE I USB
SET TX_STATE TX_ON_1
SET TX_CW_SPEED I 20
SET TX_CW_TEXT S CQ
SET RX_RF_GAIN D 30.0

GET

GET <target>

Sends a GET request to SoDaServer. The server will typically respond with a REP message on the command socket, which SoDaCLI prints automatically (see Incoming Messages).

Example:

GET SDR_VERSION
GET HWMB_REP
GET RX_RF_GAIN

REP

REP <target> [I|D|S] <value>

Sends a REP (report) command. The syntax is identical to SET. REP is seldom needed from the CLI; it is included for completeness and for test harness use.

RUN

RUN <filename>

Opens filename and processes each line as if it were typed at the prompt. The filename argument is case-sensitive on Linux. Script execution stops immediately if a line causes an error; the file is then closed.

Incoming server messages are drained after each script line.

Example script file init.cli:

# Connect to USRP and configure initial state
START --radio USRP --uds_name /tmp/MySoDa_
SET RX_TUNE_FREQ 144215000.0
SET RX_MODE USB
SET RX_RF_GAIN D 30.0
GET SDR_VERSION

Run it with:

SoDaCLI> RUN init.cli

AUDIO

AUDIO OUT [device]
AUDIO VOLUME <v>
AUDIO IN [device]
AUDIO GAIN <g>

Controls real-time audio I/O between SoDaCLI and SoDaServer. Audio is exchanged as raw 32-bit float PCM samples at 48 000 Hz, mono, over Unix-domain sockets that SoDaServer creates alongside the command socket.

Each audio direction runs in its own Qt thread with a private event loop, so audio processing never blocks the REPL.

AUDIO LIST — print all available audio output and input devices, one per line. The system default device for each direction is marked with an asterisk. Use the device description (or a unique substring of it) as the argument to AUDIO OUT or AUDIO IN. This command does not require a server connection.

AUDIO OUT [device] — start receiving demodulated audio from SoDaServer and play it through the named output device. The initial volume is 0 (muted). Use AUDIO VOLUME to unmute. If device is omitted or "default", the system default output device is used. A substring match (case-insensitive) against the device description is performed, so "Headphones" matches "Built-in Headphones".

AUDIO VOLUME v — set playback volume to v, a linear floating-point factor in [0.0, 1.0]. This command is valid only after AUDIO OUT.

AUDIO IN [device] — start capturing microphone audio and forwarding it to SoDaServer. The initial gain is 0 (muted). Use AUDIO GAIN to unmute. Device matching follows the same rules as AUDIO OUT.

AUDIO GAIN g — set the capture gain multiplier to g. A value of 1.0 means unity gain; values above 1.0 amplify the captured samples. This command is valid only after AUDIO IN.

AUDIO TEST [device] — toggle a 440 Hz sine-wave tone at 0.2 amplitude (−14 dBFS) through the named output device. Run a second time to stop. This command does not require a server connection; it is useful for verifying that audio output is working before connecting to SoDaServer. Device matching follows the same rules as AUDIO OUT. If device is omitted, the system default output device is used.

The server's audio socket paths are derived from the socket base name in the same way as the command socket:

  • {basename}_rxa — server → CLI (receive audio, use with AUDIO OUT)
  • {basename}_txa — CLI → server (transmit audio, use with AUDIO IN)

Example:

SoDaCLI> AUDIO OUT default
Audio output: Built-in Audio Analog Stereo
SoDaCLI> AUDIO VOLUME 0.8
SoDaCLI> AUDIO IN Focusrite
Audio input: Focusrite USB Audio
SoDaCLI> AUDIO GAIN 1.0

QUIT

QUIT

Sends SET STOP to SoDaServer, waits one second for any final messages, stops any active audio threads, disconnects from the socket, then exits SoDaCLI. If SoDaServer was started with the START command, the server process is also reaped.

Incoming Messages

While waiting for user input SoDaCLI polls the command socket for inbound messages from the server. Any arriving SET, GET, or REP message is pretty-printed to stdout (using SoDa::Command::toString()) and logged:

<< REP SDR_VERSION S "SoDaRadio-2.x.y"
<< REP HWMB_REP S "B200"

After every command sent the socket is also drained, so short request-reply exchanges work naturally.

Parameter Types and Enum Names

When a target takes an integer parameter drawn from a named enumeration you may supply the symbolic name instead of the integer. The following names are recognised:

Enumeration Names
ModulationType LSB USB CW_U CW_L AM WBFM NBFM
RxTxState TX_OFF_0 TX_OFF_1 TX_OFF_2 TX_ON_0 TX_ON_1 TX_ON_2
ClockSource EXTERNAL INTERNAL
TXAudioSelector MIC NOISE

For targets not listed above, supply the raw integer value.

Command Targets

The full list of command targets is defined in SoDa::Command::CmdTarget. Commonly used targets and their expected parameter types are:

Target Type Description
RX_TUNE_FREQ double RX centre frequency (Hz)
TX_TUNE_FREQ double TX centre frequency (Hz)
RX_MODE int Modulation mode (see ModulationType)
TX_MODE int TX modulation mode
RX_RF_GAIN double RX front-end gain (dB)
TX_RF_GAIN double TX amplifier gain (dB)
RX_AF_GAIN double RX audio gain
TX_STATE int Transmit on/off state (see RxTxState)
TX_CW_SPEED int CW keyer speed (WPM)
TX_CW_TEXT string CW text to send (up to 8 chars)
CLOCK_SOURCE int Reference clock (INTERNAL or EXTERNAL)
SDR_VERSION GET only; server reports version string
HWMB_REP GET only; server reports motherboard name
STOP Shut down all server threads

Log File

SoDaCLI appends all session activity to CLIHarnessLog.md in the current working directory. Each session begins with a Markdown heading:

# SoDaCLI Session

Log entry prefixes:

  • INPUT: — a line typed by the user
  • SEND: — a command transmitted to the server
  • RECV: — a message received from the server
  • STATUS: — a connection lifecycle event
  • RUN: — a script file executed
  • ERROR: — a parse or I/O error

Example Session

SoDaCLI> START --radio USRP --devargs addr=192.168.10.2
Waiting for server socket [/tmp/SoDa__cmd]...
Connected to SoDaServer
SoDaCLI> GET SDR_VERSION
>> GET SDR_VERSION
<< REP SDR_VERSION S "SoDaRadio-2.5.0"
SoDaCLI> SET RX_TUNE_FREQ 144215000.0
>> SET RX_TUNE_FREQ D 1.44215e+08
<< REP RX_LO_FREQ D 1.44e+08
<< REP RX_IF_FREQ D 2.15e+04
SoDaCLI> SET RX_MODE USB
>> SET RX_MODE I 1
SoDaCLI> QUIT
>> SET STOP I 0