Removed -b|--block option in favor of using '+' prepended to a command

from the client to request Extended Response protocol.



git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2827 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.11
Nate Bargmann, N0NB 2010-02-08 23:37:07 +00:00
rodzic 18c31c61ad
commit 14841cf118
4 zmienionych plików z 133 dodań i 119 usunięć

Wyświetl plik

@ -2,26 +2,26 @@
* rigctl.c - (C) Stephane Fillod 2000-2009
*
* This program test/control a radio using Hamlib.
* It takes commands in interactive mode as well as
* It takes commands in interactive mode as well as
* from command line options.
*
* $Id: rigctl.c,v 1.70 2009-01-04 14:49:17 fillods Exp $
* $Id: rigctl.c,v 1.70 2009-01-04 14:49:17 fillods Exp $
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*/
#ifdef HAVE_CONFIG_H
@ -53,7 +53,7 @@ void usage(void);
/*
* Reminder: when adding long options,
* Reminder: when adding long options,
* keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks.
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
@ -86,7 +86,7 @@ static struct option long_options[] =
int interactive = 1; /* if no cmd on command line, switch to interactive */
int prompt = 1; /* Print prompt in rigctl */
int opt_end= 0; /* only used by rigctld */
int opt_block = 0; /* only used by rigctld */
//int opt_block = 0; /* only used by rigctld */
int vfo_mode; /* vfo_mode=0 means target VFO is current VFO */
char send_cmd_term = '\r'; /* send_cmd termination char */
@ -251,7 +251,7 @@ int main (int argc, char *argv[])
"<hamlib-developer@lists.sourceforge.net>\n\n");
/*
* at least one command on command line,
* at least one command on command line,
* disable interactive mode
*/
if (optind < argc)
@ -260,7 +260,7 @@ int main (int argc, char *argv[])
my_rig = rig_init(my_model);
if (!my_rig) {
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
my_model);
fprintf(stderr, "Please check with --list option.\n");
exit(2);
@ -275,7 +275,7 @@ int main (int argc, char *argv[])
if (rig_file)
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN);
/*
/*
* ex: RIG_PTT_PARALLEL and /dev/parport0
*/
if (ptt_type != RIG_PTT_NONE)
@ -318,7 +318,7 @@ int main (int argc, char *argv[])
if (verbose > 0)
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
my_rig->caps->model_name);
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
do {

Wyświetl plik

@ -152,7 +152,6 @@ declare_proto_rig(set_powerstat);
declare_proto_rig(get_powerstat);
declare_proto_rig(send_dtmf);
declare_proto_rig(recv_dtmf);
declare_proto_rig(chk_blk);
declare_proto_rig(chk_vfo);
@ -229,8 +228,7 @@ static struct test_table test_list[] = {
{ '1', "dump_caps", dump_caps, ARG_NOVFO },
{ '3', "dump_conf", dump_conf, ARG_NOVFO },
{ 0x8f,"dump_state", dump_state, ARG_OUT|ARG_NOVFO },
{ 0xf0,"chk_blk", chk_blk, ARG_NOVFO }, /* rigctld only--check for block protocol */
{ 0xf1,"chk_vfo", chk_vfo, ARG_NOVFO }, /* rigctld only--check for VFO mode */
{ 0xf0,"chk_vfo", chk_vfo, ARG_NOVFO }, /* rigctld only--check for VFO mode */
{ 0x00, "", NULL },
};
@ -283,9 +281,9 @@ static int scanfc(FILE *fin, const char *format, void *p)
extern int interactive;
extern int prompt;
extern int opt_end;
extern int opt_block;
extern int vfo_mode;
extern char send_cmd_term;
int ext_resp = 0;
int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
{
@ -307,6 +305,16 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
if (scanfc(fin, "%c", &cmd) < 0)
return -1;
/* Extended response protocol requested with leading '+' on command
* string--rigctld only! */
if (cmd == '+' && !prompt) {
ext_resp = 1;
if (scanfc(fin, "%c", &cmd) < 0)
return -1;
} else if (cmd == '+' && prompt) {
return 0;
}
/* command by name */
if (cmd == '\\') {
unsigned char cmd_name[MAXNAMSIZ], *pcmd = cmd_name;
@ -466,23 +474,25 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
#endif
if (!prompt)
rig_debug(RIG_DEBUG_TRACE, "rigctl(d): %c '%s' '%s' '%s'\n",
cmd, p1, p2, p3);
rig_debug(RIG_DEBUG_TRACE, "rigctl(d): %c '0x%02x' '%s' '%s' '%s'\n",
cmd, vfo, p1, p2, p3);
/*
* Block protocol: output received command name and arguments response
* Don't send response on '\chk_blk' command
* Extended Response protocol: output received command name and arguments
* response. Don't send command header on '\chk_vfo' command.
*/
if (interactive && opt_block && (cmd != 0xf0 && cmd != 0xf1)) {
char a1[MAXARGSZ+1];
char a2[MAXARGSZ+1];
char a3[MAXARGSZ+1];
if (interactive && ext_resp && cmd != 0xf0) {
char a1[MAXARGSZ + 1];
char a2[MAXARGSZ + 1];
char a3[MAXARGSZ + 1];
char vfo_str[MAXARGSZ + 1];
p1 == NULL ? a1[0] = '\0' : snprintf(a1, sizeof(a1), " %s", p1);
vfo_mode == 0 ? vfo_str[0] = '\0' : snprintf(vfo_str, sizeof(vfo_str), " %s", rig_strvfo(vfo));
p1 == NULL ? a1[0] = '\0' : snprintf(a1, sizeof(a1), " %s", p1);
p2 == NULL ? a2[0] = '\0' : snprintf(a2, sizeof(a2), " %s", p2);
p3 == NULL ? a3[0] = '\0' : snprintf(a3, sizeof(a3), " %s", p3);
fprintf(fout, "%s:%s%s%s\n", cmd_entry->name, a1, a2, a3);
fprintf(fout, "%s:%s%s%s%s\n", cmd_entry->name, vfo_str, a1, a2, a3);
}
retcode = (*cmd_entry->rig_routine)(my_rig, fout, interactive,
@ -494,21 +504,28 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
if (retcode != RIG_OK) {
if ((interactive && !prompt && opt_block) || (interactive && !prompt))
fprintf(fout, NETRIGCTL_RET "%d\n", retcode); /* only for rigctld */
/* only for rigctld */
if ((interactive && !prompt && ext_resp) || (interactive && !prompt)) {
fprintf(fout, NETRIGCTL_RET "%d\n", retcode);
ext_resp = 0;
}
else
fprintf(fout, "%s: error = %s\n", cmd_entry->name, rigerror(retcode));
} else {
// rig_debug(RIG_DEBUG_TRACE, "rigctld: %d %s\n", cmd, cmd_entry->name);
if (interactive && !prompt) { /* only for rigctld */
/* only for rigctld */
if (interactive && !prompt) {
/* netrigctl RIG_OK */
if (!(cmd_entry->flags & ARG_OUT)
&& !opt_end && !opt_block && (cmd != 0xf0 && cmd != 0xf1)) /* netrigctl RIG_OK */
&& !opt_end && !ext_resp && cmd != 0xf0)
fprintf(fout, NETRIGCTL_RET "0\n");
else if ((cmd_entry->flags & ARG_OUT) && opt_end) /* Nate's protocol */
/* block marker protocol */
else if (ext_resp && cmd != 0xf0) {
fprintf(fout, NETRIGCTL_RET "0\n");
ext_resp = 0;
}
/* Nate's protocol (obsolete) */
else if ((cmd_entry->flags & ARG_OUT) && opt_end)
fprintf(fout, "END\n");
else if (opt_block && (cmd != 0xf0 && cmd != 0xf1)) /* block marker protocol */
fprintf(fout, NETRIGCTL_RET "0\n");
}
}
@ -658,7 +675,7 @@ declare_proto_rig(get_freq)
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1); /* i.e. "Frequency" */
fprintf(fout, "%"PRIll"\n", (long long)freq);
@ -683,7 +700,7 @@ declare_proto_rig(get_rit)
status = rig_get_rit(rig, vfo, &rit);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%ld\n", rit);
@ -708,7 +725,7 @@ declare_proto_rig(get_xit)
status = rig_get_xit(rig, vfo, &xit);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%ld\n", xit);
@ -744,10 +761,10 @@ declare_proto_rig(get_mode)
status = rig_get_mode(rig, vfo, &mode, &width);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%s\n", rig_strrmode(mode));
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg2);
fprintf(fout, "%ld\n", width);
@ -768,7 +785,7 @@ declare_proto_rig(get_vfo)
status = rig_get_vfo(rig, &vfo);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%s\n", rig_strvfo(vfo));
@ -793,7 +810,7 @@ declare_proto_rig(get_ptt)
status = rig_get_ptt(rig, vfo, &ptt);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", ptt);
@ -809,7 +826,7 @@ declare_proto_rig(get_dcd)
status = rig_get_dcd(rig, vfo, &dcd);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", dcd);
@ -834,7 +851,7 @@ declare_proto_rig(get_rptr_shift)
status = rig_get_rptr_shift(rig, vfo, &rptr_shift);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%s\n", rig_strptrshift(rptr_shift));
@ -859,7 +876,7 @@ declare_proto_rig(get_rptr_offs)
status = rig_get_rptr_offs(rig, vfo, &rptr_offs);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%ld\n", rptr_offs);
@ -884,7 +901,7 @@ declare_proto_rig(get_ctcss_tone)
status = rig_get_ctcss_tone(rig, vfo, &tone);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", tone);
@ -909,7 +926,7 @@ declare_proto_rig(get_dcs_code)
status = rig_get_dcs_code(rig, vfo, &code);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", code);
@ -934,7 +951,7 @@ declare_proto_rig(get_ctcss_sql)
status = rig_get_ctcss_sql(rig, vfo, &tone);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", tone);
@ -959,7 +976,7 @@ declare_proto_rig(get_dcs_sql)
status = rig_get_dcs_sql(rig, vfo, &code);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", code);
@ -986,7 +1003,7 @@ declare_proto_rig(get_split_freq)
status = rig_get_split_freq(rig, txvfo, &txfreq);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%"PRIll"\n", (long long)txfreq);
@ -1024,10 +1041,10 @@ declare_proto_rig(get_split_mode)
status = rig_get_split_mode(rig, txvfo, &mode, &width);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%s\n", rig_strrmode(mode));
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg2);
fprintf(fout, "%ld\n", width);
@ -1053,10 +1070,10 @@ declare_proto_rig(get_split_vfo)
status = rig_get_split_vfo(rig, vfo, &split, &tx_vfo);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", split);
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg2);
fprintf(fout, "%s\n", rig_strvfo(tx_vfo));
@ -1081,7 +1098,7 @@ declare_proto_rig(get_ts)
status = rig_get_ts(rig, vfo, &ts);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%ld\n", ts);
@ -1104,7 +1121,7 @@ declare_proto_rig(power2mW)
status = rig_power2mW(rig, &mwp, power, freq, mode);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg4);
fprintf(fout, "%i\n", mwp);
@ -1127,7 +1144,7 @@ declare_proto_rig(mW2power)
status = rig_mW2power(rig, &power, mwp, freq, mode);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg4);
fprintf(fout, "%f\n", power);
@ -1436,7 +1453,7 @@ declare_proto_rig(get_mem)
status = rig_get_mem(rig, vfo, &ch);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", ch);
@ -1722,7 +1739,7 @@ declare_proto_rig(get_trn)
status = rig_get_trn(rig, &trn);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", trn);
@ -1735,7 +1752,7 @@ declare_proto_rig(get_info)
const char *s;
s = rig_get_info(rig);
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%s\n", s ? s : "None");
@ -1923,7 +1940,7 @@ declare_proto_rig(get_ant)
status = rig_get_ant(rig, vfo, &ant);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", rig_setting2idx(ant));
@ -1985,7 +2002,7 @@ declare_proto_rig(get_powerstat)
status = rig_get_powerstat(rig, &stat);
if (status != RIG_OK)
return status;
if ((interactive && prompt) || (interactive && !prompt && opt_block))
if ((interactive && prompt) || (interactive && !prompt && ext_resp))
fprintf(fout, "%s: ", cmd->arg1);
fprintf(fout, "%d\n", stat);
@ -2077,14 +2094,6 @@ declare_proto_rig(send_cmd)
return retval;
}
/* '0xf0'--test if rigctld called with -b|--block option */
declare_proto_rig(chk_blk)
{
fprintf(fout, "CHKBLK %d\n", opt_block);
return RIG_OK;
}
/* '0xf1'--test if rigctld called with -o|--vfo option */
declare_proto_rig(chk_vfo)
{

Wyświetl plik

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH RIGCTLD "8" "February 3, 2010" "Hamlib" "Rig Control Daemon"
.TH RIGCTLD "8" "February 8, 2010" "Hamlib" "Rig Control Daemon"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -16,23 +16,24 @@
.\" .sp <n> insert n+1 empty lines
.\" for manpage-specific macros, see man(7)
.SH NAME
rigctld \- Hamlib rig control daemon
rigctld \- Hamlib TCP rig control daemon
.SH SYNOPSIS
.B rigctld
[\fIOPTION\fR]...
.SH DESCRIPTION
The \fBrigctld\fP program is an EXPERIMENTAL \fBHamlib\fP rig control daemon
that handles TCP client requests. This allows multiple user programs to share
one radio. Multiple radios can be controlled on different TCP ports by use of
multiple \fBrigctld\fP processes. The syntax of the commands are the same as
\fBrigctl\fP. It is hoped that \fBrigctld\fP will be especially useful for
languages such as Perl, Python, PHP, and others.
The \fBrigctld\fP program is a NEW \fBHamlib\fP rig control daemon ready for testing
that handles client requests via TCP sockets. This allows multiple user programs to
share one radio (this needs testing). Multiple radios can be controlled
on different TCP ports by use of multiple \fBrigctld\fP processes. The syntax of the
commands are the same as \fBrigctl\fP. It is hoped that \fBrigctld\fP will be
especially useful for client authors using languages such as Perl, Python, PHP,
and others.
.PP
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
.\" \fI<whatever>\fP escape sequences to invoke bold face and italics,
.\" respectively.
\fBrigctld\fP communicates to a client through a TCP socket using text
commands shared with \fBrigctl\fP. The protocol is simple, commands are sent
commands shared with \fBrigctl\fP. The protocol is simple; commands are sent
to \fBrigctld\fP on one line and \fBrigctld\fP responds to "get" commands with
the requested values, one per line, when successful, otherwise, it responds
with one line "RPTR x", where x is a negative number indicating the error code.
@ -40,24 +41,22 @@ Commands that do not return values respond with the line "RPTR x", where x
is zero when successful, otherwise is a regative number indicating the error code.
Each line is terminated with a newline '\\n' character.
.PP
A separate \fBblock\fP protocol (-b, or --block option) extends the above
A separate \fBExtended Response\fP protocol extends the above
behavior by echoing the received command string as a header, any returned values
as a key: value pair, and the "RPTR x" string as the end of block marker which
as a key: value pair, and the "RPTR x" string as the end of response marker which
includes the \fBHamlib\fP success or failure value. See the \fIPROTOCOL\fP
section for details.
.PP
Keep in mind that \fBHamlib\fP is BETA level software.
While a lot of backend libraries lack complete rig support, the basic functions
are usually well supported. The API may change without publicized notice,
while an advancement of the minor version (e.g. 1.1.x to 1.2.x) indicates such
a change.
are usually well supported.
.PP
Please report bugs and provide feedback at the e-mail address given in the
REPORTING BUGS section. Patches and code enhancements are also welcome.
\fIREPORTING BUGS\fP section. Patches and code enhancements are also welcome.
.SH OPTIONS
This program follows the usual GNU command line syntax, with long
options starting with two dashes ('-').
.PP
Here is a summary of the supported options:
.TP
.B \-m, --model=id
@ -92,7 +91,7 @@ backend capabilities (set by -m above) as the default.
Use \fIid\fP as the CI-V address to communicate with the rig. Only useful for
Icom rigs.
.br
N.B.: The \fIid\fP is in decimal notation, unless prefixed by
\fBN.B.\fP: The \fIid\fP is in decimal notation, unless prefixed by
\fI0x\fP for a hexadecimal value.
.TP
.B \-T, --listen-addr=IPADDR
@ -100,6 +99,9 @@ Use \fIIPADDR\fP as the listening IP address. The default is ANY.
.TP
.B \-t, --port=number
Use \fInumber\fP as the TCP listening port. The default is 4532.
.br
\fBN.B.\fP: As \fBrotctld\fP's default port is 4533, it is advisable to use even
numbered ports for \fBrigctld\fP, e.g. 4532, 4534, 4536, etc.
.TP
.B \-C, --set-conf=parm=val[,parm=val]*
Set config parameter. e.g. --set-conf=stop_bits=2
@ -121,14 +123,12 @@ command (except \fI\\set_vfo\fP!). Otherwise, 'currVFO' is assumed when this
option is not set and an extra VFO argument is not used. See \fI\\chk_vfo\fP
below.
.TP
.B \-b, --block
Use the block rigctld protocol. See \fI\\chk_blk\fP below. \fIEXPERIMENTAL\fP
.TP
.B \-e, --end-marker
Use END marker in rigctld protocol.
.br
N.B.: This option can be considered obsolete. Please consider using the block
protocol instead (see \fIPROTOCOL\fP below).
\fBN.B.\fP: This option can be considered obsolete. Please consider using the Extended
Response protocol instead (see \fIPROTOCOL\fP below). This option will be removed
in a future Hamlib release.
.TP
.B \-v, --verbose
Set verbose mode, cumulative (see \fIDIAGNOSTICS\fP below).
@ -157,10 +157,12 @@ corresponding lower case letter refers to the \fIget\fP method. Each operation
also has a long name, prepend a backslash to send a long command name.
.PP
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
backend can do
.br
(\fBN.B.\fP: 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 \fBrigctld\fP. This is a
possible bug!).
possible bug, beware!).
.PP
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
@ -404,6 +406,10 @@ 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.
.br
\fBN.B.\fP: This command will produce many lines of output so be very careful
if using a fixed length array! For example, running this command against these
Dummy backend results in over 5kB of text output.
.br
VFO parameter not used in 'VFO mode'.
.TP
.B 2, power2mW 'Power [0.0..1.0]' 'Frequency' 'Mode'
@ -430,16 +436,11 @@ Send raw command string to rig.
For binary protocols enter values as \\0xAA\\0xBB. Expect a 'Reply' from the
rig which will likely be a binary block or an ASCII string.
.TP
.B chk_blk
Returns "CHKBLK 1\\n" (single line only) if \fBrigctld\fP was invoked with the
\fI-b\fP or \fI--block\fP option, "CHKBLK 0\\n" if not.
.br
.TP
.B chk_vfo
Returns "CHKVFO 1\\n" (single line only) if \fBrigctld\fP was invoked with the
\fI-o\fP or \fI--vfo\fP option, "CHKVFO 0\\n" if not.
.br
When in VFO mode client will need to pass 'VFO' as the first parameter to
When in VFO mode the client will need to pass 'VFO' as the first parameter to
\fI\\set\fP or \fI\\get\fP commands. 'VFO' is one of the strings defined
for \fI\\set_vfo\fP above.
.br
@ -471,15 +472,17 @@ the \fI\\dump_caps\fP function which returns many lines of key:value pairs.
Future work will focus on making this output compatible with assignment to a
hash, dictionary, or other key:value variable.
.PP
\fBBlock Protocol\fP
\fBExtended Response Protocol\fP
.br
An \fIEXPERIMENTAL\fP Block protocol has been introduced into \fBrigctld\fP
as of January 24, 2010. This protocol adds several rules to the strings
returned by \fBrigctld\fP.
An \fIEXPERIMENTAL\fP Extended Response protocol has been introduced into
\fBrigctld\fP as of February 8, 2010. This protocol is invoked by prepending
a '+' character immediately ahead of the command string with no intervening
space. Also, several rules are added to the strings returned by \fBrigctld\fP.
.PP
1. The command received by \fBrigctld\fP is echoed with its long command name
followed by the value(s) received from the client terminated by a newline
as the first line of the block.
as the first line of the block. The leading '+' and '\\' characters are not
included in the echoed command string.
.PP
2. The last line of each block is the string "RPTR \fIx\fP\\n" wheren \fIx\fP is
the numeric return value of the Hamlib backend function that was called by the
@ -495,6 +498,8 @@ returned to the client.
.PP
An example response to a \fI\\set_mode\fP command:
.br
$ echo "+F USB 2400" | nc -w 1 localhost 4532
.br
set_mode: USB 2400
.br
RPRT 0
@ -505,9 +510,11 @@ return value indicating success.
.PP
An example response to a \fI\\get_mode\fP query:
.br
$ echo "+\\get_mode" | nc -w 1 localhost 4532
.br
get_mode:
.br
Mode: CW
Mode: USB
.br
Passband: 2400
.br
@ -517,8 +524,8 @@ In this case, as no value is passed to \fBrigctld\fP, the first line consists
only of the long command name. The final line shows that the command was
processed successfully by the rig backend.
.PP
The following commands have been tested with the Block protocol and the included
\fBtestctld.pl\fP script:
The following commands have been tested with the Extended Response protocol and the
included \fBtestctld.pl\fP script:
.br
\fI\\set_freq\fP \fI\\get_freq\fP \fI\\set_split_freq\fP \fI\\get_split_freq\fP
.br
@ -542,12 +549,12 @@ backgrounding:
$ rigctld -m 114 -r /dev/ttyUSB1 &
.PP
Start \fBrigctld\fP for a Yaesu FT-920 using a USB to serial adapter while
setting baud rate and stop bits, invoking block protocol, and backgrounding:
setting baud rate and stop bits, and backgrounding:
.PP
$ rigctld -m 114 -r /dev/ttyUSB1 -s 4800 -C stop_bits=2 --block &
$ rigctld -m 114 -r /dev/ttyUSB1 -s 4800 -C stop_bits=2 &
.PP
Connect to the already running \fBrigctld\fP, and set current frequency to
14.266 MHz with a 1 second read timeout:
14.266 MHz with a 1 second read timeout using the default protocol:
.PP
$ echo "\\set_freq 14266000" | nc -w 1 localhost 4532
.SH DIAGNOSTICS
@ -564,6 +571,10 @@ library development and may be requested by the developers. See the
No authentication whatsoever; DO NOT leave this TCP port open wide to the
Internet. Please ask if stronger security is needed or consider using an
SSH tunnel.
.PP
As \fBrigctld\fP does not need any greater permissions than \fBrigctl\fP, it
is advisable to not start \fBrigctld\fP as \fIroot\fP or another system user
account in order to limit any vulnerability.
.SH BUGS
The daemon is not detaching and backgrounding itself.
.br

