kopia lustrzana https://github.com/Hamlib/Hamlib
merged testcaps and dumpcaps into rigctl, added -u option (dumpcaps) to rigctl
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1160 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.4
rodzic
226acde526
commit
4e528d0f85
|
@ -1,8 +1,15 @@
|
|||
|
||||
AUTOMAKE_OPTIONS = dejagnu
|
||||
|
||||
RUNTESTDEFAULTFLAGS = --tool rigctl --srcdir $$srcdir/testsuite RIGCTL=`pwd`/rigctl TESTBCD=`pwd`/testbcd
|
||||
|
||||
|
||||
bin_PROGRAMS = rigctl rotctl
|
||||
man_MANS = rigctl.1 rotctl.1
|
||||
|
||||
noinst_PROGRAMS = dumpcaps dumpmem testcaps testrig testtrn testbcd testfreq listrigs testloc @RIGMATRIX@
|
||||
noinst_PROGRAMS = dumpmem testrig testtrn testbcd testfreq listrigs testloc @RIGMATRIX@
|
||||
|
||||
rigctl_SOURCES = rigctl.c dumpcaps.c
|
||||
|
||||
EXTRA_PROGRAMS = rigmatrix
|
||||
|
||||
|
@ -12,9 +19,7 @@ DEPENDENCIES = ../src/libhamlib.la
|
|||
|
||||
## Linker options
|
||||
listrigs_LDFLAGS = @BACKENDLNK@
|
||||
dumpcaps_LDFLAGS = @BACKENDLNK@
|
||||
dumpmem_LDFLAGS = @BACKENDLNK@
|
||||
testcaps_LDFLAGS = @BACKENDLNK@
|
||||
testrig_LDFLAGS = @BACKENDLNK@
|
||||
testtrn_LDFLAGS = @BACKENDLNK@
|
||||
testfreq_LDFLAGS = @BACKENDLNK@
|
||||
|
@ -30,9 +35,7 @@ rigmatrix_LDFLAGS = -lgd -lz @BACKENDLNK@
|
|||
|
||||
## Dependencies
|
||||
|
||||
dumpcaps_DEPENDENCIES = $(DEPENDENCIES) @BACKENDEPS@
|
||||
dumpmem_DEPENDENCIES = $(DEPENDENCIES) @BACKENDEPS@
|
||||
testcaps_DEPENDENCIES = $(DEPENDENCIES) @BACKENDEPS@
|
||||
testrig_DEPENDENCIES = $(DEPENDENCIES) @BACKENDEPS@
|
||||
testtrn_DEPENDENCIES = $(DEPENDENCIES) @BACKENDEPS@
|
||||
listrigs_DEPENDENCIES = $(DEPENDENCIES) @BACKENDEPS@
|
||||
|
@ -42,10 +45,10 @@ rigmatrix_DEPENDENCIES = $(DEPENDENCIES) @BACKENDEPS@
|
|||
|
||||
|
||||
|
||||
rigmatrix.html: rigmatrix_head.html rigmatrix listrigs dumpcaps
|
||||
rigmatrix.html: rigmatrix_head.html rigmatrix listrigs
|
||||
mkdir -p html
|
||||
( cd html && cat ../rigmatrix_head.html && ../rigmatrix ) > html/rigmatrix.html
|
||||
for f in `./listrigs | tail +2 | cut -f1` ; do ( ./dumpcaps $$f > html/model$$f.txt || exit 0 ) ; done
|
||||
for f in `./listrigs | tail +2 | cut -f1` ; do ( ./rigctl -m $$f -u > html/model$$f.txt || exit 0 ) ; done
|
||||
|
||||
EXTRA_DIST = rigmatrix_head.html $(man_MANS)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* This programs dumps the capabilities of a backend rig.
|
||||
*
|
||||
*
|
||||
* $Id: dumpcaps.c,v 1.31 2002-01-29 22:04:30 fillods Exp $
|
||||
* $Id: dumpcaps.c,v 1.32 2002-09-06 14:07:17 fillods Exp $
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -31,36 +31,28 @@
|
|||
#include "misc.h"
|
||||
|
||||
|
||||
static int print_ext(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr);
|
||||
static const char *decode_mtype(enum chan_type_e type);
|
||||
int range_sanity_check(const struct freq_range_list range_list[], int rx);
|
||||
int ts_sanity_check(const struct tuning_step_list tuning_step[]);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
/*
|
||||
* the rig may be in rig_init state, but not openned
|
||||
*/
|
||||
int dumpcaps (RIG* rig)
|
||||
{
|
||||
const struct rig_caps *caps;
|
||||
int status,i;
|
||||
char freqbuf[20];
|
||||
int backend_warnings=0;
|
||||
int rig_model;
|
||||
char prntbuf[256];
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr,"%s <rig_num>\n",argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if (!rig || !rig->caps)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
rig_model = atoi(argv[1]);
|
||||
|
||||
rig_check_backend(rig_model);
|
||||
caps = rig->caps;
|
||||
|
||||
caps = rig_get_caps(rig_model);
|
||||
if (!caps) {
|
||||
fprintf(stderr,"Unknown rig num: %d\n", rig_model);
|
||||
fprintf(stderr,"Please check riglist.h\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
printf("Rig dump for model %d\n",caps->rig_model);
|
||||
printf("Caps dump for model %d\n",caps->rig_model);
|
||||
printf("Model name:\t%s\n",caps->model_name);
|
||||
printf("Mfg name:\t%s\n",caps->mfg_name);
|
||||
printf("Backend version:\t%s\n",caps->version);
|
||||
|
@ -224,6 +216,9 @@ int main (int argc, char *argv[])
|
|||
printf("Warning: backend can set readonly levels!\n");
|
||||
backend_warnings++;
|
||||
}
|
||||
printf("Extra levels:");
|
||||
rig_ext_level_foreach(rig, print_ext, NULL);
|
||||
printf("\n");
|
||||
|
||||
sprintf_parm(prntbuf, caps->has_get_parm);
|
||||
printf("Get parameters: %s\n", prntbuf);
|
||||
|
@ -234,6 +229,9 @@ int main (int argc, char *argv[])
|
|||
printf("Warning: backend can set readonly parms!\n");
|
||||
backend_warnings++;
|
||||
}
|
||||
printf("Extra parameters:");
|
||||
rig_ext_parm_foreach(rig, print_ext, NULL);
|
||||
printf("\n");
|
||||
|
||||
#if 0
|
||||
/* FIXME: use rig->state.vfo_list instead */
|
||||
|
@ -304,6 +302,24 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
printf("\n");
|
||||
|
||||
printf("Bandwidths:");
|
||||
for (i=1; i < 1<<10; i<<=1) {
|
||||
pbwidth_t pbnorm = rig_passband_normal(rig, i);
|
||||
|
||||
if (pbnorm == 0)
|
||||
continue;
|
||||
|
||||
sprintf_freq(freqbuf, pbnorm);
|
||||
printf("\n\t%s\tnormal: %s,\t", strrmode(i), freqbuf);
|
||||
|
||||
sprintf_freq(freqbuf, rig_passband_narrow(rig, i));
|
||||
printf("narrow: %s,\t", freqbuf);
|
||||
|
||||
sprintf_freq(freqbuf, rig_passband_wide(rig, i));
|
||||
printf("wide: %s", freqbuf);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("Has priv data:\t%c\n",caps->priv!=NULL?'Y':'N');
|
||||
/*
|
||||
* TODO: keep me up-to-date with API call list!
|
||||
|
@ -380,6 +396,14 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
|
||||
static int print_ext(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr)
|
||||
{
|
||||
printf(" %s", cfp->name);
|
||||
|
||||
return 1; /* process them all */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NB: this function is not reentrant, because of the static buf.
|
||||
* but who cares? --SF
|
||||
|
|
|
@ -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 RIGCTL "1" "April 17, 2002" "Hamlib"
|
||||
.TH RIGCTL "1" "September 6, 2002" "Hamlib"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
|
@ -76,6 +76,9 @@ Set config parameter.
|
|||
.B \-l, \-\-list
|
||||
List all model numbers and exit.
|
||||
.TP
|
||||
.B \-u, \-\-dump\-caps
|
||||
Dump capabilities and exit.
|
||||
.TP
|
||||
.B \-v, \-\-verbose
|
||||
Set verbose mode, cumulative.
|
||||
.TP
|
||||
|
@ -87,12 +90,16 @@ Show version of program and exit.
|
|||
|
||||
.SH COMMANDS
|
||||
Commands can be entered either as a single char, or as a long command name.
|
||||
Basically, the commands do not take a dash in front of them, as
|
||||
the options usually do. They may be typed in when in interactive mode
|
||||
Basically, the commands do not take a dash in front of them on the command
|
||||
line, as the options usually do. They may be typed in when in interactive mode
|
||||
or provided as argument in command line interface mode.
|
||||
.PP
|
||||
Since most of the Hamlib operations have a \fIset\fP and a \fIget\fP method,
|
||||
upper case letter will be used for \fIset\fP method whereas the corresponding
|
||||
lower case letter refers to the \fIget\fP method.
|
||||
In interactive, prepend a backslash to enter a long command name.
|
||||
Example: "\\dump_caps" to see what this model can do.
|
||||
|
||||
.PP
|
||||
Please note that the backend for the radio to be controlled,
|
||||
or the radio itself may not support some commands. In that case,
|
||||
|
@ -173,16 +180,6 @@ Set tuning step, in Hz.
|
|||
.B n, get_ts
|
||||
Get tuning step.
|
||||
.TP
|
||||
.B L, set_level
|
||||
Set level/value:
|
||||
PREAMP, ATT, VOX, AF, RF, SQL, IF, APF, NR, PBT_IN,
|
||||
PBT_OUT, CWPITCH, RFPOWER, MICGAIN, KEYSPD, NOTCHF, COMP,
|
||||
AGC, BKINDL, BAL, METER, VOXGAIN, ANTIVOX.
|
||||
.TP
|
||||
.B l, get_level
|
||||
Get level value: also
|
||||
SWR, ALC, SQLSTAT, STRENGTH.
|
||||
.TP
|
||||
.B U, set_func
|
||||
Set func/status:
|
||||
FAGC, NB, COMP, VOX, TONE, TSQL, SBKIN, FBKIN, ANF, NR, AIP, MON, MN,
|
||||
|
@ -191,9 +188,19 @@ RNF, ARO, LOCK, MUTE, VSC, REV, SQL, BC, MBC, LMP, AFC, SATMODE, SCOPE, RESUME.
|
|||
.B u, get_func
|
||||
Get func status.
|
||||
.TP
|
||||
.B L, set_level
|
||||
Set level/value:
|
||||
PREAMP, ATT, VOX, AF, RF, SQL, IF, APF, NR, PBT_IN,
|
||||
PBT_OUT, CWPITCH, RFPOWER, MICGAIN, KEYSPD, NOTCHF, COMP,
|
||||
AGC, BKINDL, BAL, METER, VOXGAIN, ANTIVOX. Plus "extra" levels.
|
||||
.TP
|
||||
.B l, get_level
|
||||
Get level value: also
|
||||
SWR, ALC, SQLSTAT, STRENGTH.
|
||||
.TP
|
||||
.B P, set_parm
|
||||
Set parm/value:
|
||||
ANN, APO, BACKLIGHT, BEEP, TIME, BAT.
|
||||
ANN, APO, BACKLIGHT, BEEP, TIME, BAT. Plus "extra" parameters.
|
||||
.TP
|
||||
.B p, get_parm
|
||||
Get parm value.
|
||||
|
@ -228,6 +235,10 @@ Get transceive mode (reporting event).
|
|||
.TP
|
||||
.B _, get_info
|
||||
Get misc information about the rig.
|
||||
.TP
|
||||
.B 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.
|
||||
|
||||
.SH RETURN VALUE
|
||||
rigctl exits with:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* It takes commands in interactive mode as well as
|
||||
* from command line options.
|
||||
*
|
||||
* $Id: rigctl.c,v 1.36 2002-09-06 10:43:59 fillods Exp $
|
||||
* $Id: rigctl.c,v 1.37 2002-09-06 14:07:16 fillods Exp $
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -68,6 +68,13 @@ struct test_table {
|
|||
const char *arg3;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* external prototype
|
||||
*/
|
||||
|
||||
int dumpcaps (RIG *);
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
|
@ -127,6 +134,7 @@ declare_proto_rig(get_channel);
|
|||
declare_proto_rig(set_trn);
|
||||
declare_proto_rig(get_trn);
|
||||
declare_proto_rig(get_info);
|
||||
declare_proto_rig(dump_caps);
|
||||
|
||||
|
||||
|
||||
|
@ -182,6 +190,7 @@ struct test_table test_list[] = {
|
|||
{ 'B', "set_bank", set_bank, ARG_IN, "Bank" },
|
||||
{ '_', "get_info", get_info, ARG_OUT, "Info" },
|
||||
{ '2', "power2mW", power2mW },
|
||||
{ 0x80, "dump_caps", dump_caps },
|
||||
{ 0x00, "", NULL },
|
||||
|
||||
};
|
||||
|
@ -192,7 +201,7 @@ struct test_table test_list[] = {
|
|||
* 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:P:d:D:c:s:C:LvhVl"
|
||||
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:lC:LuvhV"
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"model", 1, 0, 'm'},
|
||||
|
@ -206,6 +215,7 @@ static struct option long_options[] =
|
|||
{"list", 0, 0, 'l'},
|
||||
{"set-conf", 1, 0, 'C'},
|
||||
{"show-conf",0, 0, 'L'},
|
||||
{"dump-caps", 0, 0, 'u'},
|
||||
{"verbose", 0, 0, 'v'},
|
||||
{"help", 0, 0, 'h'},
|
||||
{"version", 0, 0, 'V'},
|
||||
|
@ -245,11 +255,12 @@ int main (int argc, char *argv[])
|
|||
|
||||
int interactive=1; /* if no cmd on command line, switch to interactive */
|
||||
int retcode; /* generic return code from functions */
|
||||
char cmd;
|
||||
unsigned char cmd;
|
||||
struct test_table *cmd_entry;
|
||||
|
||||
int verbose = 0;
|
||||
int show_conf = 0;
|
||||
int dump_caps_opt = 0;
|
||||
const char *rig_file=NULL, *ptt_file=NULL, *dcd_file=NULL;
|
||||
ptt_type_t ptt_type = RIG_PTT_NONE;
|
||||
dcd_type_t dcd_type = RIG_DCD_NONE;
|
||||
|
@ -369,6 +380,9 @@ int main (int argc, char *argv[])
|
|||
case 'l':
|
||||
list_models();
|
||||
exit(0);
|
||||
case 'u':
|
||||
dump_caps_opt++;
|
||||
break;
|
||||
default:
|
||||
usage(); /* unknown option? */
|
||||
exit(1);
|
||||
|
@ -430,6 +444,16 @@ int main (int argc, char *argv[])
|
|||
rig_token_foreach(my_rig, print_conf_list, (rig_ptr_t)my_rig);
|
||||
}
|
||||
|
||||
/*
|
||||
* print out conf parameters, and exists immediately
|
||||
* We may be interested only in only caps, and rig_open may fail.
|
||||
*/
|
||||
if (dump_caps_opt) {
|
||||
dumpcaps(my_rig);
|
||||
rig_cleanup(my_rig); /* if you care about memory */
|
||||
exit(0);
|
||||
}
|
||||
|
||||
retcode = rig_open(my_rig);
|
||||
if (retcode != RIG_OK) {
|
||||
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
||||
|
@ -457,7 +481,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
/* command by name */
|
||||
if (cmd == '\\') {
|
||||
char cmd_name[MAXNAMSIZ], *pcmd = cmd_name;
|
||||
unsigned char cmd_name[MAXNAMSIZ], *pcmd = cmd_name;
|
||||
int c_len = MAXNAMSIZ;
|
||||
|
||||
scanf("%c", pcmd);
|
||||
|
@ -612,6 +636,7 @@ void usage()
|
|||
" -C, --set-conf=PARM=VAL set config parameters\n"
|
||||
" -L, --show-conf list all config parameters\n"
|
||||
" -l, --list list all model numbers and exit\n"
|
||||
" -u, --dump-caps dump capabilities and exit\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"
|
||||
|
@ -1473,3 +1498,11 @@ void dump_chan(RIG *rig, channel_t *chan)
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
declare_proto_rig(dump_caps)
|
||||
{
|
||||
dumpcaps(rig);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
109
tests/testcaps.c
109
tests/testcaps.c
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* testcaps.c - Copyright (C) 2001 Stephane Fillod
|
||||
* This programs test the capabilities of a backend rig,
|
||||
* like the passband info..
|
||||
*
|
||||
*
|
||||
* $Id: testcaps.c,v 1.5 2002-01-27 23:55:45 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
static char *decode_modes(rmode_t modes);
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
const struct rig_caps *caps;
|
||||
int i;
|
||||
char freqbuf[20];
|
||||
RIG *pbrig;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr,"%s <rig_num>\n",argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pbrig = rig_init(atoi(argv[1]));
|
||||
if (!pbrig) {
|
||||
fprintf(stderr,"Unknown rig num: %d\n",atoi(argv[1]));
|
||||
fprintf(stderr,"Please check riglist.h\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
caps = pbrig->caps;
|
||||
|
||||
printf("Rig dump for model %d\n",caps->rig_model);
|
||||
printf("Model name:\t%s\n",caps->model_name);
|
||||
printf("Mfg name:\t%s\n",caps->mfg_name);
|
||||
printf("Backend version:\t%s\n",caps->version);
|
||||
|
||||
|
||||
for (i=1; i < 1<<10; i<<=1) {
|
||||
const char *mode = decode_modes(i);
|
||||
|
||||
pbwidth_t pbnorm = rig_passband_normal(pbrig, i);
|
||||
if (pbnorm == 0)
|
||||
continue;
|
||||
|
||||
sprintf_freq(freqbuf, pbnorm);
|
||||
printf("%s normal: %s\n", mode, freqbuf);
|
||||
|
||||
sprintf_freq(freqbuf, rig_passband_narrow(pbrig, i));
|
||||
printf("%s narrow: %s\n", mode, freqbuf);
|
||||
|
||||
sprintf_freq(freqbuf, rig_passband_wide(pbrig, i));
|
||||
printf("%s wide: %s\n", mode, freqbuf);
|
||||
}
|
||||
|
||||
rig_cleanup(pbrig);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* NB: this function is not reentrant, because of the static buf.
|
||||
* but who cares? --SF
|
||||
*/
|
||||
static char *decode_modes(rmode_t modes)
|
||||
{
|
||||
static char buf[80];
|
||||
|
||||
buf[0] = '\0';
|
||||
if (modes&RIG_MODE_AM) strcat(buf,"AM ");
|
||||
if (modes&RIG_MODE_CW) strcat(buf,"CW ");
|
||||
if (modes&RIG_MODE_USB) strcat(buf,"USB ");
|
||||
if (modes&RIG_MODE_LSB) strcat(buf,"LSB ");
|
||||
if (modes&RIG_MODE_RTTY) strcat(buf,"RTTY ");
|
||||
if (modes&RIG_MODE_FM) strcat(buf,"FM ");
|
||||
#ifdef RIG_MODE_WFM
|
||||
if (modes&RIG_MODE_WFM) strcat(buf,"WFM ");
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
Ładowanie…
Reference in New Issue