Added two new commands to rigctl_parse.c, \chk_blk and \chk_vfo to allow

clients to query the state of the -b|--block or -o|--vfo options from rigctld

Cleaned up strings in dumpcaps.c to remove duplicates to facilite
their use as key:value pairs

Updated rigctld man page for new commands



git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2820 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.11
Nate Bargmann, N0NB 2010-02-04 00:53:56 +00:00
rodzic 5d539dcb02
commit 5e47dcf8d3
4 zmienionych plików z 252 dodań i 199 usunięć

Wyświetl plik

@ -58,7 +58,7 @@ int dumpcaps (RIG* rig, FILE *fout)
caps = rig->caps;
fprintf(fout, "Caps dump for model %d\n",caps->rig_model);
fprintf(fout, "Caps dump for model: %d\n", caps->rig_model);
fprintf(fout, "Model name:\t%s\n", caps->model_name);
fprintf(fout, "Mfg name:\t%s\n", caps->mfg_name);
fprintf(fout, "Backend version:\t%s\n", caps->version);
@ -104,16 +104,16 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, "PTT type:\t");
switch (caps->ptt_type) {
case RIG_PTT_RIG:
fprintf(fout, "rig capable\n");
fprintf(fout, "Rig capable\n");
break;
case RIG_PTT_PARALLEL:
fprintf(fout, "thru parallel port (DATA0)\n");
fprintf(fout, "Parallel port (DATA0)\n");
break;
case RIG_PTT_SERIAL_RTS:
fprintf(fout, "thru serial port (CTS/RTS)\n");
fprintf(fout, "Serial port (CTS/RTS)\n");
break;
case RIG_PTT_SERIAL_DTR:
fprintf(fout, "thru serial port (DTR/DSR)\n");
fprintf(fout, "Serial port (DTR/DSR)\n");
break;
case RIG_PTT_NONE:
fprintf(fout, "None\n");
@ -126,19 +126,19 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, "DCD type:\t");
switch (caps->dcd_type) {
case RIG_DCD_RIG:
fprintf(fout, "rig capable\n");
fprintf(fout, "Rig capable\n");
break;
case RIG_DCD_PARALLEL:
fprintf(fout, "thru parallel port (DATA1? STROBE?)\n");
fprintf(fout, "Parallel port (DATA1? STROBE?)\n");
break;
case RIG_DCD_SERIAL_CTS:
fprintf(fout, "thru serial port (CTS/RTS)\n");
fprintf(fout, "Serial port (CTS/RTS)\n");
break;
case RIG_DCD_SERIAL_DSR:
fprintf(fout, "thru serial port (DTR/DSR)\n");
fprintf(fout, "Serial port (DTR/DSR)\n");
break;
case RIG_DCD_SERIAL_CAR:
fprintf(fout, "thru serial port (CD)\n");
fprintf(fout, "Serial port (CD)\n");
break;
case RIG_DCD_NONE:
fprintf(fout, "None\n");
@ -157,13 +157,13 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, "Parallel\n");
break;
case RIG_PORT_DEVICE:
fprintf(fout, "device driver\n");
fprintf(fout, "Device driver\n");
break;
case RIG_PORT_USB:
fprintf(fout, "USB\n");
break;
case RIG_PORT_NETWORK:
fprintf(fout, "network link\n");
fprintf(fout, "Network link\n");
break;
case RIG_PORT_NONE:
fprintf(fout, "None\n");
@ -182,16 +182,16 @@ int dumpcaps (RIG* rig, FILE *fout)
(caps->serial_handshake == RIG_HANDSHAKE_XONXOFF ? "XONXOFF" : "CTS/RTS")
);
fprintf(fout, "Write delay %dms, timeout %dms, %d retry\n",
fprintf(fout, "Write delay: %dms, timeout %dms, %d retry\n",
caps->write_delay, caps->timeout, caps->retry);
fprintf(fout, "Post Write delay %dms\n",
fprintf(fout, "Post Write delay: %dms\n",
caps->post_write_delay);
fprintf(fout, "Has targetable VFO: %s\n",
caps->targetable_vfo?"yes":"no");
caps->targetable_vfo ? "Y" : "N");
fprintf(fout, "Has transceive: %s\n",
caps->transceive?"yes":"no");
caps->transceive ? "Y" : "N");
fprintf(fout, "Announce: 0x%x\n", caps->announces);
fprintf(fout, "Max RIT: -%ld.%ldkHz/+%ld.%ldkHz\n",
@ -210,13 +210,13 @@ int dumpcaps (RIG* rig, FILE *fout)
for(i = 0; i < MAXDBLSTSIZ && caps->preamp[i] != 0; i++)
fprintf(fout, " %ddB", caps->preamp[i]);
if (i == 0)
fprintf(fout, " none");
fprintf(fout, " None");
fprintf(fout, "\n");
fprintf(fout, "Attenuator:");
for(i = 0; i < MAXDBLSTSIZ && caps->attenuator[i] != 0; i++)
fprintf(fout, " %ddB",caps->attenuator[i]);
if (i == 0)
fprintf(fout, " none");
fprintf(fout, " None");
fprintf(fout, "\n");
fprintf(fout, "CTCSS:");
@ -224,7 +224,7 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, " %d.%1d", caps->ctcss_list[i] / 10, caps->ctcss_list[i] % 10);
}
if (i == 0)
fprintf(fout, " none");
fprintf(fout, " None");
else
fprintf(fout, " Hz, %d tones", i);
fprintf(fout, "\n");
@ -234,7 +234,7 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, " %d", caps->dcs_list[i]);
}
if (i == 0)
fprintf(fout, " none");
fprintf(fout, " None");
else
fprintf(fout, ", %d codes", i);
fprintf(fout, "\n");
@ -249,22 +249,24 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, "Get level: %s\n", prntbuf);
if ((caps->has_get_level & RIG_LEVEL_SQLSTAT)) {
fprintf(fout, "Warning: backend uses deprecated SQLSTAT level!\n");
fprintf(fout, "Warning--backend uses deprecated SQLSTAT level!\n");
backend_warnings++;
}
if ((caps->has_get_level & RIG_LEVEL_RAWSTR) &&
caps->str_cal.size == 0) {
fprintf(fout, "Warning: backend has get RAWSTR, but not calibration data\n");
fprintf(fout, "Warning--backend has get RAWSTR, but not calibration data\n");
backend_warnings++;
}
sprintf_level_gran(prntbuf, caps->has_set_level, caps->level_gran);
fprintf(fout, "Set level: %s\n", prntbuf);
if (caps->has_set_level & RIG_LEVEL_READONLY_LIST) {
fprintf(fout, "Warning: backend can set readonly levels!\n");
fprintf(fout, "Warning--backend can set readonly levels!\n");
backend_warnings++;
}
fprintf(fout, "Extra levels:");
rig_ext_level_foreach(rig, print_ext, fout);
fprintf(fout, "\n");
@ -275,7 +277,7 @@ int dumpcaps (RIG* rig, FILE *fout)
sprintf_parm_gran(prntbuf, caps->has_set_parm, caps->parm_gran);
fprintf(fout, "Set parameters: %s\n", prntbuf);
if (caps->has_set_parm & RIG_PARM_READONLY_LIST) {
fprintf(fout, "Warning: backend can set readonly parms!\n");
fprintf(fout, "Warning--backend can set readonly parms!\n");
backend_warnings++;
}
fprintf(fout, "Extra parameters:");
@ -286,7 +288,7 @@ int dumpcaps (RIG* rig, FILE *fout)
if (rig->state.vfo_list != 0)
sprintf_vfo(prntbuf, rig->state.vfo_list);
else
strcpy(prntbuf," none! This backend might be bogus!\n");
strcpy(prntbuf,"None. This backend might be bogus!\n");
fprintf(fout, "VFO list: %s\n", prntbuf);
sprintf_vfop(prntbuf, caps->vfo_ops);
@ -303,11 +305,11 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, "\n\t%d..%d: \t%s", caps->chan_list[i].start,
caps->chan_list[i].end,
rig_strmtype(caps->chan_list[i].type));
fprintf(fout, "\n\t mem caps: ");
fprintf(fout, "\n\t Mem caps: ");
dump_chan_caps(&caps->chan_list[i].mem_caps, fout);
}
if (i == 0)
fprintf(fout, " none");
fprintf(fout, " None");
fprintf(fout, "\n");
/* TODO: print rx/tx ranges here */
@ -328,14 +330,15 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, "Tuning steps:");
for (i = 0; i < TSLSTSIZ && !RIG_IS_TS_END(caps->tuning_steps[i]); i++) {
if (caps->tuning_steps[i].ts == RIG_TS_ANY)
strcpy(freqbuf, "ANY");
strcpy(freqbuf, "ANY"); /* strcpy! Looks safe for now */
else
sprintf_freq(freqbuf, caps->tuning_steps[i].ts);
sprintf_mode(prntbuf, caps->tuning_steps[i].modes);
fprintf(fout, "\n\t%s: \t%s", freqbuf, prntbuf);
}
if (i == 0) {
fprintf(fout, " none! This backend might be bogus!");
fprintf(fout, " None! This backend might be bogus!");
backend_warnings++;
}
fprintf(fout, "\n");
@ -353,7 +356,7 @@ int dumpcaps (RIG* rig, FILE *fout)
fprintf(fout, "\n\t%s: \t%s", freqbuf, prntbuf);
}
if (i == 0) {
fprintf(fout, " none! This backend might be bogus!");
fprintf(fout, " None. This backend might be bogus!");
backend_warnings++;
}
fprintf(fout, "\n");
@ -366,13 +369,13 @@ int dumpcaps (RIG* rig, FILE *fout)
continue;
sprintf_freq(freqbuf, pbnorm);
fprintf(fout, "\n\t%s\tnormal: %s,\t", rig_strrmode(i), freqbuf);
fprintf(fout, "\n\t%s\tNormal: %s,\t", rig_strrmode(i), freqbuf);
sprintf_freq(freqbuf, rig_passband_narrow(rig, i));
fprintf(fout, "narrow: %s,\t", freqbuf);
fprintf(fout, "Narrow: %s,\t", freqbuf);
sprintf_freq(freqbuf, rig_passband_wide(rig, i));
fprintf(fout, "wide: %s", freqbuf);
fprintf(fout, "Wide: %s", freqbuf);
}
fprintf(fout, "\n");