Wyświetl plik

@ -68,7 +68,7 @@
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:lLuobevhV"
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:lLuoevhV"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -86,7 +86,6 @@ static struct option long_options[] =
{"show-conf",0, 0, 'L'},
{"dump-caps", 0, 0, 'u'},
{"vfo", 0, 0, 'o'},
{"block", 0, 0, 'b'},
{"end-marker", 0, 0, 'e'},
{"verbose", 0, 0, 'v'},
{"help", 0, 0, 'h'},
@ -107,7 +106,6 @@ void usage(void);
int interactive = 1; /* no cmd because of daemon */
int prompt = 0; /* Daemon mode for rigparse return string */
int opt_end = 0; /* END marker for rigctld */
int opt_block = 0; /* Block markers for rigctld */
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
char send_cmd_term = '\r'; /* send_cmd termination char */
@ -279,10 +277,7 @@ int main (int argc, char *argv[])
break;
case 'e':
opt_end++;
fprintf(stderr, "-e|--end-marker option is deprecated. Please consider -b|--block instead.\n");
break;
case 'b':
opt_block++;
fprintf(stderr, "-e|--end-marker option is deprecated!\nPlease consider using the Extended Response protocol instead.\n");
break;
default:
usage(); /* unknown option? */
@ -518,8 +513,7 @@ void usage(void)
" -l, --list list all model numbers and exit\n"
" -u, --dump-caps dump capabilities and exit\n"
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
" -b, --block use block rigctld protocol\n",
" -e, --end-marker use END marker in rigctld protocol\n"
" -e, --end-marker use END marker in rigctld protocol (obsolete)\n"
" -v, --verbose set verbose mode, cumulative\n"
" -h, --help display this help and exit\n"
" -V, --version output version information and exit\n\n",