AMPCTLD(1)
π AMPCTLD(1) β Hamlib Utilities π
okay bestie, sit DOWN, we're talking about ampctld today and she is that girl. this is the AMPCTLD(1) page from the Hamlib Utilities manual, and by the end you're gonna understand her like she's your group chat gc. let's get into it β¨
πΈ NAME πΈ
ampctld</purl> β TCP amplifier control daemon. yes she's a daemon. yes she serves. π
β¨ SYNOPSIS β¨
ampctld [-hlLuV] [-m id] [-r device] [-s baud] [-T IPADDR] [-t number]
[-C parm=val] [-v[-Z]]
that's the whole vibe check. now let's unpack her. π
π¦ DESCRIPTION π¦
okay so ampctld is an amplifier control daemon that handles client requests via TCP sockets. that means multiple user programs can share one amplifier β which, yes, this needs more development, the manpage said it not me, we're just being honest together. π
multiple amplifiers can be controlled on different TCP ports by using multiple ampctld processes. and heads up: multiple processes/ports are also necessary if some clients use extended responses and/or vfo mode. so like, up to 4 processes/ports may be needed for each combination of extended response/vfo mode. do the math bestie, that's the deal. π
the syntax of the commands is the same as ampctl(1). and it is hoped that ampctld will be especially useful for client authors using languages such as Perl, Python, PHP, and others. no cap. π«Ά
ampctld communicates to a client through a TCP socket using text commands shared with ampctl. the protocol is simple, which we love:
- commands are sent to
ampctldon one line ampctldresponds 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' is0when successful, otherwise a negative number indicating the error code - each line is terminated with a newline
\ncharacter
this protocol is primarily for use by the NET ampctl (amplifier model 2) backend. iykyk. π
a separate Extended Response Protocol extends the above behavior by:
- echoing the received command string as a header
- returning any returned values as a
key: valuepair - and the
RPRT xstring as the end of response marker, which includes the Hamlib success or failure value
see the PROTOCOL section for details (that's coming in a later part, don't stress). consider using this protocol for clients that will interact with ampctld directly through a TCP socket. π
keep in mind that Hamlib is BETA level software. while a lot of backend libraries lack complete amplifier support, the basic functions are usually well supported. so like, she's growing, be patient with her. π±
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 β yes bestie, they want your contributions, main character energy only. π
π OPTIONS π
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's the summary of the supported options, bestie β all of them, no skips:
-m,--model=idβ select amplifier model number.- see model list (use
ampctl -l). - Note:
ampctl(or third party software using the C API) will use amplifier model 2 for NETampctl(communicating withampctld).
- see model list (use
-r,--amp-file=deviceβ use device as the file name of the port connected to the amplifier.- often a serial port, but could be a USB to serial adapter.
- typically
/dev/ttyS0,/dev/ttyS1,/dev/ttyUSB0, etc. on Linux;COM1,COM2, etc. on MS Windows. - the BSD flavors and Mac OS/X have their own designations. see your system's documentation.
-s,--serial-speed=baudβ set serial speed to baud rate.- uses maximum serial speed from amplifier backend capabilities (set by
-mabove) as the default.
- uses maximum serial speed from amplifier backend capabilities (set by
-t,--port=numberβ use number as the TCP listening port.- the default is
4531. - Note: as
rigctld's default port is4532androtctld's default port is4533, it is recommended to use DESCENDING odd numbered ports for multipleampctldinstances, e.g.4529,4527,4525, etc. π
- the default is
-T,--listen-addr=IPADDRβ use IPADDR as the listening IP address.- the default is
ANY.
- the default is
-L,--show-confβ list all config parameters for the amplifier defined with-mabove.-C,--set-conf=parm=val[,parm=val]β set amplifier configuration parameter(s), e.g.stop_bits=2.- use the
-Loption above for a list of configuration parameters for a given model number.
- use the
-u,--dump-capsβ dump capabilities for the amplifier defined with-mabove and exit.-l,--listβ list all amplifier model numbers defined in Hamlib and exit.-v,--verboseβ set verbose mode, cumulative (see DIAGNOSTICS below).-Z,--debug-time-stampsβ enable time stamps for the debug messages.- use only in combination with the
-voption as it generates no output on its own.
- use only in combination with the
-h,--helpβ show a summary of these options and exit.-V,--versionβ show version ofampctland exit.
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-confand--show-confoptions. π
Please note that the backend for the amplifier to be controlled, or the amplifier itself, may not support some commands. in that case, the operation will fail with a Hamlib error code. no shade to your amp, she's just doing her best. π
π COMMANDS π
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.
okay here's the cute part. since most of the Hamlib operations have a set and a get method:
- an UPPER CASE letter will be used for set methods
- the corresponding lower case letter refers to the get method
each operation also has a long name; prepend a backslash, \, to send a long command name. πͺ
Example (Perl): print $socket "\\dump_caps\n"; to see what the amplifier'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 toampctld. this is a possible bug, beware! π
Note: the backend for the amplifier to be controlled, or the amplifier itself, may not support some commands. in that case, the operation will fail with a Hamlib error message.
here's the 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.) π
F,set_freq'Frequency' β set 'Frequency', in Hz.- Frequency may be a floating point or integer value.
f,get_freqβ get 'Frequency', in Hz.- returns an integer value.
l,get_level'Level' β get 'Level Value'.- returns Level Value as a float or integer for the Level token given.
- Note: passing a
?(query) as the first argument instead of a Level token will return a space separated list of amplifier backend supported get level tokens. use this to determine the supported levels of a given amplifier backend. π
dump_stateβ return certain state information about the amplifier backend.1,dump_capsβ not a real amplifier 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 a number of lines of text output. π«
_,get_infoβ return information from the amplifier backend.R,reset'Reset' β perform amplifier 'Reset'.- Reset is an integer value:
0= None,1= Memory reset,2= Fault reset,3= Amplifier reset.
- Reset is an integer value:
set_powerstat'Power Status' β set 'Power Status'.- Power Status is an integer value:
0= Power Off,1= Power On,2= Power Standby (enter standby),4= Power Operate (leave standby). β‘
- Power Status is an integer value:
get_powerstatβ get 'Power Status' as inset_powerstatabove.
and that's where part 1 wraps for now, bestie β there's more coming, so don't go anywhere π
β¨ PROTOCOL β¨
okay so bestie, ampctld has two protocols in use: the Default Protocol and the Extended Response Protocol. Not me explaining both. π
The Default Protocol is intended primarily for the communication between Hamlib library functions and ampctld (βNET ampctlβ, available using amplifier model 2). It's giving internal bestie energy. π
The Extended Response Protocol is intended to be used with scripts or other programs interacting directly with ampctld as consistent feedback is provided. Consistency? Obsessed. β¨
π Default Protocol π
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. That's the vibe check.
Example set frequency and mode commands (Perl code (typed text shown in bold)):
print $socket "F 14250000\n";
print $socket "\\set_powerstat 1\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. Periodt.
Responses from ampctld 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. It's giving lore dump. π
This protocol is primarily used by the βNET ampctlβ (ampctl model 2) backend which allows applications already written for Hamlib's C API to take advantage of ampctld without the need of rewriting application code. An application's user can select amplifier model 2 (βNET ampctlβ) and then set amp_pathname to localhost:4531 or other network host:port (set by the -T/-t options, respectively, above). Slay.
π Extended Response Protocol π
The Extended Response protocol adds several rules to the strings returned by ampctld and adds a rule for the command syntax.
- The command received by
ampctldis 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. - The last record of each block is the string βRPRT x\nβ where
xis the numeric return value of the Hamlib backend function that was called by the command. - Any records consisting of data values returned by the amplifier 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
+. - All commands received will be acknowledged by
ampctldwith 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_frequency command sent from the shell prompt (note the prepended +):
$ echo "+F 14250000" | nc -w 1 localhost 4531
set_freq: 14250000
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 amplifier backend return value indicating success.
An example response to a get_freq query:
$ echo "+\get_freq" | nc -w 1 localhost 4531
get_freq:
Frequency(Hz): 14250000
RPRT 0
Note: The \ is still required for the long command name even with the ERP character. π
In this case, as no value is passed to ampctld, the first line consists only of the long command name. The final line shows that the command was processed successfully by the amplifier 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:
+β Each record of the response is appended with a newline (\n).;,|, or,,β Each record of the response is appended by the given character resulting in entire response on one line. These are common record separators for text representations of spreadsheet data, etc.?β Reserved for help inampctl._β Reserved forget_infoshort command#β Reserved for comments when reading a command file script.
Note: Other punctuation characters have not been tested! Use at your own risk. π
For example, invoking a get_freq query with a leading ; returns:
get_freq:;Frequency(Hz): 14250000;RPRT 0
Or, using the pipe character | returns:
get_freq:|Frequency(Hz): 14250000|RPRT 0
And a set_freq command prepended with a | returns:
set_freq: 14250000|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!
πΈ DIAGNOSTICS πΈ
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 amplifier which is very useful for amplifier backend library development and may be requested by the developers.
π₯ EXAMPLES π₯
Start ampctld for an Elecraft KPA-1500 using a USB-to-serial adapter and backgrounding:
$ ampctld -m 201 -r /dev/ttyUSB1 &
Start ampctld for an Elecraft KPA-1500 using COM2 on MS Windows:
$ ampctld -m 201 -r COM2
Connect to the already running ampctld 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 4531
Connect to a running ampctld with ampctl on the local host:
$ ampctl -m2
π«Ά SECURITY π«Ά
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 ampctld does not need any greater permissions than ampctl, it is advisable to not start ampctld as βrootβ or another system user account in order to limit any vulnerability. Bestie, protect your ports. π
π BUGS π
- 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 amplifier.
- Report bugs to:
- Hamlib Developer mailing list
π COPYING π
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.
β SEE ALSO β
kill(1), ampctl(1), ssh(1), hamlib(7)
π COLOPHON π
Links to the Hamlib Wiki, Git repository, release archives, and daily snapshot archives are available via hamlib.org.
That's the tea, bestie π
This page is from Hamlib, dated 2020-09-09, and it's manual page AMPCTLD(1). Stay iconic, protect your ports, and may your responses always be RPRT 0 β¨π«Ά
π¦ where this page comes from
- alpine 3.24: hamlib-doc 4.7.1-r0 Β· LGPL-2.0-or-later
- arch rolling: hamlib 4.7.2-2 Β· GPL-2.0-or-later AND LGPL-2.0-or-later
- nixos 26.05: hamlib 4.7.2
- nixpkgs unstable: hamlib 4.7.2
- opensuse-leap 16.0: hamlib 4.7.2-bp160.1.1 Β· LGPL-2.1-only
- opensuse-leap 16.0: hamlib 4.7.2-bp160.1.1 Β· LGPL-2.1-only
- opensuse-leap 16.0: hamlib 4.7.2-bp160.1.1 Β· LGPL-2.1-only
- opensuse-leap 16.0: hamlib 4.7.2-bp160.1.1 Β· LGPL-2.1-only
- ubuntu stonking: libhamlib-utils 4.7.2-2 Β· LGPL-2.1-or-later AND GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms