2000-10-29 16:35:29 +00:00
|
|
|
/*
|
|
|
|
* hamlib - (C) 2000 Frank Singleton and Stephane Fillod
|
|
|
|
*
|
|
|
|
* rigctl.c - (C) Stephane Fillod 2000
|
|
|
|
*
|
|
|
|
* This program test/control a radio using Hamlib.
|
|
|
|
* TODO: be more generic and add command line option to run
|
|
|
|
* in non-interactive mode
|
|
|
|
*
|
2001-03-02 18:43:25 +00:00
|
|
|
* $Id: rigctl.c,v 1.10 2001-03-02 18:43:25 f4cfe 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2001-02-25 23:14:19 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
/* TODO: autoconf should check for getopt support, include libs otherwise */
|
|
|
|
#include <getopt.h>
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
#include <hamlib/rig.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define SERIAL_PORT "/dev/ttyS0"
|
|
|
|
|
|
|
|
#define MAXNAMSIZ 40
|
2001-02-25 23:14:19 +00:00
|
|
|
#define MAXNBOPT 100 /* max number of different options */
|
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
struct test_table {
|
2001-02-25 23:14:19 +00:00
|
|
|
unsigned char cmd;
|
|
|
|
unsigned char name[MAXNAMSIZ];
|
|
|
|
int (*test_func)(RIG*, int, const struct test_table*, const char*, const char*, const char*);
|
|
|
|
const char *name1;
|
|
|
|
const char *name2;
|
|
|
|
const char *name3;
|
2000-10-29 16:35:29 +00:00
|
|
|
};
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
#define declare_proto_rig(f) static int (f)(RIG *rig, int interactive, const struct test_table *cmd, const char *arg1, const char *arg2, const char *arg3)
|
|
|
|
|
|
|
|
declare_proto_rig(set_freq);
|
|
|
|
declare_proto_rig(get_freq);
|
|
|
|
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);
|
|
|
|
declare_proto_rig(set_ctcss);
|
|
|
|
declare_proto_rig(get_ctcss);
|
|
|
|
declare_proto_rig(set_dcs);
|
|
|
|
declare_proto_rig(get_dcs);
|
|
|
|
declare_proto_rig(set_split_freq);
|
|
|
|
declare_proto_rig(get_split_freq);
|
|
|
|
declare_proto_rig(set_split);
|
|
|
|
declare_proto_rig(get_split);
|
|
|
|
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);
|
|
|
|
declare_proto_rig(set_bank);
|
|
|
|
declare_proto_rig(set_mem);
|
|
|
|
declare_proto_rig(get_mem);
|
|
|
|
declare_proto_rig(mv_ctl);
|
|
|
|
declare_proto_rig(set_channel);
|
|
|
|
declare_proto_rig(get_channel);
|
|
|
|
declare_proto_rig(set_trn);
|
|
|
|
declare_proto_rig(get_trn);
|
2000-10-29 16:35:29 +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
|
|
|
|
*
|
|
|
|
* TODO: add missing rig_set_/rig_get_: rit, ann, ant, dcs, ctcss, dcd, etc.
|
|
|
|
* NB: do NOT use -W since it's reserved by POSIX.
|
|
|
|
* 'q' 'Q' '?' are also reserved for interface use
|
2001-02-11 23:22:06 +00:00
|
|
|
*/
|
2000-10-29 16:35:29 +00:00
|
|
|
struct test_table test_list[] = {
|
2001-02-25 23:14:19 +00:00
|
|
|
{ 'F', "set_freq", set_freq, "Frequency" },
|
|
|
|
{ 'f', "get_freq", get_freq, "Frequency" },
|
|
|
|
{ 'M', "set_mode", set_mode, "Mode", "Passband" },
|
|
|
|
{ 'm', "get_mode", get_mode, "Mode", "Passband" },
|
|
|
|
{ 'V', "set_vfo", set_vfo, "VFO" },
|
|
|
|
{ 'v', "get_vfo", get_vfo, "VFO" },
|
|
|
|
{ 'T', "set_ptt", set_ptt, "PTT" },
|
|
|
|
{ 't', "get_ptt", get_ptt, "PTT" },
|
|
|
|
{ 'R', "set_rptr_shift", set_rptr_shift, "Rptr shift" },
|
|
|
|
{ 'r', "get_rptr_shift", get_rptr_shift, "Rptr shift" },
|
|
|
|
{ 'O', "set_rptr_offs", set_rptr_offs, "Rptr offset" },
|
|
|
|
{ 'o', "get_rptr_offs", get_rptr_offs, "Rptr offset" },
|
|
|
|
{ 'C', "set_ctcss", set_ctcss, "CTCSS tone" },
|
|
|
|
{ 'c', "get_ctcss", get_ctcss, "CTCSS tone" },
|
|
|
|
{ 'D', "set_dcs", set_dcs, "DCS code" },
|
|
|
|
{ 'd', "get_dcs", get_dcs, "DCS code" },
|
|
|
|
{ 'I', "set_split_freq", set_split_freq, "Rx frequency", "Tx frequency" },
|
|
|
|
{ 'i', "get_split_freq", get_split_freq, "Rx frequency", "Tx frequency" },
|
|
|
|
{ 'S', "set_split", set_split, "Split mode" },
|
|
|
|
{ 's', "get_split", get_split, "Split mode" },
|
|
|
|
{ 'N', "set_ts", set_ts, "Tuning step" },
|
|
|
|
{ 'n', "get_ts", get_ts, "Tuning step" },
|
2000-10-29 16:35:29 +00:00
|
|
|
{ '2', "power2mW", power2mW },
|
2001-02-25 23:14:19 +00:00
|
|
|
{ 'L', "set_level", set_level, "Level", "Value" },
|
|
|
|
{ 'l', "get_level", get_level, "Level", "Value" },
|
|
|
|
{ 'U', "set_func", set_func, "Func", "Func status" },
|
|
|
|
{ 'u', "get_func", get_func, "Func", "Func status" },
|
|
|
|
{ 'B', "set_bank", set_bank, "Bank" },
|
|
|
|
{ 'E', "set_mem", set_mem, "Memory#" },
|
|
|
|
{ 'e', "get_mem", get_mem, "Memory#" },
|
|
|
|
{ 'G', "mv_ctl", mv_ctl, "Mem/VFO op" },
|
2001-03-01 21:25:45 +00:00
|
|
|
{ 'H', "set_channel", set_channel /* huh! */ },
|
|
|
|
{ 'h', "get_channel", get_channel, "Channel" },
|
|
|
|
{ 'A', "set_trn", set_trn, "Transceive" },
|
|
|
|
{ 'a', "get_trn", get_trn, "Transceive" },
|
2000-10-29 16:35:29 +00:00
|
|
|
{ 0x00, "", NULL },
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
RIG *my_rig; /* handle to rig (nstance) */
|
|
|
|
|
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 */
|
|
|
|
int i;
|
|
|
|
char cmd;
|
2001-02-25 23:14:19 +00:00
|
|
|
struct option long_options[MAXNBOPT];
|
|
|
|
char opt_string[MAXNBOPT*2], *opt_ptr;
|
|
|
|
struct test_table *cmd_entry;
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* allocate memory, setup & open port
|
|
|
|
*/
|
|
|
|
|
|
|
|
retcode = rig_load_backend("icom");
|
|
|
|
retcode |= rig_load_backend("ft747");
|
2001-02-07 23:53:30 +00:00
|
|
|
retcode |= rig_load_backend("ft847");
|
|
|
|
retcode |= rig_load_backend("kenwood");
|
|
|
|
retcode |= rig_load_backend("aor");
|
2001-03-02 18:43:25 +00:00
|
|
|
retcode |= rig_load_backend("pcr");
|
2001-02-07 23:53:30 +00:00
|
|
|
rig_load_backend("winradio");
|
2001-02-14 01:13:20 +00:00
|
|
|
rig_load_backend("dummy");
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
if (retcode != RIG_OK ) {
|
|
|
|
printf("rig_load_backend: error = %s \n", rigerror(retcode));
|
|
|
|
exit(3);
|
|
|
|
}
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
opt_ptr = opt_string;
|
|
|
|
for (i=0; i<MAXNBOPT-1 && test_list[i].cmd; i++) {
|
|
|
|
/*
|
|
|
|
* build long_options
|
|
|
|
*/
|
|
|
|
long_options[i].name = test_list[i].name;
|
|
|
|
long_options[i].val = test_list[i].cmd;
|
|
|
|
long_options[i].has_arg = test_list[i].name1 ?
|
|
|
|
required_argument : no_argument;
|
|
|
|
long_options[i].flag = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* build short_options
|
|
|
|
*/
|
|
|
|
*opt_ptr++ = test_list[i].cmd;
|
|
|
|
if (long_options[i].has_arg)
|
|
|
|
*opt_ptr++ = ':';
|
|
|
|
}
|
2001-03-01 21:25:45 +00:00
|
|
|
memset(long_options+i, 0, sizeof(struct option));
|
2001-02-25 23:14:19 +00:00
|
|
|
*opt_ptr = '\0';
|
|
|
|
|
|
|
|
printf("%s\n",opt_string);
|
|
|
|
|
|
|
|
/* TODO: add a long option(after they are consumed) or arg to set rig model */
|
2000-10-29 16:35:29 +00:00
|
|
|
#if 1
|
2001-02-25 23:14:19 +00:00
|
|
|
my_rig = rig_init(RIG_MODEL_DUMMY);
|
2000-10-29 16:35:29 +00:00
|
|
|
#else
|
2001-02-25 23:14:19 +00:00
|
|
|
my_rig = rig_init(RIG_MODEL_IC706MKIIG);
|
2000-10-29 16:35:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!my_rig)
|
|
|
|
exit(1); /* whoops! something went wrong (mem alloc?) */
|
|
|
|
|
|
|
|
strncpy(my_rig->state.rig_path,SERIAL_PORT,FILPATHLEN);
|
|
|
|
|
2001-02-11 23:22:06 +00:00
|
|
|
/* TODO: make this a parameter */
|
|
|
|
my_rig->state.ptt_type = RIG_PTT_PARALLEL;
|
|
|
|
strncpy(my_rig->state.ptt_path,"/dev/parport0",FILPATHLEN);
|
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
if ((retcode = rig_open(my_rig)) != RIG_OK) {
|
|
|
|
fprintf(stderr,"rig_open: error = %s \n", rigerror(retcode));
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
while(1) {
|
|
|
|
int c;
|
|
|
|
int option_index = 0;
|
|
|
|
|
|
|
|
c = getopt_long (argc, argv, opt_string,
|
|
|
|
long_options, &option_index);
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
printf ("## option '%c' %s\n", c, long_options[option_index].name);
|
|
|
|
|
|
|
|
cmd_entry = find_cmd_entry(c);
|
|
|
|
if (!cmd_entry)
|
|
|
|
break; /* TODO: */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* at least one command on command line,
|
|
|
|
* disable interactive mode
|
|
|
|
*/
|
|
|
|
interactive = 0;
|
|
|
|
|
|
|
|
retcode = (*cmd_entry->test_func)(my_rig, interactive, cmd_entry, optarg,
|
|
|
|
optarg, optarg);
|
|
|
|
|
|
|
|
if (retcode != RIG_OK ) {
|
|
|
|
printf("%s: error = %s\n",cmd_entry->name,rigerror(retcode));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!interactive) {
|
|
|
|
rig_close(my_rig); /* close port */
|
|
|
|
rig_cleanup(my_rig); /* if you care about memory */
|
|
|
|
return 0;
|
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
while (1) {
|
2001-02-25 23:14:19 +00:00
|
|
|
char arg1[128], *p1;
|
|
|
|
char arg2[128], *p2;
|
|
|
|
char arg3[128], *p3;
|
|
|
|
|
2000-10-29 16:35:29 +00:00
|
|
|
printf("\nRig command: ");
|
|
|
|
scanf("%c", &cmd);
|
|
|
|
if (cmd == 0x0a)
|
|
|
|
scanf("%c", &cmd);
|
|
|
|
|
|
|
|
if (cmd == 'Q' || cmd == 'q')
|
|
|
|
break;
|
|
|
|
|
2001-02-07 23:53:30 +00:00
|
|
|
if (cmd == '?') {
|
|
|
|
for (i=0; test_list[i].cmd != 0x00; i++)
|
|
|
|
printf("%c: %s\n",test_list[i].cmd,test_list[i].name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
cmd_entry = find_cmd_entry(cmd);
|
|
|
|
if (!cmd_entry) {
|
|
|
|
fprintf(stderr, "Command not found!\n");
|
|
|
|
continue;
|
|
|
|
}
|
2000-10-29 16:35:29 +00:00
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
p1 = p2 = p3 = NULL;
|
|
|
|
if (cmd_entry->name1) {
|
|
|
|
printf("%s: ", cmd_entry->name1);
|
|
|
|
scanf("%s", arg1);
|
|
|
|
p1 = arg1;
|
|
|
|
}
|
|
|
|
if (cmd_entry->name2) {
|
|
|
|
printf("%s: ", cmd_entry->name2);
|
|
|
|
scanf("%s", arg2);
|
|
|
|
p2 = arg2;
|
|
|
|
}
|
|
|
|
if (cmd_entry->name3) {
|
|
|
|
printf("%s: ", cmd_entry->name3);
|
|
|
|
scanf("%s", arg3);
|
|
|
|
p1 = arg3;
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
2001-02-25 23:14:19 +00:00
|
|
|
retcode = (*cmd_entry->test_func)(my_rig, interactive, cmd_entry, p1,
|
|
|
|
p2, p3);
|
2000-10-29 16:35:29 +00:00
|
|
|
|
|
|
|
if (retcode != RIG_OK ) {
|
2001-02-25 23:14:19 +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-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;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%lld", &freq);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_freq(rig, RIG_VFO_CURR, 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;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_freq(rig, RIG_VFO_CURR, &freq);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1); /* i.e. "Frequency" */
|
|
|
|
printf("%lld", freq);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &mode);
|
|
|
|
sscanf(arg2, "%d", (int*)&width);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_mode(rig, RIG_VFO_CURR, 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;
|
2000-10-29 16:35:29 +00:00
|
|
|
pbwidth_t width;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_mode(rig, RIG_VFO_CURR, &mode, &width);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
2001-03-01 21:25:45 +00:00
|
|
|
printf("%d\n", mode);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name2);
|
|
|
|
printf("%d", 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
|
|
|
{
|
|
|
|
vfo_t vfo;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", (int*)&vfo);
|
2000-10-29 16:35:29 +00:00
|
|
|
return rig_set_vfo(rig, vfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_vfo)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
vfo_t vfo;
|
|
|
|
|
|
|
|
status = rig_get_vfo(rig, &vfo);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%d\n", 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);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_ptt(rig, RIG_VFO_CURR, 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;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_ptt(rig, RIG_VFO_CURR, &ptt);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
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;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", (int*)&rptr_shift);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_rptr_shift(rig, RIG_VFO_CURR, 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;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_rptr_shift(rig, RIG_VFO_CURR, &rptr_shift);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%d\n", 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);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_rptr_offs(rig, RIG_VFO_CURR, 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;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_rptr_offs(rig, RIG_VFO_CURR, &rptr_offs);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%ld\n", rptr_offs);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_ctcss)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
unsigned int tone;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &tone);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_ctcss(rig, RIG_VFO_CURR, tone);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_ctcss)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
unsigned int tone;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_ctcss(rig, RIG_VFO_CURR, &tone);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%d\n", tone);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_dcs)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
unsigned int code;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &code);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_dcs(rig, RIG_VFO_CURR, code);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_dcs)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
unsigned int code;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_dcs(rig, RIG_VFO_CURR, &code);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
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
|
|
|
{
|
|
|
|
freq_t rxfreq,txfreq;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg2, "%lld", &rxfreq);
|
|
|
|
sscanf(arg2, "%lld", &txfreq);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_split_freq(rig, RIG_VFO_CURR, rxfreq, 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;
|
|
|
|
freq_t rxfreq,txfreq;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_split_freq(rig, RIG_VFO_CURR, &rxfreq, &txfreq);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%lld\n", rxfreq);
|
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name2);
|
|
|
|
printf("%lld\n", txfreq);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(set_split)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
split_t split;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", (int*)&split);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_split(rig, RIG_VFO_CURR, split);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(get_split)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
split_t split;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_split(rig, RIG_VFO_CURR, &split);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%d\n", split);
|
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);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_ts(rig, RIG_VFO_CURR, 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;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_ts(rig, RIG_VFO_CURR, &ts);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
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: ");
|
|
|
|
scanf("%Ld", &freq);
|
|
|
|
printf("Mode: ");
|
|
|
|
scanf("%d", &mode);
|
|
|
|
status = rig_power2mW(rig, &mwp, power, freq, mode);
|
|
|
|
printf("Power: %d mW\n", mwp);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sscanf(arg1, "%ld", &level);
|
|
|
|
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);
|
|
|
|
|
2001-02-11 23:22:06 +00:00
|
|
|
return rig_set_level(rig, RIG_VFO_CURR, 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;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%ld", &level);
|
2001-02-11 23:22:06 +00:00
|
|
|
status = rig_get_level(rig, RIG_VFO_CURR, level, &val);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-03-01 21:25:45 +00:00
|
|
|
printf("%s: ", cmd->name2);
|
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;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%ld", &func);
|
|
|
|
sscanf(arg2, "%d", (int*)&func_stat);
|
2001-02-11 23:22:06 +00:00
|
|
|
return rig_set_func(rig, RIG_VFO_CURR, func, func_stat);
|
2000-10-29 16:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-11 23:22:06 +00:00
|
|
|
/*
|
|
|
|
* TODO: if rig_get_func fails, do not printf
|
|
|
|
* fix all other get_* calls in rigctl..
|
|
|
|
*/
|
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;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%ld", &func);
|
2001-02-11 23:22:06 +00:00
|
|
|
status = rig_get_func(rig, RIG_VFO_CURR, func, &func_stat);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
2001-03-01 21:25:45 +00:00
|
|
|
printf("%s: ", cmd->name2);
|
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-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);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_bank(rig, RIG_VFO_CURR, 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);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_mem(rig, RIG_VFO_CURR, 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;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_mem(rig, RIG_VFO_CURR, &ch);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%d\n", ch);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
declare_proto_rig(mv_ctl)
|
2000-10-29 16:35:29 +00:00
|
|
|
{
|
|
|
|
mv_op_t op;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", (int*)&op);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_mv_ctl(rig, RIG_VFO_CURR, op);
|
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
|
|
|
{
|
2001-03-01 21:25:45 +00:00
|
|
|
fprintf(stderr,"rigctl_set_channel not implemented yet!\n");
|
2000-10-29 16:35:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
sscanf(arg1, "%d", &chan.channel_num);
|
|
|
|
status = rig_get_channel(rig, &chan);
|
|
|
|
return status;
|
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
|
|
|
{
|
|
|
|
int trn;
|
|
|
|
|
2001-02-25 23:14:19 +00:00
|
|
|
sscanf(arg1, "%d", &trn);
|
2000-12-05 22:04:44 +00:00
|
|
|
return rig_set_trn(rig, RIG_VFO_CURR, 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
|
|
|
{
|
|
|
|
int status;
|
|
|
|
int trn;
|
|
|
|
|
2000-12-05 22:04:44 +00:00
|
|
|
status = rig_get_trn(rig, RIG_VFO_CURR, &trn);
|
2001-02-25 23:14:19 +00:00
|
|
|
if (interactive)
|
|
|
|
printf("%s: ", cmd->name1);
|
|
|
|
printf("%d\n", trn);
|
2000-10-29 16:35:29 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|