| RIGCTLD(1) | Hamlib Utilities | RIGCTLD(1) |
rigctld - TCP radio control daemon
rigctld |
[-hlLouV] [-m id] [-r device] [-p device] [-d device] [-P type] [-D type] [-s baud] [-c id] [-T IPADDR] [-t number] [-C parm=val] [-X seconds] [-v[-Z]] |
The rigctld program is a radio control daemon that handles client requests via TCP sockets. This allows multiple user programs to share one radio (this needs more development). Multiple radios can be controlled on different TCP ports by use of multiple rigctld processes. Note that multiple processes/ports are also necessary if some clients use extended responses and/or vfo mode. So up to 4 processes/ports may be needed for each combination of extended response/vfo mode. The syntax of the commands are the same as rigctl(1). It is hoped that rigctld will be especially useful for client authors using languages such as Perl, Python, PHP, and others.
rigctld communicates to a client through a TCP socket using text commands shared with rigctl. The protocol is simple, commands are sent to rigctld on one line and rigctld responds to get commands with the requested values, one per line, when successful, otherwise, it responds with one line “RPRT x”, where ‘x’ is a negative number indicating the error code. Commands that do not return values respond with the line “RPRT x”, where ‘x’ is ‘0’ when successful, otherwise is a regative number indicating the error code. Each line is terminated with a newline ‘\n’ character. This protocol is primarily for use by the NET rigctl (radio model 2) backend.
A separate Extended Response Protocol extends the above behavior by echoing the received command string as a header, any returned values as a key: value pair, and the “RPRT x” string as the end of response marker which includes the Hamlib success or failure value. See the PROTOCOL section for details. Consider using this protocol for clients that will interact with rigctld directly through a TCP socket.
Keep in mind that Hamlib is BETA level software. While a lot of backend libraries lack complete rotator support, the basic functions are usually well supported.
Please report bugs and provide feedback at the e-mail address given in the BUGS section below. Patches and code enhancements sent to the same address are welcome.
This program follows the usual GNU command line syntax. Short options that take an argument may have the value follow immediately or be separated by a space. Long options starting with two dashes (‘-’) require an ‘=’ between the option and any argument.
Here is a summary of the supported options:
rigctld
rigctl -m 2 rigctl -m 2 -r 127.0.0.1 rigctl -m 2 -r localhost rigctl -m 2 -r 192.168.1.1 (local IP address) rigctl -m 2 -r ::1 (on Linux rigctld doesn't listen on IPV6 by default)
rigctld -T 127.0.0.1Exceptions:
rigctl -m 2 (binds to all interfaces) rigctl -m 2 -r 127.0.0.1 (bind only to 127.0.0.1)
rigctl -m 2 -r localhost (only works if localhost is IPV4 address)
rigctld -T localhost (will set up on IPV4 or IPV6 based on localhost)Exceptions:
rigctl -m 2 rigctl -m 2 -r localhost rigctl -m 2 ip6-localhost
rigctl -m 2 -r 127.0.0.1 (only works if localhost is IPV4 address)
rigctl -m 2 -r ::1 (only works localhost is IPV6 address)
rigctld -T ip6-localhost
rigctl -m 2 -r ip6-localhost
async:True enables asynchronous data transfer for backends that support it. This allows use of transceive and spectrum data.
auto_power_on:True enables compatible rigs to be powered up on open
auto_power_off:True enables compatible rigs to be powered down on close
auto_disable_screensaver:True enables compatible rigs to have their screen saver disabled on open
dcd_type:Data Carrier Detect (or squelch) interface type override
dcd_pathname:Path name to the device file of the Data Carrier Detect (or squelch)
disable_yaesu_bandselect:True disables the automatic band select on band change for Yaesu rigs
dtr_state:ON turns on DTR, OFF turns it off, Unset disables it
lo_freq:Frequency to add to the VFO frequency for use with a transverter
post_write_delay:Delay in ms between each command sent out
ptt_share:True enables ptt port to be shared with other apps
ptt_type:Push-To-Talk interface type override
ptt_pathname:Path name to the device file of the Push-To-Talk
ptt_bitnum:Push-To-Talk GPIO bit number
retry:Max number of retry
rts_state:ON turns on DTR, OFF turns it off, Unset disables it
twiddle_timeout:For satellite ops when VFOB is twiddled will pause VFOB commands until timeout
twiddle_rit:Suppress get_freq on VFOB for RIT tuning satellites
timeout:Timeout in ms
write_delay:Delay in ms between each byte sent out
tuner_control_pathname:Path name to a script/program to control a tuner with 1 argument of 0/1 for Tuner Off/On
Note: Some options may not be implemented by a given backend and will return an error. This is most likely to occur with the --set-conf and --show-conf options.
Please note that the backend for the radio to be controlled, or the radio itself may not support some commands. In that case, the operation will fail with a Hamlib error code.
Commands can be sent over the TCP socket either as a single char, or as a long command name plus the value(s) space separated on one ‘\n’ terminated line. See PROTOCOL.
Since most of the Hamlib operations have a set and a get method, a single upper case letter will be used for set methods whereas the corresponding single lower case letter refers to the get method. Each operation also has a long name; prepend a backslash, ‘\’, to send a long command name all in lower case.
Example (Perl): “print $socket "\\dump_caps\n";” to see what the radio's backend can do (Note: In Perl and many other languages a ‘\’ will need to be escaped with a preceding ‘\’ so that even though two backslash characters appear in the code, only one will be passed to rigctld. This is a possible bug, beware!).
Note: The backend for the radio to be controlled, or the radio itself may not support some commands. In that case, the operation will fail with a Hamlib error message.
Here is a summary of the supported commands (In the case of set commands the quoted italicized string is replaced by the value in the description. In the case of get commands the quoted italicized string is the key name of the value returned.):
$ rigctl -m 229 -r /dev/rig -o
Rig command: V
VFO: VFOB
Rig command:
1 = TX/RX = ANT1
2 = TX/RX = ANT2
3 = TX/RX = ANT3
4 = TX/RX = ANT1/ANT4
5 = TX/RX = ANT2/ANT4
6 = TX/RX = ANT3/ANT4
Example from rigctld socket: b CQ CQ DE ME Yaesu example to send message#1 frm rigctld socket: b 1
Stop sending the current morse code.
Wait for morse to finish -- only works on full break-in
Have rig transmit internal message 'Msgnum'
Get 'DCD' (squelch) status: ‘0’ (Closed) or ‘1’ (Open).
Set 'Rptr Shift'.
Rptr Shift is one of: ‘+’, ‘-’, or something else for ‘None’.
Get 'Rptr Shift'.
Returns ‘+’, ‘-’, or ‘None’.
Set 'Rptr Offset', in Hz.
Get 'Rptr Offset', in Hz.
Set 'CTCSS Tone', in tenths of Hz.
Get 'CTCSS Tone', in tenths of Hz.
Set 'DCS Code'.
Get 'DCS Code'.
Set 'CTCSS Sql' tone, in tenths of Hz.
Get 'CTCSS Sql' tone, in tenths of Hz.
Set 'DCS Sql' code.
Get 'DCS Sql'
code.
Set 'Tuning Step', in Hz.
Get 'Tuning Step', in Hz.
Set 'Func' and 'Func Status'.
Func is a token: ‘FAGC’, ‘NB’, ‘COMP’, ‘VOX’, ‘TONE’, ‘TSQL’, ‘SBKIN’, ‘FBKIN’, ‘ANF’, ‘NR’, ‘AIP’, ‘APF’, ‘MON’, ‘MN’, ‘RF’, ‘ARO’, ‘LOCK’, ‘MUTE’, ‘VSC’, ‘REV’, ‘SQL’, ‘ABM’, ‘BC’, ‘MBC’, ‘RIT’, ‘AFC’, ‘SATMODE’, ‘SCOPE’, ‘RESUME’, ‘TBURST’, ‘TUNER’, ‘XIT’.
Func Status is a non null value for “activate” or “de-activate” otherwise, much as TRUE/FALSE definitions in the C language (true is non-zero and false is zero, ‘0’).
Note: Passing a ‘?’ (query) as the first argument instead of a Func token will return a space separated list of radio backend supported set function tokens. Use this to determine the supported functions of a given radio backend.
Get 'Func Status'.
Returns Func Status as a non null value for the Func token given as in set_func above.
Note: Passing a ‘?’ (query) as the first argument instead of a Func token will return a space separated list of radio backend supported get function tokens. Use this to determine the supported functions of a given radio backend.
Set 'Level' and 'Level Value'.
evel is a token: ‘PREAMP’, ‘ATT’, ‘VOXDELAY’, ‘AF’, ‘RF’, ‘SQL’, ‘IF’, ‘APF’, ‘NR’, ‘PBT_IN’, ‘PBT_OUT’, ‘CWPITCH’, ‘RFPOWER’, ‘MICGAIN’, ‘KEYSPD’, ‘NOTCHF’, ‘COMP’, ‘AGC’, ‘BKINDL’, ‘BAL’, ‘METER’, ‘VOXGAIN’, ‘ANTIVOX’, ‘SLOPE_LOW’, ‘SLOPE_HIGH’, ‘BKIN_DLYMS’, ‘RAWSTR’, ‘SWR’, ‘ALC’, ‘STRENGTH’, ‘RFPOWER_METER’, ‘COMPMETER’, ‘VD_METER’, ‘ID_METER’, ‘NOTCHF_RAW’, ‘MONITOR_GAIN’, ‘NQ’, ‘RFPOWER_METER_WATTS’, ‘SPECTRUM_MODE’, ‘SPECTRUM_SPAN’, ‘SPECTRUM_EDGE_LOW’, ‘SPECTRUM_EDGE_HIGH’, ‘SPECTRUM_SPEED’, ‘SPECTRUM_REF’, ‘SPECTRUM_AVG’, ‘SPECTRUM_ATT’, ‘TEMP_METER’, ‘BAND_SELECT’, ‘USB_AF’.
The Level Value can be a float or an integer value. For the AGC token the value is one of ‘0’ = OFF, ‘1’ = SUPERFAST, ‘2’ = FAST, ‘3’ = SLOW, ‘4’ = USER, ‘5’ = MEDIUM, ‘6’ = AUTO. Note that not all values work on all rigs. To list usable values do 'rigctl -m [modelnum] -u | grep "AGC levels"' or for Windows 'rigctl -m [modelnum] -u | find "AGC levels"'.
Note: Passing a ‘?’ (query) as the first argument instead of a Level token will return a space separated list of radio backend supported set level tokens. Use this to determine the supported levels of a given radio backend.
Get 'Level Value'.
Returns Level Value as a float or integer for the Level token given as in set_level above.
Note: Passing a ‘?’ (query) as the first argument instead of a Level token will return a space separated list of radio backend supported get level tokens. Use this to determine the supported levels of a given radio backend.
Set 'Parm' and 'Parm Value'.
Parm is a token: ‘ANN’, ‘APO’, ‘BACKLIGHT’, ‘BEEP’, ‘TIME’, ‘BAT’, ‘KEYLIGHT’, ‘BANDSELECT’, ‘KEYERTYPE’.
Note: Passing a ‘?’ (query) as the first argument instead of a Parm token will return a space separated list of radio backend supported set parameter tokens. Use this to determine the supported parameters of a given radio backend.
Get 'Parm Value'.
Returns Parm Value as a float or integer for the Parm token given as in set_parm above.
Note: Passing a ‘?’ (query) as the first argument instead of a Parm token will return a space separated list of radio backend supported get parameter tokens. Use this to determine the supported parameters of a given radio backend.
Set 'Bank'.
Sets the current memory bank number.
Set 'Memory#' channel number.
Get 'Memory#' channel number.
Perform a 'Mem/VFO Op'.
Mem/VFO Operation is a token: ‘CPY’, ‘XCHG’, ‘FROM_VFO’, ‘TO_VFO’, ‘MCL’, ‘UP’, ‘DOWN’, ‘BAND_UP’, ‘BAND_DOWN’, ‘LEFT’, ‘RIGHT’, ‘TUNE’, ‘TOGGLE’.
Note: Passing a ‘?’ (query) as the first argument instead of a Mem/VFO Op token will return a space separated list of radio backend supported Set Mem/VFO Op tokens. Use this to determine the supported Mem/VFO Ops of a given radio backend.
Perform a 'Scan Fct' on a 'Scan Channel'.
Scan Function is a token: ‘STOP’, ‘MEM’, ‘SLCT’, ‘PRIO’, ‘PROG’, ‘DELTA’, ‘VFO’, ‘PLT’.
Scan Channel is an integer (maybe?).
Note: Passing a ‘?’ (query) as the first argument instead of a Scan Fct token will return a space separated list of radio backend supported Scan Function tokens. Use this to determine the supported Scan Functions of a given radio backend.
Set memory 'Channel' data.
Not implemented yet.
Get channel memory.
If readonly!=0 then only channel data is returned and rig remains on the current channel. If readonly=0 then rig will be set to the channel requested. data.
Set 'Transceive' mode.
Transcieve is a token: ‘OFF’, ‘RIG’, ‘POLL’.
Transceive is a mechanism for radios to report events without a specific call for information.
Note: Passing a ‘?’ (query) as the first argument instead of a Transceive token will return a space separated list of radio backend supported Transceive mode tokens. Use this to determine the supported Transceive modes of a given radio backend.
Get 'Transceive' mode.
Transceive mode (reporting event) as in set_trn above.
Perform rig 'Reset'.
Reset is a value: ‘0’ = None, ‘1’ = Software reset, ‘2’ = VFO reset, ‘4’ = Memory Clear reset, ‘8’ = Master reset.
Since these values are defined as a bitmask in include/hamlib/rig.h, it should be possible to OR these values together to do multiple resets at once, if the backend supports it or supports a reset action via rig control at all.
Set 'Power Status'.
Power Status is a value: ‘0’ = Power Off, ‘1’ = Power On, ‘2’ = Power Standby.
Get 'Power Status' as in set_powerstat above.
Set DTMF 'Digits'.
Get DTMF 'Digits'.
Get misc information about the rig.
Get misc information about the rig vfos and other info.
Get misc information about a specific vfo.
Return certain state information about the radio backend.
Not a real rig remote command, it just dumps capabilities, i.e. what the backend knows about this model, and what it can do.
TODO: Ensure this is in a consistent format so it can be read into a hash, dictionary, etc. Bug reports requested.
Note: This command will produce many lines of output so be very careful if using a fixed length array! For example, running this command against the Dummy backend results in over 5kB of text output.
VFO parameter not used in 'VFO mode'.
Returns 'Power mW'.
Converts a Power value in a range of 0.0...1.0 to the real transmit power in milli-Watts (integer).
'Frequency' and 'Mode' also need to be provided as output power may vary according to these values.
VFO parameter is not used in VFO mode.
Returns 'Power [0.0..1.0]'.
Converts the real transmit power in milli-Watts (integer) to a Power value in a range of 0.0 ... 1.0.
'Frequency' and 'Mode' also need to be provided as output power may vary according to these values.
VFO parameter is not used in VFO mode.
Set 'DateTime'
Sets rig clock -- note that some rigs do not handle seconds or milliseconds.
If you try to set that you will get a debug warning message.
Format is ISO8601.
Formats accepted
YYYY-MM-DDTHH:MM:SS.sss+ZZ (where +ZZ is either -/+ UTC offset)
YYYY-MM-DDTHH:MM:SS+ZZ
YYYY-MM-DDTHH:MM+ZZ
YYYY-MM-DD (sets date only)
Can send ASCII string or 0xnn values -- there can be no spaces in the command string. Possible terminator values are CR, LF, ;, ICOM, 0-100 (bytes to read), or -1 meaning unknown (will timeout on read) Examples:
send_raw ; FA;MD;
send_raw icom 0xFE;0xFE;0x94;0x03;0xFD
send_raw -1 0xFE;0xFE;0x94;0x03;0xFD
send_raw 14 0xFE;0xFE;0x94;0x03;0xFD
Client can send its version to rigctld and get feedback on compatibility, deprecation, and alternatives
Returns hamlib version with ISO8601 date/time
Returns hamlib version with ISO8601 date/time
Performs test routines. Under development.
Sets GPIO1, GPIO2, GPIO3, GPIO4 on the GPIO ptt port Can also use 1,2,3,4
Reads GPIO1, GPIO2, GPIO3, GPIO4 on the GPIO ptt port Can also use 1,2,3,4
There are two protocols in use by rigctld, the Default Protocol and the Extended Response Protocol.
The Default Protocol is intended primarily for the communication between Hamlib library functions and rigctld (“NET rigctl”, available using radio model ‘2’).
The Extended Response Protocol is intended to be used with scripts or other programs interacting directly with rigctld as consistent feedback is provided.
The Default Protocol is intentionally simple. Commands are entered on a single line with any needed values. In practice, reliable results are obtained by terminating each command string with a newline character, ‘\n’.
Example set frequency and mode commands (Perl code (typed text shown in bold)):
print $socket "F 14250000\n"; print $socket "\\set_mode LSB 2400\n"; # escape leading '\'
A one line response will be sent as a reply to set commands, “RPRT x\n” where x is the Hamlib error code with ‘0’ indicating success of the command.
Responses from rigctld get commands are text values and match the same tokens used in the set commands. Each value is returned on its own line. On error the string “RPRT x\n” is returned where x is the Hamlib error code.
Example get frequency (Perl code):
print $socket "f\n"; "14250000\n"
Most get functions return one to three values. A notable exception is the dump_caps command which returns many lines of key:value pairs.
This protocol is primarily used by the “NET rigctl” (rigctl model 2) backend which allows applications already written for Hamlib's C API to take advantage of rigctld without the need of rewriting application code. An application's user can select rotator model 2 (“NET rigctl”) and then set rig_pathname to “localhost:4532” or other network host:port (set by the -T/-t options, respectively, above).
The Extended Response protocol adds several rules to the strings returned by rigctld and adds a rule for the command syntax.
1. The command received by rigctld is echoed with its long command name followed by the value(s) (if any) received from the client terminated by the specified response separator as the first record of the response.
2. The last record of each block is the string “RPRT x\n” where x is the numeric return value of the Hamlib backend function that was called by the command.
3. Any records consisting of data values returned by the radio backend are prepended by a string immediately followed by a colon then a space and then the value terminated by the response separator. e.g. “Frequency: 14250000\n” when the command was prepended by ‘+’.
4. All commands received will be acknowledged by rigctld
with records from rules 1 and 2. Records from rule 3 are only returned when
data values must be returned to the client.
An example response to a set_mode command sent from the shell prompt (note the prepended ‘+’):
$ echo "+M USB 2400" | nc -w 1 localhost 4532 set_mode: USB 2400 RPRT 0
In this case the long command name and values are returned on the first line and the second line contains the end of block marker and the numeric radio backend return value indicating success.
An example response to a get_mode query:
$ echo "+\get_mode" | nc -w 1 localhost 4532 get_mode: Mode: USB Passband: 2400 RPRT 0
In this case, as no value is passed to rigctld, the first line consists only of the long command name. The final line shows that the command was processed successfully by the radio backend.
Invoking the Extended Response Protocol requires prepending a command with a punctuation character. As shown in the examples above, prepending a ‘+’ character to the command results in the responses being separated by a newline character (‘\n’). Any other punctuation character recognized by the C ispunct() function except ‘\’, ‘?’, or ‘_’ will cause that character to become the response separator and the entire response will be on one line.
Separator character summary:
For example, invoking a get_mode query with a leading ‘;’ returns:
get_mode:;Mode: USB;Passband: 2400;RPRT 0
Or, using the pipe character ‘|’ returns:
get_mode:|Mode: USB|Passband: 2400|RPRT 0
And a set_mode command prepended with a ‘|’ returns:
set_mode: USB 2400|RPRT 0
Such a format will allow reading a response as a single event using a preferred response separator. Other punctuation characters have not been tested!
The following commands have been tested with the Extended Response protocol and the included testctld.pl Perl script:
The -v, --verbose option allows different levels of diagnostics to be output to stderr and correspond to -v for BUG, -vv for ERR, -vvv for WARN, -vvvv for VERBOSE, or -vvvvv for TRACE.
A given verbose level is useful for providing needed debugging information to the email address below. For example, TRACE output shows all of the values sent to and received from the radio which is very useful for radio backend library development and may be requested by the developers.
Start rigctld for a Yaesu FT-920 using a USB-to-serial adapter and backgrounding:
$ rigctld -m 1014 -r /dev/ttyUSB1 &
Start rigctld for a Yaesu FT-920 using a USB-to-serial adapter while setting baud rate and stop bits, and backgrounding:
$ rigctld -m 1014 -r /dev/ttyUSB1 -s 4800 -C stop_bits=2 &
Start rigctld for an Elecraft K3 using COM2 on MS Windows:
$ rigctld -m 2029 -r COM2
Connect to the already running rigctld and set the frequency to 14.266 MHz with a 1 second read timeout using the default protocol from the shell prompt:
$ echo "\set_freq 14266000" | nc -w 1 localhost 4532P
Connect to a running rigctld with rigctl on the local host:
$ rigctl -m2
No authentication whatsoever; DO NOT leave this TCP port open wide to the Internet. Please ask if stronger security is needed or consider using a Secure Shell (ssh(1)) tunnel.
As rigctld does not need any greater permissions than rigctl, it is advisable to not start rigctld as “root” or another system user account in order to limit any vulnerability.
The daemon is not detaching and backgrounding itself.
No method to exit the daemon so the kill(1) command must be used to terminate it.
Multiple clients using the daemon may experience contention with the connected radio.
Report bugs to:
This file is part of Hamlib, a project to develop a library that simplifies radio, rotator, and amplifier control functions for developers of software primarily of interest to radio amateurs and those interested in radio communications.
Copyright © 2000-2010 Stephane Fillod
Copyright © 2000-2018 the Hamlib Group (various contributors)
Copyright © 2011-2020 Nate Bargmann
This is free software; see the file COPYING for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Links to the Hamlib Wiki, Git repository, release archives, and daily snapshot archives are available via hamlib.org.
| 2020-09-09 | Hamlib |