Wyświetl plik

@ -1,8 +1,9 @@
/*
* rigctl_parse.c - (C) Stephane Fillod 2000-2009
* (C) Terry Embry 2008-2009
* (C) The Hamlib Group 2010
*
* This program test/control a radio using Hamlib.
* This program tests/controls a radio using Hamlib.
* It takes commands in interactive mode as well as
* from command line options.
*
@ -149,6 +150,8 @@ 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);
/*
@ -223,6 +226,8 @@ 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 */
{ 0x00, "", NULL },
};
@ -461,8 +466,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
rig_debug(RIG_DEBUG_TRACE, "rigctl(d): %c '%s' '%s' '%s'\n",
cmd, p1, p2, p3);
/* Block protocol: output received command name and arguments response */
if (interactive && opt_block) {
/*
* Block protocol: output received command name and arguments response
* Don't send response on '\chk_blk' command
*/
if (interactive && opt_block && (cmd != 0xf0 && cmd != 0xf1)) {
char a1[MAXARGSZ+1];
char a2[MAXARGSZ+1];
char a3[MAXARGSZ+1];
@ -481,18 +489,22 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc)
pthread_mutex_unlock(&rig_mutex);
#endif
if (retcode != RIG_OK) {
if (interactive && !prompt && opt_block)
if ((interactive && !prompt && opt_block) || (interactive && !prompt))
fprintf(fout, NETRIGCTL_RET "%d\n", retcode); /* only for rigctld */
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 */
if (!(cmd_entry->flags & ARG_OUT) && !opt_end) /* netrigctl RIG_OK */
if (!(cmd_entry->flags & ARG_OUT)
&& !opt_end && !opt_block && (cmd != 0xf0 && cmd != 0xf1)) /* netrigctl RIG_OK */
fprintf(fout, NETRIGCTL_RET "0\n");
else if ((cmd_entry->flags & ARG_OUT) && opt_end) /* Nate's protocol */
fprintf(fout, "END\n");
else if (opt_block) /* block marker protocol */
else if (opt_block && (cmd != 0xf0 && cmd != 0xf1)) /* block marker protocol */
fprintf(fout, NETRIGCTL_RET "0\n");
}
}
@ -2040,3 +2052,19 @@ 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)
{
fprintf(fout, "CHKVFO %d\n", vfo_mode);
return RIG_OK;
}

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" "January 24, 2010" "Hamlib" "Rig Control Daemon"
.TH RIGCTLD "8" "February 3, 2010" "Hamlib" "Rig Control Daemon"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -117,10 +117,12 @@ Dump capabilities for the radio defined with -m above and exit.
.TP
.B \-o, --vfo
Set vfo mode, requiring an extra VFO argument in front of each appropriate
command. Otherwise, VFO_CURR is assumed when this option is not set.
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. \fIEXPERIMENTAL\fP
Use the block rigctld protocol. See \fI\\chk_blk\fP below. \fIEXPERIMENTAL\fP
.TP
.B \-e, --end-marker
Use END marker in rigctld protocol.
@ -160,9 +162,9 @@ 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!).
.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 \fBHamlib\fP error message.
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
\fBHamlib\fP error message.
.PP
Here is a summary of the supported commands (In the case of "set" commands the
quoted string is replaced by the value in the description. In the case of "get"
@ -185,7 +187,8 @@ Get 'Mode' 'Passband'. Returns Mode as a string from \fIset_mode\fP above
and Passband in Hz.
.TP
.B V, set_vfo 'VFO'
Set 'VFO': VFOA, VFOB, VFOC, currVFO, VFO, MEM, Main, Sub, TX, RX.
Set 'VFO': VFOA, VFOB, VFOC, currVFO, VFO, MEM, Main, Sub, TX, RX. In VFO mode
only a single VFO parameter is required.
.TP
.B v, get_vfo
Get current 'VFO'. Returns VFO as a string from \fIset_vfo\fP above.
@ -369,7 +372,8 @@ Get misc information about the rig (no value is passed).
.B 1, dump_caps
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.
in a consistent format so it can be read into a hash, dictionary, etc. Bug
reports requested.
.TP
.B 2, power2mW
Converts a power value in a range of \fI0.0 ... 1.0\fP to the real transmit
@ -381,6 +385,20 @@ Send raw command string to rig.
.br
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
\fI\\set\fP or \fI\\get\fP commands. 'VFO' is one of the strings defined
for \fI\\set_vfo\fP above.
.br
.SH PROTOCOL
\fBDefault Protocol\fP
.br
@ -456,11 +474,13 @@ 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
`testctld.pl' script:
\fBtestctld.pl\fP script:
.br
\fI\\set_freq\fP \fI\\get-freq\fP
.br
\fI\\set_mode\fP \fI\\get_mode\fP
.br
\fI\\set_vfo\fP \fI\\get_vfo\fP
.SH EXAMPLES
Start \fBrigctld\fP for a Yaesu FT-920 using an USB-to-serial adapter and
backgrounding:
@ -468,13 +488,14 @@ 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 and backgrounding:
setting baud rate and stop bits, invoking block protocol, and backgrounding:
.PP
$ rigctld -m 114 -r /dev/ttyUSB1 -s 4800 -C stop_bits=2 &
$ rigctld -m 114 -r /dev/ttyUSB1 -s 4800 -C stop_bits=2 --block &
.PP
Connect to the already running \fBrigctld\fP, and set current frequency to 14.266 MHz:
Connect to the already running \fBrigctld\fP, and set current frequency to
14.266 MHz with a 1 second read timeout:
.PP
$ echo "\\set_freq 14266000" | nc localhost 4532
$ echo "\\set_freq 14266000" | nc -w 1 localhost 4532
.SH DIAGNOSTICS
The \fB-v\fP, \fB--verbose\fP, option allows different levels of diagnostics
to be output to \fBstderr\fP and correspond to -v for BUG, -vv for ERR,
@ -498,11 +519,11 @@ Report bugs to <hamlib-developer@lists.sourceforge.net>.
.br
We are already aware of the bugs in the previous section :-)
.SH AUTHORS
Written by Stephane Fillod and the Hamlib Group
Written by Stephane Fillod, Nate Bargmann, and the Hamlib Group
.br
<http://www.hamlib.org>.
.SH COPYRIGHT
Copyright \(co 2000-2010 Stephane Fillod and the Hamlib Group.
Copyright \(co 2000-2010 Stephane Fillod, Nate Bargmann, and the Hamlib Group.
.PP
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY

Wyświetl plik

@ -108,7 +108,7 @@ 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; /* vfo_mode=0 means target VFO is current VFO */
int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */
char send_cmd_term = '\r'; /* send_cmd termination char */
@ -278,10 +278,11 @@ int main (int argc, char *argv[])
dump_caps_opt++;
break;
case 'e':
opt_end = 1;
opt_end++;
fprintf(stderr, "-e|--end-marker option is deprecated. Please consider -b|--block instead.\n");
break;
case 'b':
opt_block = 1;
opt_block++;
break;
default:
usage(); /* unknown option? */
@ -339,7 +340,7 @@ int main (int argc, char *argv[])
}
/*
* print out conf parameters, and exists immediately
* print out conf parameters, and exits immediately
* We may be interested only in only caps, and rig_open may fail.
*/
if (dump_caps_opt) {