2000-10-29 16:35:29 +00:00
|
|
|
/*
|
2005-01-24 23:04:35 +00:00
|
|
|
* rigctl.c - (C) Stephane Fillod 2000-2005
|
2000-10-29 16:35:29 +00:00
|
|
|
*
|
|
|
|
* This program test/control a radio using Hamlib.
|
2001-07-20 11:09:26 +00:00
|
|
|
* It takes commands in interactive mode as well as
|
|
|
|
* from command line options.
|
2000-10-29 16:35:29 +00:00
|
|
|
*
|
2005-01-25 00:22:14 +00:00
|
|
|
* $Id: rigctl.c,v 1.54 2005-01-25 00:21:46 fillods Exp $
|
2000-10-29 16:35:29 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
#include <stdio.h>
|
2001-07-20 11:09:26 +00:00
|
|
|
#include <stdlib.h>
|
2000-10-29 16:35:29 +00:00
|
|
|
#include <string.h>
|
2001-02-25 23:14:19 +00:00
|
|
|
#include <unistd.h>
|
2002-09-06 10:43:59 +00:00
|
|
|
#include <ctype.h>
|
2003-05-03 13:17:25 +00:00
|
|
|
#include <errno.h>
|
2001-02-25 23:14:19 +00:00
|
|
|
|
|
|
|
#include <getopt.h>
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
#include <hamlib/rig.h>
|
2001-12-20 07:51:02 +00:00
|
|
|
#include "misc.h"
|
2003-11-16 17:34:00 +00:00
|
|
|
#include "sprintflst.h"
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
#define MAXNAMSIZ 32
|
2001-02-25 23:14:19 +00:00
|
|
|
#define MAXNBOPT 100 /* max number of different options */
|
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-09-22 11:49:19 +00:00
|
|
|
#define ARG_IN1 0x01
|
|
|
|
#define ARG_OUT1 0x02
|
|
|
|
#define ARG_IN2 0x04
|
|
|
|
#define ARG_OUT2 0x08
|
|
|
|
#define ARG_IN3 0x10
|
|
|
|
#define ARG_OUT3 0x20
|
|
|
|
#define ARG_IN4 0x40
|
|
|
|
#define ARG_OUT4 0x80
|
2003-03-27 23:44:20 +00:00
|
|
|
#define ARG_NOVFO 0x8000
|
2001-09-22 11:49:19 +00:00
|
|
|
|
|
|
|
#define ARG_IN (ARG_IN1|ARG_IN2|ARG_IN3|ARG_IN4)
|
|
|
|
#define ARG_OUT (ARG_OUT1|ARG_OUT2|ARG_OUT3|ARG_OUT4)
|
2001-07-20 11:09:26 +00:00
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
struct test_table {
|
2001-02-25 23:14:19 +00:00
|
|
|
unsigned char cmd;
|
2001-07-20 11:09:26 +00:00
|
|
|
const char *name;
|
2003-03-27 23:44:20 +00:00
|
|
|
int (*rig_routine)(RIG*, int, const struct test_table*, vfo_t,
|
|
|
|
const char*, const char*, const char*);
|
2001-07-20 11:09:26 +00:00
|
|
|
int flags;
|
|
|
|
const char *arg1;
|
|
|
|
const char *arg2;
|
|
|
|
const char *arg3;
|
2000-10-29 16:35:29 +00:00
|
|
|
};
|
|
|
|
|
2002-09-06 14:07:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* external prototype
|
|
|
|
*/
|
|
|
|
|
|
|
|
int dumpcaps (RIG *);
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
/*
|
|
|
|
* Prototypes
|
|
|
|
*/
|
|
|
|
void usage();
|
|
|
|
void usage_rig();
|
|
|
|
void version();
|
|
|
|
void list_models();
|
2002-01-27 23:58:24 +00:00
|
|
|
void dump_chan(RIG*, channel_t*);
|
2001-12-20 07:51:02 +00:00
|
|
|
static int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
|
|
|
|
int set_conf(RIG *my_rig, char *conf_parms);
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
#define declare_proto_rig(f) static int (f)(RIG *rig, int interactive, \
|
2003-03-27 23:44:20 +00:00
|
|
|
const struct test_table *cmd, vfo_t vfo, const char *arg1, \
|
2001-07-20 11:09:26 +00:00
|
|
|
const char *arg2, const char *arg3)
|
2001-02-25 23:14:19 +00:00
|
|
|
|
|
|
|
declare_proto_rig(set_freq);
|
|
|
|
declare_proto_rig(get_freq);
|
2002-08-19 22:17:11 +00:00
|
|
|
declare_proto_rig(set_rit);
|
|
|
|
declare_proto_rig(get_rit);
|
2002-11-28 22:25:46 +00:00
|
|
|
declare_proto_rig(set_xit);
|
|
|
|
declare_proto_rig(get_xit);
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_mode);
|
|
|
|
declare_proto_rig(get_mode);
|
|
|
|
declare_proto_rig(set_vfo);
|
|
|
|
declare_proto_rig(get_vfo);
|
|
|
|
declare_proto_rig(set_ptt);
|
|
|
|
declare_proto_rig(get_ptt);
|
|
|
|
declare_proto_rig(get_ptt);
|
|
|
|
declare_proto_rig(set_rptr_shift);
|
|
|
|
declare_proto_rig(get_rptr_shift);
|
|
|
|
declare_proto_rig(set_rptr_offs);
|
|
|
|
declare_proto_rig(get_rptr_offs);
|
2001-07-01 11:46:17 +00:00
|
|
|
declare_proto_rig(set_ctcss_tone);
|
|
|
|
declare_proto_rig(get_ctcss_tone);
|
|
|
|
declare_proto_rig(set_dcs_code);
|
|
|
|
declare_proto_rig(get_dcs_code);
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_split_freq);
|
|
|
|
declare_proto_rig(get_split_freq);
|
2001-12-20 07:51:02 +00:00
|
|
|
declare_proto_rig(set_split_mode);
|
|
|
|
declare_proto_rig(get_split_mode);
|
2003-04-06 18:40:36 +00:00
|
|
|
declare_proto_rig(set_split_vfo);
|
|
|
|
declare_proto_rig(get_split_vfo);
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_ts);
|
|
|
|
declare_proto_rig(get_ts);
|
|
|
|
declare_proto_rig(power2mW);
|
|
|
|
declare_proto_rig(set_level);
|
|
|
|
declare_proto_rig(get_level);
|
|
|
|
declare_proto_rig(set_func);
|
|
|
|
declare_proto_rig(get_func);
|
2001-12-20 07:51:02 +00:00
|
|
|
declare_proto_rig(set_parm);
|
|
|
|
declare_proto_rig(get_parm);
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_bank);
|
|
|
|
declare_proto_rig(set_mem);
|
|
|
|
declare_proto_rig(get_mem);
|
2001-06-03 19:54:05 +00:00
|
|
|
declare_proto_rig(vfo_op);
|
2001-06-26 20:55:29 +00:00
|
|
|
declare_proto_rig(scan);
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_channel);
|
|
|
|
declare_proto_rig(get_channel);
|
|
|
|
declare_proto_rig(set_trn);
|
|
|
|
declare_proto_rig(get_trn);
|
2002-01-09 23:09:10 +00:00
|
|
|
declare_proto_rig(get_info);
|
2002-09-06 14:07:17 +00:00
|
|
|
declare_proto_rig(dump_caps);
|
2002-11-28 22:25:46 +00:00
|
|
|
declare_proto_rig(set_ant);
|
|
|
|
declare_proto_rig(get_ant);
|
2003-10-20 22:15:02 +00:00
|
|
|
declare_proto_rig(reset);
|
2004-06-06 21:59:54 +00:00
|
|
|
declare_proto_rig(send_morse);
|
|
|
|
declare_proto_rig(set_powerstat);
|
|
|
|
declare_proto_rig(get_powerstat);
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
|
|
|
|
|
2001-02-11 23:22:06 +00:00
|
|
|
/*
|
2001-02-25 23:14:19 +00:00
|
|
|
* convention: upper case cmd is set, lowercase is get
|
|
|
|
*
|
2002-11-28 22:25:46 +00:00
|
|
|
* TODO: add missing rig_set_/rig_get_: sql, dcd, etc.
|
2001-07-20 11:09:26 +00:00
|
|
|
* NB: 'q' 'Q' '?' are reserved by interactive mode interface
|
2003-03-27 23:44:20 +00:00
|
|
|
* do NOT use -W since it's reserved by POSIX.
|
2002-01-09 23:09:10 +00:00
|
|
|
*
|
2003-03-27 23:44:20 +00:00
|
|
|
* Available alphabetic letters: -.--------K-----*-----W-Y-
|
2001-02-11 23:22:06 +00:00
|
|
|
*/
|
2000-10-29 16:35:29 +00:00
|
|
|
struct test_table test_list[] = {
|
2003-03-27 23:44:20 +00:00
|
|
|
{ 'F', "set_freq", set_freq, ARG_IN, "Frequency" },
|
|
|
|
{ 'f', "get_freq", get_freq, ARG_OUT, "Frequency" },
|
2002-08-22 23:44:50 +00:00
|
|
|
{ 'J', "set_rit", set_rit, ARG_IN, "RIT" },
|
|
|
|
{ 'j', "get_rit", get_rit, ARG_OUT, "RIT" },
|
2003-03-27 23:44:20 +00:00
|
|
|
{ 'M', "set_mode", set_mode, ARG_IN, "Mode", "Passband" },
|
|
|
|
{ 'm', "get_mode", get_mode, ARG_OUT, "Mode", "Passband" },
|
|
|
|
{ 'V', "set_vfo", set_vfo, ARG_IN|ARG_NOVFO, "VFO" },
|
2001-07-20 11:09:26 +00:00
|
|
|
{ 'v', "get_vfo", get_vfo, ARG_OUT, "VFO" },
|
|
|
|
{ 'T', "set_ptt", set_ptt, ARG_IN, "PTT" },
|
|
|
|
{ 't', "get_ptt", get_ptt, ARG_OUT, "PTT" },
|
|
|
|
{ 'R', "set_rptr_shift", set_rptr_shift, ARG_IN, "Rptr shift" },
|
|
|
|
{ 'r', "get_rptr_shift", get_rptr_shift, ARG_OUT, "Rptr shift" },
|
|
|
|
{ 'O', "set_rptr_offs", set_rptr_offs, ARG_IN, "Rptr offset" },
|
|
|
|
{ 'o', "get_rptr_offs", get_rptr_offs, ARG_OUT, "Rptr offset" },
|
|
|
|
{ 'C', "set_ctcss_tone", set_ctcss_tone, ARG_IN, "CTCSS tone" },
|
|
|
|
{ 'c', "get_ctcss_tone", get_ctcss_tone, ARG_OUT, "CTCSS tone" },
|
|
|
|
{ 'D', "set_dcs_code", set_dcs_code, ARG_IN, "DCS code" },
|
|
|
|
{ 'd', "get_dcs_code", get_dcs_code, ARG_OUT, "DCS code" },
|
|
|
|
{ 'I', "set_split_freq", set_split_freq, ARG_IN, "Tx frequency" },
|
|
|
|
{ 'i', "get_split_freq", get_split_freq, ARG_OUT, "Tx frequency" },
|
2001-12-20 07:51:02 +00:00
|
|
|
{ 'X', "set_split_mode", set_split_mode, ARG_IN, "Mode", "Passband" },
|
|
|
|
{ 'x', "get_split_mode", get_split_mode, ARG_OUT, "Mode", "Passband" },
|
2003-04-06 18:40:36 +00:00
|
|
|
{ 'S', "set_split_vfo", set_split_vfo, ARG_IN, "Split mode", "TxVFO" },
|
|
|
|
{ 's', "get_split_vfo", get_split_vfo, ARG_OUT, "Split mode", "TxVFO" },
|
2001-07-20 11:09:26 +00:00
|
|
|
{ 'N', "set_ts", set_ts, ARG_IN, "Tuning step" },
|
|
|
|
{ 'n', "get_ts", get_ts, ARG_OUT, "Tuning step" },
|
|
|
|
{ 'L', "set_level", set_level, ARG_IN, "Level", "Value" },
|
2001-09-22 11:49:19 +00:00
|
|
|
{ 'l', "get_level", get_level, ARG_IN1|ARG_OUT2, "Level", "Value" },
|
2001-07-20 11:09:26 +00:00
|
|
|
{ 'U', "set_func", set_func, ARG_IN, "Func", "Func status" },
|
2001-09-22 11:49:19 +00:00
|
|
|
{ 'u', "get_func", get_func, ARG_IN1|ARG_OUT2, "Func", "Func status" },
|
2003-03-27 23:44:20 +00:00
|
|
|
{ 'P', "set_parm", set_parm, ARG_IN|ARG_NOVFO, "Parm", "Value" },
|
|
|
|
{ 'p', "get_parm", get_parm, ARG_IN1|ARG_OUT2|ARG_NOVFO, "Parm", "Value" },
|
2001-07-20 11:09:26 +00:00
|
|
|
{ 'E', "set_mem", set_mem, ARG_IN, "Memory#" },
|
|
|
|
{ 'e', "get_mem", get_mem, ARG_OUT, "Memory#" },
|
|
|
|
{ 'G', "vfo_op", vfo_op, ARG_IN, "Mem/VFO op" },
|
|
|
|
{ 'g', "scan", scan, ARG_IN, "Scan fct", "Channel" },
|
2003-03-27 23:44:20 +00:00
|
|
|
{ 'H', "set_channel", set_channel, ARG_IN|ARG_NOVFO, /* FIXME */ },
|
|
|
|
{ 'h', "get_channel", get_channel, ARG_IN|ARG_NOVFO, "Channel" },
|
|
|
|
{ 'A', "set_trn", set_trn, ARG_IN|ARG_NOVFO, "Transceive" },
|
|
|
|
{ 'a', "get_trn", get_trn, ARG_OUT|ARG_NOVFO, "Transceive" },
|
2001-07-20 11:09:26 +00:00
|
|
|
{ 'B', "set_bank", set_bank, ARG_IN, "Bank" },
|
2003-03-27 23:44:20 +00:00
|
|
|
{ '_', "get_info", get_info, ARG_OUT|ARG_NOVFO, "Info" },
|
|
|
|
{ '2', "power2mW", power2mW, ARG_NOVFO },
|
|
|
|
{ '1', "dump_caps", dump_caps, ARG_NOVFO },
|
|
|
|
{ 'Z', "set_xit", set_xit, ARG_IN, "XIT" },
|
|
|
|
{ 'z', "get_xit", get_xit, ARG_OUT, "XIT" },
|
2002-11-28 22:25:46 +00:00
|
|
|
{ 0x83, "set_ant", set_ant, ARG_IN, "Antenna" },
|
|
|
|
{ 0x84, "get_ant", get_ant, ARG_OUT, "Antenna" },
|
2003-10-20 22:15:02 +00:00
|
|
|
{ 0x85, "reset", reset, ARG_IN, "Reset" },
|
2004-06-06 21:59:54 +00:00
|
|
|
{ 0x86, "send_morse", send_morse, ARG_IN, "Morse" },
|
|
|
|
{ 0x87, "set_powerstat", set_powerstat, ARG_IN|ARG_NOVFO, "Status" },
|
|
|
|
{ 0x88, "get_powerstat", get_powerstat, ARG_OUT|ARG_NOVFO, "Status" },
|
2000-10-29 16:35:29 +00:00
|
|
|
{ 0x00, "", NULL },
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
2003-03-27 23:44:20 +00:00
|
|
|
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:lC:LuovhV"
|
2001-07-20 11:09:26 +00:00
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
|
|
|
{"model", 1, 0, 'm'},
|
|
|
|
{"rig-file", 1, 0, 'r'},
|
|
|
|
{"ptt-file", 1, 0, 'p'},
|
|
|
|
{"dcd-file", 1, 0, 'd'},
|
|
|
|
{"ptt-type", 1, 0, 'P'},
|
|
|
|
{"dcd-type", 1, 0, 'D'},
|
2001-12-21 09:48:51 +00:00
|
|
|
{"serial-speed", 1, 0, 's'},
|
2001-09-22 11:49:19 +00:00
|
|
|
{"civaddr", 1, 0, 'c'},
|
2001-07-20 11:09:26 +00:00
|
|
|
{"list", 0, 0, 'l'},
|
2001-12-20 07:51:02 +00:00
|
|
|
{"set-conf", 1, 0, 'C'},
|
|
|
|
{"show-conf",0, 0, 'L'},
|
2002-09-06 14:07:17 +00:00
|
|
|
{"dump-caps", 0, 0, 'u'},
|
2003-03-27 23:44:20 +00:00
|
|
|
{"vfo", 0, 0, 'o'},
|
2001-07-20 11:09:26 +00:00
|
|
|
{"verbose", 0, 0, 'v'},
|
|
|
|
{"help", 0, 0, 'h'},
|
|
|
|
{"version", 0, 0, 'V'},
|
|
|
|
{0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
struct test_table *find_cmd_entry(int cmd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0; i<MAXNBOPT && test_list[i].cmd != 0x00; i++)
|
|
|
|
if (test_list[i].cmd == cmd)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i >= MAXNBOPT || test_list[i].cmd == 0x00)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return &test_list[i];
|
|
|
|
}
|
2001-07-20 11:09:26 +00:00
|
|
|
/*
|
|
|
|
* TODO: use Lex
|
|
|
|
*/
|
|
|
|
char parse_arg(const char *arg)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0; i<MAXNBOPT && test_list[i].cmd != 0; i++)
|
|
|
|
if (!strncmp(arg, test_list[i].name, MAXNAMSIZ))
|
|
|
|
return test_list[i].cmd;
|
|
|
|
return 0;
|
|
|
|
}
|
2001-02-25 23:14:19 +00:00
|
|
|
|
2003-05-03 13:17:25 +00:00
|
|
|
static int scanfc(const char *format, void *p)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
do {
|
|
|
|
ret = scanf(format, p);
|
|
|
|
if (ret < 0) {
|
|
|
|
if (errno != EINTR)
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "scanf: %s\n", strerror(errno));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
} while(1);
|
|
|
|
}
|
|
|
|
|
2001-12-20 07:51:02 +00:00
|
|
|
#define MAXCONFLEN 128
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
int main (int argc, char *argv[])
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
RIG *my_rig; /* handle to rig (nstance) */
|
2001-07-20 11:09:26 +00:00
|
|
|
rig_model_t my_model = RIG_MODEL_DUMMY;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
int interactive=1; /* if no cmd on command line, switch to interactive */
|
2000-10-29 16:35:29 +00:00
|
|
|
int retcode; /* generic return code from functions */
|
2002-09-06 14:07:17 +00:00
|
|
|
unsigned char cmd;
|
2001-02-25 23:14:19 +00:00
|
|
|
struct test_table *cmd_entry;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
int verbose = 0;
|
2003-03-27 23:44:20 +00:00
|
|
|
int vfo_mode = 0;
|
2001-12-20 07:51:02 +00:00
|
|
|
int show_conf = 0;
|
2002-09-06 14:07:17 +00:00
|
|
|
int dump_caps_opt = 0;
|
2001-07-20 11:09:26 +00:00
|
|
|
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;
|
2001-12-21 09:48:51 +00:00
|
|
|
int serial_rate = 0;
|
2001-09-22 11:49:19 +00:00
|
|
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
2001-12-20 07:51:02 +00:00
|
|
|
char conf_parms[MAXCONFLEN] = "";
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
while(1) {
|
|
|
|
int c;
|
|
|
|
int option_index = 0;
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
c = getopt_long (argc, argv, SHORT_OPTIONS,
|
2001-02-25 23:14:19 +00:00
|
|
|
long_options, &option_index);
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
switch(c) {
|
|
|
|
case 'h':
|
|
|
|
usage();
|
|
|
|
exit(0);
|
|
|
|
case 'V':
|
|
|
|
version();
|
|
|
|
exit(0);
|
|
|
|
case 'm':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
my_model = atoi(optarg);
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
rig_file = optarg;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ptt_file = optarg;
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
dcd_file = optarg;
|
|
|
|
break;
|
|
|
|
case 'P':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-08-22 23:44:50 +00:00
|
|
|
if (!strcmp(optarg, "RIG"))
|
|
|
|
ptt_type = RIG_PTT_RIG;
|
|
|
|
else if (!strcmp(optarg, "DTR"))
|
|
|
|
ptt_type = RIG_PTT_SERIAL_DTR;
|
|
|
|
else if (!strcmp(optarg, "RTS"))
|
|
|
|
ptt_type = RIG_PTT_SERIAL_RTS;
|
|
|
|
else if (!strcmp(optarg, "PARALLEL"))
|
|
|
|
ptt_type = RIG_PTT_PARALLEL;
|
|
|
|
else if (!strcmp(optarg, "NONE"))
|
|
|
|
ptt_type = RIG_PTT_NONE;
|
|
|
|
else
|
|
|
|
ptt_type = atoi(optarg);
|
2001-07-20 11:09:26 +00:00
|
|
|
break;
|
|
|
|
case 'D':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
2002-08-22 23:44:50 +00:00
|
|
|
if (!strcmp(optarg, "RIG"))
|
|
|
|
dcd_type = RIG_DCD_RIG;
|
|
|
|
else if (!strcmp(optarg, "DSR"))
|
|
|
|
dcd_type = RIG_DCD_SERIAL_DSR;
|
|
|
|
else if (!strcmp(optarg, "CTS"))
|
|
|
|
dcd_type = RIG_DCD_SERIAL_CTS;
|
2003-08-17 22:39:07 +00:00
|
|
|
else if (!strcmp(optarg, "CD"))
|
|
|
|
dcd_type = RIG_DCD_SERIAL_CAR;
|
2002-08-22 23:44:50 +00:00
|
|
|
else if (!strcmp(optarg, "PARALLEL"))
|
|
|
|
dcd_type = RIG_DCD_PARALLEL;
|
|
|
|
else if (!strcmp(optarg, "NONE"))
|
|
|
|
dcd_type = RIG_DCD_NONE;
|
|
|
|
else
|
|
|
|
dcd_type = atoi(optarg);
|
2001-07-20 11:09:26 +00:00
|
|
|
break;
|
2001-09-22 11:49:19 +00:00
|
|
|
case 'c':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
civaddr = optarg;
|
|
|
|
break;
|
2001-12-21 09:48:51 +00:00
|
|
|
case 's':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
serial_rate = atoi(optarg);
|
|
|
|
break;
|
2001-12-20 07:51:02 +00:00
|
|
|
case 'C':
|
|
|
|
if (!optarg) {
|
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (*conf_parms != '\0')
|
|
|
|
strcat(conf_parms, ",");
|
|
|
|
strncat(conf_parms, optarg, MAXCONFLEN-strlen(conf_parms));
|
|
|
|
break;
|
2003-03-27 23:44:20 +00:00
|
|
|
case 'o':
|
|
|
|
vfo_mode++;
|
|
|
|
break;
|
2001-07-20 11:09:26 +00:00
|
|
|
case 'v':
|
|
|
|
verbose++;
|
|
|
|
break;
|
2001-12-20 07:51:02 +00:00
|
|
|
case 'L':
|
|
|
|
show_conf++;
|
|
|
|
break;
|
2001-07-20 11:09:26 +00:00
|
|
|
case 'l':
|
|
|
|
list_models();
|
|
|
|
exit(0);
|
2002-09-06 14:07:17 +00:00
|
|
|
case 'u':
|
|
|
|
dump_caps_opt++;
|
|
|
|
break;
|
2001-07-20 11:09:26 +00:00
|
|
|
default:
|
|
|
|
usage(); /* unknown option? */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2002-01-27 23:58:24 +00:00
|
|
|
|
|
|
|
rig_set_debug(verbose<2 ? RIG_DEBUG_WARN: verbose);
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "rigctl, %s\n", hamlib_version);
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "Report bugs to "
|
|
|
|
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
2001-02-25 23:14:19 +00:00
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
/*
|
|
|
|
* at least one command on command line,
|
|
|
|
* disable interactive mode
|
|
|
|
*/
|
|
|
|
if (optind < argc)
|
2001-02-25 23:14:19 +00:00
|
|
|
interactive = 0;
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
my_rig = rig_init(my_model);
|
2001-02-25 23:14:19 +00:00
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
if (!my_rig) {
|
|
|
|
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",
|
|
|
|
my_model);
|
|
|
|
fprintf(stderr, "Please check with --list option.\n");
|
|
|
|
exit(2);
|
2001-02-25 23:14:19 +00:00
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-12-26 23:34:56 +00:00
|
|
|
retcode = set_conf(my_rig, conf_parms);
|
2001-12-20 07:51:02 +00:00
|
|
|
if (retcode != RIG_OK) {
|
|
|
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
if (rig_file)
|
2001-07-25 21:59:55 +00:00
|
|
|
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN);
|
2001-02-25 23:14:19 +00:00
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
/*
|
|
|
|
* ex: RIG_PTT_PARALLEL and /dev/parport0
|
|
|
|
*/
|
|
|
|
if (ptt_type != RIG_PTT_NONE)
|
|
|
|
my_rig->state.pttport.type.ptt = ptt_type;
|
|
|
|
if (dcd_type != RIG_DCD_NONE)
|
|
|
|
my_rig->state.dcdport.type.dcd = dcd_type;
|
|
|
|
if (ptt_file)
|
2001-07-25 21:59:55 +00:00
|
|
|
strncpy(my_rig->state.pttport.pathname, ptt_file, FILPATHLEN);
|
2001-07-20 11:09:26 +00:00
|
|
|
if (dcd_file)
|
2001-07-25 21:59:55 +00:00
|
|
|
strncpy(my_rig->state.dcdport.pathname, dcd_file, FILPATHLEN);
|
2001-12-21 09:48:51 +00:00
|
|
|
/* FIXME: bound checking and port type == serial */
|
|
|
|
if (serial_rate != 0)
|
|
|
|
my_rig->state.rigport.parm.serial.rate = serial_rate;
|
2001-09-22 11:49:19 +00:00
|
|
|
if (civaddr)
|
|
|
|
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
|
|
|
|
2001-12-20 07:51:02 +00:00
|
|
|
/*
|
|
|
|
* print out conf parameters
|
|
|
|
*/
|
|
|
|
if (show_conf) {
|
|
|
|
rig_token_foreach(my_rig, print_conf_list, (rig_ptr_t)my_rig);
|
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2002-09-06 14:07:17 +00:00
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2001-12-26 23:34:56 +00:00
|
|
|
retcode = rig_open(my_rig);
|
|
|
|
if (retcode != RIG_OK) {
|
2001-07-20 11:09:26 +00:00
|
|
|
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
|
|
|
exit(2);
|
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
if (verbose > 0)
|
|
|
|
printf("Opened rig model %d, '%s'\n", my_rig->caps->rig_model,
|
|
|
|
my_rig->caps->model_name);
|
2002-01-27 23:58:24 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "Backend version: %s, Status: %s\n",
|
2004-05-17 21:09:45 +00:00
|
|
|
my_rig->caps->version, rig_strstatus(my_rig->caps->status));
|
2001-07-20 11:09:26 +00:00
|
|
|
|
|
|
|
#define MAXARGSZ 127
|
|
|
|
while (1) {
|
|
|
|
char arg1[MAXARGSZ+1], *p1;
|
|
|
|
char arg2[MAXARGSZ+1], *p2;
|
|
|
|
char arg3[MAXARGSZ+1], *p3;
|
2001-09-22 11:49:19 +00:00
|
|
|
static int last_was_ret = 1;
|
2003-03-27 23:44:20 +00:00
|
|
|
vfo_t vfo = RIG_VFO_CURR;
|
2001-07-20 11:09:26 +00:00
|
|
|
|
|
|
|
if (interactive) {
|
|
|
|
printf("\nRig command: ");
|
2001-09-22 11:49:19 +00:00
|
|
|
|
|
|
|
do {
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%c", &cmd);
|
2002-09-06 10:43:59 +00:00
|
|
|
|
|
|
|
/* command by name */
|
|
|
|
if (cmd == '\\') {
|
2002-09-06 14:07:17 +00:00
|
|
|
unsigned char cmd_name[MAXNAMSIZ], *pcmd = cmd_name;
|
2002-09-06 10:43:59 +00:00
|
|
|
int c_len = MAXNAMSIZ;
|
|
|
|
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%c", pcmd);
|
2002-09-06 10:43:59 +00:00
|
|
|
while(c_len-- && (isalnum(*pcmd) || *pcmd == '_' ))
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%c", ++pcmd);
|
|
|
|
|
2002-09-06 10:43:59 +00:00
|
|
|
*pcmd = '\0';
|
|
|
|
cmd = parse_arg(cmd_name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-09-22 11:49:19 +00:00
|
|
|
if (cmd == 0x0a || cmd == 0x0d) {
|
|
|
|
if (last_was_ret) {
|
|
|
|
printf("? for help, q to quit.\n");
|
|
|
|
printf("\nRig command: ");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
last_was_ret = 1;
|
|
|
|
}
|
|
|
|
} while (cmd == 0x0a || cmd == 0x0d);
|
|
|
|
|
|
|
|
last_was_ret = 0;
|
2001-07-20 11:09:26 +00:00
|
|
|
|
2002-09-06 10:43:59 +00:00
|
|
|
/* comment line */
|
2002-06-26 20:44:37 +00:00
|
|
|
if (cmd == '#' || cmd == ';') {
|
|
|
|
while( cmd != '\n' && cmd != '\r')
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%c", &cmd);
|
2002-06-26 20:44:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2001-07-20 11:09:26 +00:00
|
|
|
if (cmd == 'Q' || cmd == 'q')
|
|
|
|
break;
|
|
|
|
if (cmd == '?') {
|
|
|
|
usage_rig();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* parse rest of command line */
|
|
|
|
if (optind >= argc)
|
|
|
|
break;
|
|
|
|
if (argv[optind][1] == '\0')
|
|
|
|
cmd = argv[optind][0];
|
|
|
|
else
|
|
|
|
cmd = parse_arg(argv[optind]);
|
|
|
|
optind++;
|
2001-02-07 23:53:30 +00:00
|
|
|
}
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
cmd_entry = find_cmd_entry(cmd);
|
|
|
|
if (!cmd_entry) {
|
2001-07-20 11:09:26 +00:00
|
|
|
fprintf(stderr, "Command '%c' not found!\n", cmd);
|
2001-02-25 23:14:19 +00:00
|
|
|
continue;
|
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
p1 = p2 = p3 = NULL;
|
2003-03-27 23:44:20 +00:00
|
|
|
if (!(cmd_entry->flags & ARG_NOVFO) && vfo_mode) {
|
|
|
|
if (interactive) {
|
|
|
|
printf("VFO: ");
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%s", arg1);
|
2004-05-17 21:09:45 +00:00
|
|
|
vfo = rig_parse_vfo(arg1);
|
2003-03-27 23:44:20 +00:00
|
|
|
} else {
|
|
|
|
if (!argv[optind]) {
|
|
|
|
fprintf(stderr, "Invalid arg for command '%s'\n",
|
|
|
|
cmd_entry->name);
|
|
|
|
exit(2);
|
|
|
|
}
|
2004-05-17 21:09:45 +00:00
|
|
|
vfo = rig_parse_vfo(argv[optind++]);
|
2003-03-27 23:44:20 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-22 11:49:19 +00:00
|
|
|
if ((cmd_entry->flags & ARG_IN1) && cmd_entry->arg1) {
|
|
|
|
if (interactive) {
|
|
|
|
printf("%s: ", cmd_entry->arg1);
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%s", arg1);
|
2001-09-22 11:49:19 +00:00
|
|
|
p1 = arg1;
|
|
|
|
} else {
|
|
|
|
if (!argv[optind]) {
|
|
|
|
fprintf(stderr, "Invalid arg for command '%s'\n",
|
|
|
|
cmd_entry->name);
|
|
|
|
exit(2);
|
2001-07-20 11:09:26 +00:00
|
|
|
}
|
2001-09-22 11:49:19 +00:00
|
|
|
p1 = argv[optind++];
|
2001-07-20 11:09:26 +00:00
|
|
|
}
|
2001-09-22 11:49:19 +00:00
|
|
|
}
|
|
|
|
if ((cmd_entry->flags & ARG_IN2) && cmd_entry->arg2) {
|
|
|
|
if (interactive) {
|
|
|
|
printf("%s: ", cmd_entry->arg2);
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%s", arg2);
|
2001-09-22 11:49:19 +00:00
|
|
|
p2 = arg2;
|
|
|
|
} else {
|
|
|
|
if (!argv[optind]) {
|
|
|
|
fprintf(stderr, "Invalid arg for command '%s'\n",
|
|
|
|
cmd_entry->name);
|
|
|
|
exit(2);
|
2001-07-20 11:09:26 +00:00
|
|
|
}
|
2001-09-22 11:49:19 +00:00
|
|
|
p2 = argv[optind++];
|
2001-07-20 11:09:26 +00:00
|
|
|
}
|
2001-09-22 11:49:19 +00:00
|
|
|
}
|
|
|
|
if ((cmd_entry->flags & ARG_IN3) && cmd_entry->arg3) {
|
|
|
|
if (interactive) {
|
|
|
|
printf("%s: ", cmd_entry->arg3);
|
2003-05-03 13:17:25 +00:00
|
|
|
scanfc("%s", arg3);
|
2001-09-22 11:49:19 +00:00
|
|
|
p3 = arg3;
|
|
|
|
} else {
|
|
|
|
if (!argv[optind]) {
|
|
|
|
fprintf(stderr, "Invalid arg for command '%s'\n",
|
|
|
|
cmd_entry->name);
|
|
|
|
exit(2);
|
2001-07-20 11:09:26 +00:00
|
|
|
}
|
2001-09-22 11:49:19 +00:00
|
|
|
p3 = argv[optind++];
|
2001-07-20 11:09:26 +00:00
|
|
|
}
|
2001-02-25 23:14:19 +00:00
|
|
|
}
|
2001-07-20 11:09:26 +00:00
|
|
|
retcode = (*cmd_entry->rig_routine)(my_rig, interactive,
|
2003-03-27 23:44:20 +00:00
|
|
|
cmd_entry, vfo, p1, p2, p3);
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
if (retcode != RIG_OK ) {
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: error = %s\n", cmd_entry->name, rigerror(retcode));
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_close(my_rig); /* close port */
|
|
|
|
rig_cleanup(my_rig); /* if you care about memory */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
|
|
|
|
void version()
|
|
|
|
{
|
|
|
|
printf("rigctl, %s\n\n", hamlib_version);
|
|
|
|
printf("%s\n", hamlib_copyright);
|
|
|
|
}
|
|
|
|
|
|
|
|
void usage_rig()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2001-09-22 11:49:19 +00:00
|
|
|
printf("Commands (may not be available for this rig):\n");
|
2001-07-20 11:09:26 +00:00
|
|
|
for (i=0; test_list[i].cmd != 0; i++) {
|
2002-10-07 21:50:54 +00:00
|
|
|
printf("%c: %-16s(", isprint(test_list[i].cmd)?test_list[i].cmd:'?', test_list[i].name);
|
2004-10-02 10:33:21 +00:00
|
|
|
if (test_list[i].arg1 && (test_list[i].flags&ARG_IN1))
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s", test_list[i].arg1);
|
2004-10-02 10:33:21 +00:00
|
|
|
if (test_list[i].arg2 && (test_list[i].flags&ARG_IN2))
|
2001-07-20 11:09:26 +00:00
|
|
|
printf(",%s", test_list[i].arg2);
|
2004-10-02 10:33:21 +00:00
|
|
|
if (test_list[i].arg3 && (test_list[i].flags&ARG_IN3))
|
2001-07-20 11:09:26 +00:00
|
|
|
printf(",%s", test_list[i].arg3);
|
|
|
|
printf(") \t");
|
|
|
|
|
|
|
|
if (i%2)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
void usage()
|
|
|
|
{
|
|
|
|
printf("Usage: rigctl [OPTION]... [COMMAND]...\n"
|
|
|
|
"Send COMMANDs to a connected radio transceiver or receiver.\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
printf(
|
|
|
|
" -m, --model=ID select radio model number. See model list\n"
|
|
|
|
" -r, --rig-file=DEVICE set device of the radio to operate on\n"
|
|
|
|
" -p, --ptt-file=DEVICE set device of the PTT device to operate on\n"
|
|
|
|
" -d, --dcd-file=DEVICE set device of the DCD device to operate on\n"
|
|
|
|
" -P, --ptt-type=TYPE set type of the PTT device to operate on\n"
|
|
|
|
" -D, --dcd-type=TYPE set type of the DCD device to operate on\n"
|
2001-12-21 09:48:51 +00:00
|
|
|
" -s, --serial-speed=BAUD set serial speed of the serial port\n"
|
2002-01-27 23:58:24 +00:00
|
|
|
" -c, --civaddr=ID set CI-V address, decimal (for Icom rigs only)\n"
|
2001-12-20 07:51:02 +00:00
|
|
|
" -C, --set-conf=PARM=VAL set config parameters\n"
|
|
|
|
" -L, --show-conf list all config parameters\n"
|
2001-07-20 11:09:26 +00:00
|
|
|
" -l, --list list all model numbers and exit\n"
|
2002-09-06 14:07:17 +00:00
|
|
|
" -u, --dump-caps dump capabilities and exit\n"
|
2003-03-27 23:44:20 +00:00
|
|
|
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
|
2001-07-20 11:09:26 +00:00
|
|
|
" -v, --verbose set verbose mode, cumulative\n"
|
|
|
|
" -h, --help display this help and exit\n"
|
|
|
|
" -V, --version output version information and exit\n\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
usage_rig();
|
|
|
|
|
|
|
|
printf("\nReport bugs to <hamlib-developer@lists.sourceforge.net>.\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-12-20 07:51:02 +00:00
|
|
|
static int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
|
|
|
{
|
|
|
|
RIG *rig = (RIG*) data;
|
|
|
|
int i;
|
|
|
|
char buf[128] = "";
|
|
|
|
|
|
|
|
rig_get_conf(rig, cfp->token, buf);
|
|
|
|
printf("%s: \"%s\"\n" "\t"
|
|
|
|
"Default: %s, Value: %s\n",
|
|
|
|
cfp->name, cfp->tooltip,
|
|
|
|
cfp->dflt, buf );
|
|
|
|
|
|
|
|
switch (cfp->type) {
|
|
|
|
case RIG_CONF_NUMERIC:
|
|
|
|
printf("\tRange: %.1f..%.1f, step %.1f\n",
|
|
|
|
cfp->u.n.min, cfp->u.n.max, cfp->u.n.step);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_COMBO:
|
|
|
|
if (!cfp->u.c.combostr)
|
|
|
|
break;
|
|
|
|
printf("\tCombo: %s", cfp->u.c.combostr[0]);
|
|
|
|
for (i=1 ; i<RIG_COMBO_MAX && cfp->u.c.combostr[i]; i++)
|
|
|
|
printf(", %s", cfp->u.c.combostr[i]);
|
|
|
|
printf("\n");
|
|
|
|
break;
|
2003-10-20 22:15:02 +00:00
|
|
|
case RIG_CONF_STRING:
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("\tString.\n");
|
2003-10-20 22:15:02 +00:00
|
|
|
break;
|
|
|
|
case RIG_CONF_CHECKBUTTON:
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("\tCheck button.\n");
|
2003-10-20 22:15:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("\tUnkown conf\n");
|
2001-12-20 07:51:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1; /* !=0, we want them all ! */
|
|
|
|
}
|
|
|
|
|
2001-07-20 11:09:26 +00:00
|
|
|
static int print_model_list(const struct rig_caps *caps, void *data)
|
|
|
|
{
|
2004-02-08 20:25:36 +00:00
|
|
|
printf("%d\t%-16s%-24s%-8s%s\n", caps->rig_model, caps->mfg_name,
|
2004-05-17 21:09:45 +00:00
|
|
|
caps->model_name, caps->version, rig_strstatus(caps->status));
|
2001-07-20 11:09:26 +00:00
|
|
|
return 1; /* !=0, we want them all ! */
|
|
|
|
}
|
|
|
|
|
|
|
|
void list_models()
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
rig_load_all_backends();
|
|
|
|
|
2004-02-08 20:25:36 +00:00
|
|
|
printf("Rig#\tMfg Model Vers. Status\n");
|
2001-07-20 11:09:26 +00:00
|
|
|
status = rig_list_foreach(print_model_list, NULL);
|
|
|
|
if (status != RIG_OK ) {
|
|
|
|
printf("rig_list_foreach: error = %s \n", rigerror(status));
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 07:51:02 +00:00
|
|
|
int set_conf(RIG *my_rig, char *conf_parms)
|
|
|
|
{
|
|
|
|
char *p, *q, *n;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
p = conf_parms;
|
|
|
|
while (p && *p != '\0') {
|
|
|
|
/* FIXME: left hand value of = cannot be null */
|
|
|
|
q = strchr(p, '=');
|
|
|
|
if (q) *q++ = '\0';
|
|
|
|
n = strchr(q, ',');
|
|
|
|
if (n) *n++ = '\0';
|
|
|
|
|
|
|
|
ret = rig_set_conf(my_rig, rig_token_lookup(my_rig, p), q);
|
|
|
|
if (ret != RIG_OK)
|
|
|
|
return ret;
|
|
|
|
p = n;
|
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
/*
|
|
|
|
* static int (f)(RIG *rig, int interactive, const void *arg1, const void *arg2, const void *arg3, const void *arg4)
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare_proto_rig(set_freq)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
freq_t freq;
|
|
|
|
|
2005-01-24 23:04:35 +00:00
|
|
|
sscanf(arg1, "%"SCNfreq, &freq);
|
2003-03-24 12:18:42 +00:00
|
|
|
return rig_set_freq(rig, vfo, freq);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_freq)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
freq_t freq;
|
|
|
|
|
2003-03-24 12:18:42 +00:00
|
|
|
status = rig_get_freq(rig, vfo, &freq);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2003-03-27 23:44:20 +00:00
|
|
|
printf("%s: ", cmd->arg1); /* i.e. "Frequency" */
|
2005-01-25 00:22:14 +00:00
|
|
|
printf("%"PRIll"\n", (long long)freq);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2002-08-19 22:17:11 +00:00
|
|
|
declare_proto_rig(set_rit)
|
|
|
|
{
|
|
|
|
shortfreq_t rit;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
sscanf(arg1, "%ld", &rit);
|
|
|
|
return rig_set_rit(rig, vfo, rit);
|
2002-08-19 22:17:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare_proto_rig(get_rit)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
shortfreq_t rit;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_rit(rig, vfo, &rit);
|
2002-08-19 22:17:11 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg1);
|
|
|
|
printf("%ld\n", rit);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2002-11-28 22:25:46 +00:00
|
|
|
declare_proto_rig(set_xit)
|
|
|
|
{
|
|
|
|
shortfreq_t xit;
|
|
|
|
|
|
|
|
sscanf(arg1, "%ld", &xit);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_xit(rig, vfo, xit);
|
2002-11-28 22:25:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare_proto_rig(get_xit)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
shortfreq_t xit;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_xit(rig, vfo, &xit);
|
2002-11-28 22:25:46 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg1);
|
|
|
|
printf("%ld\n", xit);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2002-08-19 22:17:11 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_mode)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
rmode_t mode;
|
2000-12-04 23:39:18 +00:00
|
|
|
pbwidth_t width;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
mode = rig_parse_mode(arg1);
|
2003-11-16 17:34:00 +00:00
|
|
|
sscanf(arg2, "%ld", &width);
|
2003-03-24 12:18:42 +00:00
|
|
|
return rig_set_mode(rig, vfo, mode, width);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_mode)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
2000-12-04 23:39:18 +00:00
|
|
|
rmode_t mode;
|
2003-03-27 23:44:20 +00:00
|
|
|
pbwidth_t width;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2003-03-24 12:18:42 +00:00
|
|
|
status = rig_get_mode(rig, vfo, &mode, &width);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2003-03-27 23:44:20 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("%s\n", rig_strrmode(mode));
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2003-03-27 23:44:20 +00:00
|
|
|
printf("%s: ", cmd->arg2);
|
2002-01-22 00:56:13 +00:00
|
|
|
printf("%ld\n", width);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_vfo)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2004-05-17 21:09:45 +00:00
|
|
|
return rig_set_vfo(rig, rig_parse_vfo(arg1));
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_vfo)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = rig_get_vfo(rig, &vfo);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("%s\n", rig_strvfo(vfo));
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_ptt)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
ptt_t ptt;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", (int*)&ptt);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_ptt(rig, vfo, ptt);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_ptt)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
ptt_t ptt;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_ptt(rig, vfo, &ptt);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%d\n", ptt);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_rptr_shift)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
rptr_shift_t rptr_shift;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
rptr_shift = rig_parse_rptr_shift(arg1);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_rptr_shift(rig, vfo, rptr_shift);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_rptr_shift)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
rptr_shift_t rptr_shift;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_rptr_shift(rig, vfo, &rptr_shift);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("%s\n", rig_strptrshift(rptr_shift));
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_rptr_offs)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
unsigned long rptr_offs;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%ld", &rptr_offs);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_rptr_offs(rig, vfo, rptr_offs);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_rptr_offs)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
unsigned long rptr_offs;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_rptr_offs(rig, vfo, &rptr_offs);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%ld\n", rptr_offs);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-01 11:46:17 +00:00
|
|
|
declare_proto_rig(set_ctcss_tone)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-07-01 11:46:17 +00:00
|
|
|
tone_t tone;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &tone);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_ctcss_tone(rig, vfo, tone);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-01 11:46:17 +00:00
|
|
|
declare_proto_rig(get_ctcss_tone)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
2001-07-01 11:46:17 +00:00
|
|
|
tone_t tone;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_ctcss_tone(rig, vfo, &tone);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%d\n", tone);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-01 11:46:17 +00:00
|
|
|
declare_proto_rig(set_dcs_code)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-07-01 11:46:17 +00:00
|
|
|
tone_t code;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &code);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_dcs_code(rig, vfo, code);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-01 11:46:17 +00:00
|
|
|
declare_proto_rig(get_dcs_code)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
2001-07-01 11:46:17 +00:00
|
|
|
tone_t code;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_dcs_code(rig, vfo, &code);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%d\n", code);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_split_freq)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-06-27 17:32:47 +00:00
|
|
|
freq_t txfreq;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2005-01-24 23:04:35 +00:00
|
|
|
sscanf(arg1, "%"SCNfreq, &txfreq);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_split_freq(rig, vfo, txfreq);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_split_freq)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
2001-06-27 17:32:47 +00:00
|
|
|
freq_t txfreq;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_split_freq(rig, vfo, &txfreq);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2005-01-25 00:22:14 +00:00
|
|
|
printf("%"PRIll"\n", (long long)txfreq);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2001-12-20 07:51:02 +00:00
|
|
|
declare_proto_rig(set_split_mode)
|
|
|
|
{
|
|
|
|
rmode_t mode;
|
|
|
|
pbwidth_t width;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
mode = rig_parse_mode(arg1);
|
2001-12-20 07:51:02 +00:00
|
|
|
sscanf(arg2, "%d", (int*)&width);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_split_mode(rig, vfo, mode, width);
|
2001-12-20 07:51:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
declare_proto_rig(get_split_mode)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
rmode_t mode;
|
|
|
|
pbwidth_t width;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_split_mode(rig, vfo, &mode, &width);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-12-20 07:51:02 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg1);
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("%s\n", rig_strrmode(mode));
|
2001-12-20 07:51:02 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg2);
|
2002-01-22 00:56:13 +00:00
|
|
|
printf("%ld\n", width);
|
2001-12-20 07:51:02 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2003-04-06 18:40:36 +00:00
|
|
|
declare_proto_rig(set_split_vfo)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
split_t split;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", (int*)&split);
|
2004-05-17 21:09:45 +00:00
|
|
|
return rig_set_split_vfo(rig, vfo, split, rig_parse_vfo(arg2));
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-06 18:40:36 +00:00
|
|
|
declare_proto_rig(get_split_vfo)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
split_t split;
|
2003-04-06 18:40:36 +00:00
|
|
|
vfo_t tx_vfo;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2003-04-06 18:40:36 +00:00
|
|
|
status = rig_get_split_vfo(rig, vfo, &split, &tx_vfo);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%d\n", split);
|
2003-04-06 18:40:36 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg2);
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("%s\n", rig_strvfo(tx_vfo));
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_ts)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
unsigned long ts;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%ld", &ts);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_ts(rig, vfo, ts);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_ts)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
unsigned long ts;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_ts(rig, vfo, &ts);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%ld\n", ts);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(power2mW)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
float power;
|
|
|
|
freq_t freq;
|
|
|
|
rmode_t mode;
|
|
|
|
unsigned int mwp;
|
|
|
|
|
|
|
|
printf("Power [0.0 .. 1.0]: ");
|
|
|
|
scanf("%f", &power);
|
|
|
|
printf("Frequency: ");
|
2005-01-24 23:04:35 +00:00
|
|
|
scanf("%"SCNfreq, &freq);
|
2000-10-29 16:35:29 +00:00
|
|
|
printf("Mode: ");
|
|
|
|
scanf("%d", &mode);
|
|
|
|
status = rig_power2mW(rig, &mwp, power, freq, mode);
|
|
|
|
printf("Power: %d mW\n", mwp);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2002-07-09 20:40:28 +00:00
|
|
|
/*
|
|
|
|
* RIG_CONF_ extparm's type:
|
|
|
|
* NUMERIC: val.f
|
|
|
|
* COMBO: val.i, starting from 0
|
|
|
|
* STRING: val.s
|
|
|
|
* CHECKBUTTON: val.i 0/1
|
|
|
|
*/
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_level)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-02-11 23:22:06 +00:00
|
|
|
setting_t level;
|
|
|
|
value_t val;
|
2001-02-25 23:14:19 +00:00
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
level = rig_parse_level(arg1);
|
2002-07-09 20:40:28 +00:00
|
|
|
if (!rig_has_set_level(rig, level)) {
|
|
|
|
const struct confparams *cfp;
|
|
|
|
|
|
|
|
cfp = rig_ext_lookup(rig, arg1);
|
|
|
|
if (!cfp)
|
|
|
|
return -RIG_EINVAL; /* no such parameter */
|
|
|
|
|
|
|
|
switch (cfp->type) {
|
|
|
|
case RIG_CONF_CHECKBUTTON:
|
|
|
|
case RIG_CONF_COMBO:
|
|
|
|
sscanf(arg2, "%d", &val.i);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_NUMERIC:
|
|
|
|
sscanf(arg2, "%f", &val.f);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_STRING:
|
2002-10-07 21:50:54 +00:00
|
|
|
val.cs = arg2;
|
2002-07-09 20:40:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -RIG_ECONF;
|
|
|
|
}
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_ext_level(rig, vfo, cfp->token, val);
|
2002-07-09 20:40:28 +00:00
|
|
|
}
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
sscanf(arg2, "%f", &val.f);
|
2001-02-11 23:22:06 +00:00
|
|
|
else
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg2, "%d", &val.i);
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_level(rig, vfo, level, val);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_level)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-02-11 23:22:06 +00:00
|
|
|
int status;
|
|
|
|
setting_t level;
|
|
|
|
value_t val;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
level = rig_parse_level(arg1);
|
2002-07-09 20:40:28 +00:00
|
|
|
if (!rig_has_get_level(rig, level)) {
|
|
|
|
const struct confparams *cfp;
|
|
|
|
|
|
|
|
cfp = rig_ext_lookup(rig, arg1);
|
|
|
|
if (!cfp)
|
|
|
|
return -RIG_EINVAL; /* no such parameter */
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_ext_level(rig, vfo, cfp->token, &val);
|
2002-07-09 20:40:28 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg2);
|
|
|
|
|
|
|
|
switch (cfp->type) {
|
|
|
|
case RIG_CONF_CHECKBUTTON:
|
|
|
|
case RIG_CONF_COMBO:
|
|
|
|
printf("%d\n", val.i);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_NUMERIC:
|
|
|
|
printf("%f\n", val.f);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_STRING:
|
|
|
|
printf("%s\n", val.s);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -RIG_ECONF;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_level(rig, vfo, level, &val);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg2);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
printf("%f\n", val.f);
|
|
|
|
else
|
|
|
|
printf("%d\n", val.i);
|
2001-02-11 23:22:06 +00:00
|
|
|
return status;
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_func)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-02-11 23:22:06 +00:00
|
|
|
setting_t func;
|
|
|
|
int func_stat;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
func = rig_parse_func(arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg2, "%d", (int*)&func_stat);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_func(rig, vfo, func, func_stat);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_func)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-02-11 23:22:06 +00:00
|
|
|
int status;
|
|
|
|
setting_t func;
|
|
|
|
int func_stat;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
func = rig_parse_func(arg1);
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_func(rig, vfo, func, &func_stat);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg2);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%d\n", func_stat);
|
2001-02-11 23:22:06 +00:00
|
|
|
return status;
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
2001-12-20 07:51:02 +00:00
|
|
|
declare_proto_rig(set_parm)
|
|
|
|
{
|
|
|
|
setting_t parm;
|
|
|
|
value_t val;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
parm = rig_parse_parm(arg1);
|
2002-07-09 20:40:28 +00:00
|
|
|
|
|
|
|
if (!rig_has_set_parm(rig, parm)) {
|
|
|
|
const struct confparams *cfp;
|
|
|
|
|
|
|
|
cfp = rig_ext_lookup(rig, arg1);
|
|
|
|
if (!cfp)
|
|
|
|
return -RIG_EINVAL; /* no such parameter */
|
|
|
|
|
|
|
|
switch (cfp->type) {
|
|
|
|
case RIG_CONF_CHECKBUTTON:
|
|
|
|
case RIG_CONF_COMBO:
|
|
|
|
sscanf(arg2, "%d", &val.i);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_NUMERIC:
|
|
|
|
sscanf(arg2, "%f", &val.f);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_STRING:
|
2002-10-07 21:50:54 +00:00
|
|
|
val.cs = arg2;
|
2002-07-09 20:40:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -RIG_ECONF;
|
|
|
|
}
|
|
|
|
return rig_set_ext_parm(rig, cfp->token, val);
|
|
|
|
}
|
|
|
|
|
2002-01-22 00:56:13 +00:00
|
|
|
if (RIG_PARM_IS_FLOAT(parm))
|
2001-12-20 07:51:02 +00:00
|
|
|
sscanf(arg2, "%f", &val.f);
|
|
|
|
else
|
|
|
|
sscanf(arg2, "%d", &val.i);
|
|
|
|
|
|
|
|
return rig_set_parm(rig, parm, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
declare_proto_rig(get_parm)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
setting_t parm;
|
|
|
|
value_t val;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
parm = rig_parse_parm(arg1);
|
2002-07-09 20:40:28 +00:00
|
|
|
if (!rig_has_get_parm(rig, parm)) {
|
|
|
|
const struct confparams *cfp;
|
|
|
|
|
|
|
|
cfp = rig_ext_lookup(rig, arg1);
|
|
|
|
if (!cfp)
|
|
|
|
return -RIG_EINVAL; /* no such parameter */
|
|
|
|
|
|
|
|
status = rig_get_ext_parm(rig, cfp->token, &val);
|
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg2);
|
|
|
|
|
|
|
|
switch (cfp->type) {
|
|
|
|
case RIG_CONF_CHECKBUTTON:
|
|
|
|
case RIG_CONF_COMBO:
|
|
|
|
printf("%d\n", val.i);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_NUMERIC:
|
|
|
|
printf("%f\n", val.f);
|
|
|
|
break;
|
|
|
|
case RIG_CONF_STRING:
|
|
|
|
printf("%s\n", val.s);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -RIG_ECONF;
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2001-12-20 07:51:02 +00:00
|
|
|
status = rig_get_parm(rig, parm, &val);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-12-20 07:51:02 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg2);
|
2002-01-22 00:56:13 +00:00
|
|
|
if (RIG_PARM_IS_FLOAT(parm))
|
2001-12-20 07:51:02 +00:00
|
|
|
printf("%f\n", val.f);
|
|
|
|
else
|
|
|
|
printf("%d\n", val.i);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_bank)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int bank;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &bank);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_bank(rig, vfo, bank);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_mem)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &ch);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_mem(rig, vfo, ch);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_mem)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
int ch;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_mem(rig, vfo, &ch);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-07-20 11:09:26 +00:00
|
|
|
printf("%s: ", cmd->arg1);
|
2001-02-25 23:14:19 +00:00
|
|
|
printf("%d\n", ch);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2001-06-03 19:54:05 +00:00
|
|
|
declare_proto_rig(vfo_op)
|
|
|
|
{
|
|
|
|
vfo_op_t op;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
op = rig_parse_vfo_op(arg1);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_vfo_op(rig, vfo, op);
|
2001-06-03 19:54:05 +00:00
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-06-26 20:55:29 +00:00
|
|
|
declare_proto_rig(scan)
|
|
|
|
{
|
|
|
|
scan_t op;
|
|
|
|
int ch;
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
op = rig_parse_scan(arg1);
|
2001-06-26 20:55:29 +00:00
|
|
|
sscanf(arg2, "%d", &ch);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_scan(rig, vfo, op, ch);
|
2001-06-26 20:55:29 +00:00
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_channel)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2002-01-27 23:58:24 +00:00
|
|
|
fprintf(stderr,"rigctl set_channel not implemented yet!\n");
|
2001-07-20 11:09:26 +00:00
|
|
|
return -RIG_ENIMPL;
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_channel)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2001-03-01 21:25:45 +00:00
|
|
|
int status;
|
|
|
|
channel_t chan;
|
|
|
|
|
2002-10-07 21:50:54 +00:00
|
|
|
if (isdigit(arg1[0])) {
|
|
|
|
chan.vfo = RIG_VFO_MEM;
|
2002-07-10 21:34:53 +00:00
|
|
|
if (sscanf(arg1, "%d", &chan.channel_num) != 1)
|
|
|
|
return -RIG_EINVAL;
|
2002-10-07 21:50:54 +00:00
|
|
|
} else {
|
2004-05-17 21:09:45 +00:00
|
|
|
chan.vfo = rig_parse_vfo(arg1);
|
2002-07-10 21:34:53 +00:00
|
|
|
chan.channel_num = 0;
|
2002-10-07 21:50:54 +00:00
|
|
|
}
|
2002-07-10 21:34:53 +00:00
|
|
|
|
2001-03-01 21:25:45 +00:00
|
|
|
status = rig_get_channel(rig, &chan);
|
2001-12-26 23:34:56 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
2002-01-27 23:58:24 +00:00
|
|
|
dump_chan(rig, &chan);
|
2001-03-01 21:25:45 +00:00
|
|
|
return status;
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
2002-08-22 23:44:50 +00:00
|
|
|
static int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
|
|
|
{
|
2005-01-25 00:22:14 +00:00
|
|
|
printf("Event: freq changed to %"PRIll"Hz on %s\n", (long long)freq, rig_strvfo(vfo));
|
2002-08-22 23:44:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mymode_event(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width, rig_ptr_t arg)
|
|
|
|
{
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("Event: mode changed to %s, width %liHz on %s\n", rig_strrmode(mode),
|
|
|
|
width, rig_strvfo(vfo));
|
2002-08-22 23:44:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int myvfo_event(RIG *rig, vfo_t vfo, rig_ptr_t arg)
|
|
|
|
{
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("Event: vfo changed to %s\n", rig_strvfo(vfo));
|
2002-08-22 23:44:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int myptt_event(RIG *rig, vfo_t vfo, ptt_t ptt, rig_ptr_t arg)
|
|
|
|
{
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("Event: PTT changed to %i on %s\n", ptt, rig_strvfo(vfo));
|
2002-08-22 23:44:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mydcd_event(RIG *rig, vfo_t vfo, dcd_t dcd, rig_ptr_t arg)
|
|
|
|
{
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("Event: DCD changed to %i on %s\n", dcd, rig_strvfo(vfo));
|
2002-08-22 23:44:50 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_trn)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2002-08-22 23:44:50 +00:00
|
|
|
int trn;
|
|
|
|
|
2003-05-03 13:17:25 +00:00
|
|
|
if (!strcmp(arg1, "OFF"))
|
|
|
|
trn = RIG_TRN_OFF;
|
|
|
|
else if (!strcmp(arg1, "RIG") || !strcmp(arg1, "ON"))
|
|
|
|
trn = RIG_TRN_RIG;
|
|
|
|
else if (!strcmp(arg1, "POLL"))
|
|
|
|
trn = RIG_TRN_POLL;
|
|
|
|
else
|
|
|
|
return -RIG_EINVAL;
|
2002-08-22 23:44:50 +00:00
|
|
|
|
|
|
|
if (trn != RIG_TRN_OFF) {
|
|
|
|
rig_set_freq_callback(rig, myfreq_event, NULL);
|
|
|
|
rig_set_mode_callback(rig, mymode_event, NULL);
|
|
|
|
rig_set_vfo_callback (rig, myvfo_event, NULL);
|
|
|
|
rig_set_ptt_callback (rig, myptt_event, NULL);
|
|
|
|
rig_set_dcd_callback (rig, mydcd_event, NULL);
|
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2002-08-22 23:44:50 +00:00
|
|
|
return rig_set_trn(rig, trn);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_trn)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
2003-05-03 13:17:25 +00:00
|
|
|
int status;
|
|
|
|
int trn;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2003-05-03 13:17:25 +00:00
|
|
|
status = rig_get_trn(rig, &trn);
|
|
|
|
if (status != RIG_OK)
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
2003-05-03 13:17:25 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg1);
|
|
|
|
printf("%d\n", trn);
|
|
|
|
return status;
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
2002-01-09 23:09:10 +00:00
|
|
|
declare_proto_rig(get_info)
|
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
|
|
|
|
s = rig_get_info(rig);
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg1);
|
|
|
|
printf("%s\n", s ? s : "None");
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-27 23:58:24 +00:00
|
|
|
|
|
|
|
void dump_chan(RIG *rig, channel_t *chan)
|
|
|
|
{
|
|
|
|
int idx, firstloop=1;
|
|
|
|
char freqbuf[16];
|
|
|
|
char widthbuf[16];
|
|
|
|
char prntbuf[256];
|
|
|
|
|
|
|
|
printf("Channel: %d, Name: '%s'\n", chan->channel_num,
|
|
|
|
chan->channel_desc);
|
|
|
|
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("VFO: %s, Antenna: %d, Split: %s\n", rig_strvfo(chan->vfo),
|
2002-01-27 23:58:24 +00:00
|
|
|
chan->ant, chan->split==RIG_SPLIT_ON?"ON":"OFF");
|
|
|
|
|
|
|
|
sprintf_freq(freqbuf, chan->freq);
|
|
|
|
sprintf_freq(widthbuf, chan->width);
|
|
|
|
printf("Freq: %s\tMode: %s\tWidth: %s\n",
|
2004-05-17 21:09:45 +00:00
|
|
|
freqbuf, rig_strrmode(chan->mode), widthbuf);
|
2002-01-27 23:58:24 +00:00
|
|
|
|
|
|
|
sprintf_freq(freqbuf, chan->tx_freq);
|
|
|
|
sprintf_freq(widthbuf, chan->tx_width);
|
|
|
|
printf("txFreq: %s\ttxMode: %s\ttxWidth: %s\n",
|
2004-05-17 21:09:45 +00:00
|
|
|
freqbuf, rig_strrmode(chan->tx_mode), widthbuf);
|
2002-01-27 23:58:24 +00:00
|
|
|
|
|
|
|
sprintf_freq(freqbuf,chan->rptr_offs);
|
2004-05-17 21:09:45 +00:00
|
|
|
printf("Shift: %s, Offset: %s%s, ", rig_strptrshift(chan->rptr_shift),
|
2002-01-27 23:58:24 +00:00
|
|
|
chan->rptr_offs>0?"+":"", freqbuf);
|
|
|
|
|
|
|
|
sprintf_freq(freqbuf,chan->tuning_step);
|
|
|
|
printf("Step: %s, ", freqbuf);
|
|
|
|
sprintf_freq(freqbuf,chan->rit);
|
|
|
|
printf("RIT: %s%s, ", chan->rit>0?"+":"", freqbuf);
|
|
|
|
sprintf_freq(freqbuf,chan->xit);
|
|
|
|
printf("XIT: %s%s\n", chan->xit>0?"+":"", freqbuf);
|
|
|
|
|
|
|
|
printf("CTCSS: %d.%dHz, ", chan->ctcss_tone/10, chan->ctcss_tone%10);
|
|
|
|
printf("CTCSSsql: %d.%dHz, ", chan->ctcss_sql/10, chan->ctcss_sql%10);
|
|
|
|
printf("DCS: %d.%d, ", chan->dcs_code/10, chan->dcs_code%10);
|
|
|
|
printf("DCSsql: %d.%d\n", chan->dcs_sql/10, chan->dcs_sql%10);
|
|
|
|
|
|
|
|
sprintf_func(prntbuf, chan->funcs);
|
|
|
|
printf("Functions: %s\n", prntbuf);
|
|
|
|
|
|
|
|
printf("Levels:");
|
|
|
|
for (idx=0; idx<60; idx++) {
|
|
|
|
setting_t level = rig_idx2setting(idx);
|
|
|
|
const char *level_s;
|
|
|
|
|
|
|
|
if (!rig_has_set_level(rig, level))
|
|
|
|
continue;
|
2004-05-17 21:09:45 +00:00
|
|
|
level_s = rig_strlevel(level);
|
2002-01-27 23:58:24 +00:00
|
|
|
if (!level_s)
|
|
|
|
continue; /* duh! */
|
|
|
|
if (firstloop)
|
|
|
|
firstloop = 0;
|
|
|
|
else
|
|
|
|
printf(",\t");
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
printf(" %s: %g%%", level_s, 100*chan->levels[idx].f);
|
|
|
|
else
|
|
|
|
printf(" %s: %d", level_s, chan->levels[idx].i);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2002-09-06 14:07:17 +00:00
|
|
|
declare_proto_rig(dump_caps)
|
|
|
|
{
|
|
|
|
dumpcaps(rig);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2002-11-28 22:25:46 +00:00
|
|
|
declare_proto_rig(set_ant)
|
|
|
|
{
|
|
|
|
ant_t ant;
|
|
|
|
|
|
|
|
sscanf(arg1, "%d", &ant);
|
2003-03-27 23:44:20 +00:00
|
|
|
return rig_set_ant(rig, vfo, rig_idx2setting(ant));
|
2002-11-28 22:25:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
declare_proto_rig(get_ant)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
ant_t ant;
|
|
|
|
|
2003-03-27 23:44:20 +00:00
|
|
|
status = rig_get_ant(rig, vfo, &ant);
|
2002-11-28 22:25:46 +00:00
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg1);
|
|
|
|
printf("%d\n", rig_setting2idx(ant));
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2003-10-20 22:15:02 +00:00
|
|
|
declare_proto_rig(reset)
|
|
|
|
{
|
|
|
|
reset_t reset;
|
|
|
|
|
|
|
|
sscanf(arg1, "%d", &reset);
|
|
|
|
return rig_reset(rig, reset);
|
|
|
|
}
|
|
|
|
|
2004-06-06 21:59:54 +00:00
|
|
|
declare_proto_rig(send_morse)
|
|
|
|
{
|
|
|
|
return rig_send_morse(rig, vfo, arg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
declare_proto_rig(set_powerstat)
|
|
|
|
{
|
|
|
|
powerstat_t stat;
|
|
|
|
|
|
|
|
sscanf(arg1, "%d", &stat);
|
|
|
|
return rig_set_powerstat(rig, stat);
|
|
|
|
}
|
|
|
|
|
|
|
|
declare_proto_rig(get_powerstat)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
powerstat_t stat;
|
|
|
|
|
|
|
|
status = rig_get_powerstat(rig, &stat);
|
|
|
|
if (status != RIG_OK)
|
|
|
|
return status;
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->arg1);
|
|
|
|
printf("%d\n", stat);
|
|
|
|
return status;
|
|
|
|
}
|
2002-09-06 14:07:17 +00:00
|
|
|
|