2003-12-04 23:15:02 +00:00
|
|
|
/*
|
2009-09-14 07:27:58 +00:00
|
|
|
* rigmem.c - (C) Thierry Leconte 2003-2005
|
|
|
|
* (C) Stephane Fillod 2003-2009
|
2003-12-04 23:15:02 +00:00
|
|
|
*
|
|
|
|
* This program exercises the backup and restore of a radio
|
|
|
|
* using Hamlib.
|
|
|
|
*
|
|
|
|
*
|
2011-08-22 01:51:06 +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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-12-04 23:15:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2017-08-09 18:09:55 +00:00
|
|
|
# include "config.h"
|
2003-12-04 23:15:02 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
|
|
|
#include <hamlib/rig.h>
|
|
|
|
#include "misc.h"
|
|
|
|
#include "sprintflst.h"
|
|
|
|
|
|
|
|
#define MAXNAMSIZ 32
|
2017-08-09 18:09:55 +00:00
|
|
|
#define MAXNBOPT 100 /* max number of different options */
|
2003-12-04 23:15:02 +00:00
|
|
|
|
|
|
|
|
2011-08-22 01:51:06 +00:00
|
|
|
/*
|
2003-12-04 23:15:02 +00:00
|
|
|
* external prototype
|
|
|
|
*/
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
extern int xml_save(RIG *rig, const char *outfilename);
|
|
|
|
extern int xml_load(RIG *rig, const char *infilename);
|
|
|
|
extern int xml_parm_save(RIG *rig, const char *outfilename);
|
|
|
|
extern int xml_parm_load(RIG *rig, const char *infilename);
|
2003-12-04 23:15:02 +00:00
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
extern int csv_save(RIG *rig, const char *outfilename);
|
|
|
|
extern int csv_load(RIG *rig, const char *infilename);
|
|
|
|
extern int csv_parm_save(RIG *rig, const char *outfilename);
|
|
|
|
extern int csv_parm_load(RIG *rig, const char *infilename);
|
2003-12-04 23:15:02 +00:00
|
|
|
|
2011-08-22 01:51:06 +00:00
|
|
|
/*
|
2003-12-04 23:15:02 +00:00
|
|
|
* Prototypes
|
|
|
|
*/
|
|
|
|
void usage();
|
|
|
|
void version();
|
|
|
|
int set_conf(RIG *rig, char *conf_parms);
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
int clear_chans(RIG *rig, const char *infilename);
|
2003-12-04 23:15:02 +00:00
|
|
|
|
|
|
|
/*
|
2011-08-22 01:51:06 +00:00
|
|
|
* Reminder: when adding long options,
|
2017-08-09 18:09:55 +00:00
|
|
|
* keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks.
|
2003-12-04 23:15:02 +00:00
|
|
|
* NB: do NOT use -W since it's reserved by POSIX.
|
|
|
|
*/
|
2005-04-20 14:47:56 +00:00
|
|
|
#define SHORT_OPTIONS "m:r:s:c:C:p:axvhV"
|
2017-10-06 23:58:42 +00:00
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
|
|
|
{"model", 1, 0, 'm'},
|
|
|
|
{"rig-file", 1, 0, 'r'},
|
|
|
|
{"serial-speed", 1, 0, 's'},
|
|
|
|
{"civaddr", 1, 0, 'c'},
|
|
|
|
{"set-conf", 1, 0, 'C'},
|
|
|
|
{"set-separator", 1, 0, 'p'},
|
|
|
|
{"all", 0, 0, 'a'},
|
2005-04-20 13:33:18 +00:00
|
|
|
#ifdef HAVE_XML2
|
2017-10-06 23:58:42 +00:00
|
|
|
{"xml", 0, 0, 'x'},
|
2005-04-20 13:33:18 +00:00
|
|
|
#endif
|
2017-10-06 23:58:42 +00:00
|
|
|
{"verbose", 0, 0, 'v'},
|
|
|
|
{"help", 0, 0, 'h'},
|
|
|
|
{"version", 0, 0, 'V'},
|
2017-08-09 18:09:55 +00:00
|
|
|
{0, 0, 0, 0}
|
2003-12-04 23:15:02 +00:00
|
|
|
};
|
|
|
|
|
2020-04-01 19:51:50 +00:00
|
|
|
#define MAXCONFLEN 1024
|
2003-12-04 23:15:02 +00:00
|
|
|
|
|
|
|
int all;
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
int main(int argc, char *argv[])
|
2011-08-22 01:51:06 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
RIG *rig; /* handle to rig (nstance) */
|
|
|
|
rig_model_t my_model = RIG_MODEL_DUMMY;
|
|
|
|
|
|
|
|
int retcode; /* generic return code from functions */
|
|
|
|
|
2020-01-14 17:44:49 +00:00
|
|
|
int verbose = 0;
|
|
|
|
#ifdef HAVE_XML2
|
|
|
|
int xml = 0;
|
|
|
|
#endif
|
2017-08-09 18:09:55 +00:00
|
|
|
const char *rig_file = NULL;
|
|
|
|
int serial_rate = 0;
|
|
|
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
|
|
|
char conf_parms[MAXCONFLEN] = "";
|
|
|
|
extern char csv_sep;
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
int c;
|
|
|
|
int option_index = 0;
|
2020-07-01 13:52:44 +00:00
|
|
|
char dummy[2];
|
2017-08-09 18:09:55 +00:00
|
|
|
|
|
|
|
c = getopt_long(argc, argv, SHORT_OPTIONS, long_options, &option_index);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (c == -1)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
switch (c)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
case 'h':
|
|
|
|
usage();
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
case 'V':
|
|
|
|
version();
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
case 'm':
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!optarg)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
my_model = atoi(optarg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'r':
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!optarg)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_file = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!optarg)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
civaddr = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's':
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!optarg)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2020-07-01 13:52:44 +00:00
|
|
|
if (sscanf(optarg, "%d%1s", &serial_rate, dummy) != 1)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Invalid baud rate of %s\n", optarg);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!optarg)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (*conf_parms != '\0')
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
strcat(conf_parms, ",");
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:51:50 +00:00
|
|
|
if (strlen(conf_parms) + strlen(optarg) > MAXCONFLEN - 24)
|
|
|
|
{
|
|
|
|
printf("Length of conf_parms exceeds internal maximum of %d\n",
|
|
|
|
MAXCONFLEN - 24);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
strncat(conf_parms, optarg, MAXCONFLEN - strlen(conf_parms));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p':
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!optarg)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage(); /* wrong arg count */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
csv_sep = optarg[0];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'a':
|
|
|
|
all++;
|
|
|
|
break;
|
2005-04-20 13:33:18 +00:00
|
|
|
#ifdef HAVE_XML2
|
2017-08-09 18:09:55 +00:00
|
|
|
|
|
|
|
case 'x':
|
|
|
|
xml++;
|
|
|
|
break;
|
2005-04-20 13:33:18 +00:00
|
|
|
#endif
|
2017-08-09 18:09:55 +00:00
|
|
|
|
|
|
|
case 'v':
|
|
|
|
verbose++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
usage(); /* unknown option? */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose);
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "rigmem, %s\n", hamlib_version);
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s",
|
2017-08-09 18:09:55 +00:00
|
|
|
"Report bugs to "
|
|
|
|
"<hamlib-developer@lists.sourceforge.net>\n\n");
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (optind + 1 >= argc)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
rig = rig_init(my_model);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!rig)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr,
|
2020-03-23 15:13:02 +00:00
|
|
|
"Unknown rig num %u, or initialization error.\n",
|
2017-08-09 18:09:55 +00:00
|
|
|
my_model);
|
|
|
|
|
|
|
|
fprintf(stderr, "Please check with --list option.\n");
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = set_conf(rig, conf_parms);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (retcode != RIG_OK)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
|
|
|
exit(2);
|
|
|
|
}
|
2003-12-04 23:15:02 +00:00
|
|
|
|
2009-09-14 07:27:58 +00:00
|
|
|
/* check channel support */
|
2017-08-09 18:09:55 +00:00
|
|
|
if (rig->caps->set_channel == NULL
|
2019-11-30 16:19:08 +00:00
|
|
|
&& rig->caps->get_channel == NULL
|
|
|
|
&& rig->caps->set_chan_all_cb == NULL
|
|
|
|
&& rig->caps->get_chan_all_cb == NULL
|
|
|
|
&& (rig->caps->set_mem == NULL || rig->caps->set_vfo == NULL))
|
2017-10-06 23:58:42 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
|
|
|
|
fprintf(stderr,
|
2020-03-23 15:13:02 +00:00
|
|
|
"Error: rig num %u has no memory support implemented/available.\n",
|
2017-08-09 18:09:55 +00:00
|
|
|
my_model);
|
|
|
|
exit(3);
|
2009-09-14 07:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check channel description */
|
2017-10-06 23:58:42 +00:00
|
|
|
if (rig->caps->chan_list[0].type == 0)
|
|
|
|
{
|
2020-03-23 15:13:02 +00:00
|
|
|
fprintf(stderr, "Error: rig num %u has no channel list.\n",
|
2017-08-09 18:09:55 +00:00
|
|
|
my_model);
|
|
|
|
exit(3);
|
2009-09-14 07:27:58 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (rig_file)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
strncpy(rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: bound checking and port type == serial */
|
2017-10-06 23:58:42 +00:00
|
|
|
if (serial_rate != 0)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
rig->state.rigport.parm.serial.rate = serial_rate;
|
|
|
|
}
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (civaddr)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
rig_set_conf(rig, rig_token_lookup(rig, "civaddr"), civaddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = rig_open(rig);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (retcode != RIG_OK)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode));
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (verbose > 0)
|
|
|
|
{
|
2020-03-23 15:13:02 +00:00
|
|
|
printf("Opened rig model %u, '%s'\n",
|
2017-08-09 18:09:55 +00:00
|
|
|
rig->caps->rig_model,
|
|
|
|
rig->caps->model_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,
|
|
|
|
"Backend version: %s, Status: %s\n",
|
|
|
|
rig->caps->version,
|
|
|
|
rig_strstatus(rig->caps->status));
|
|
|
|
|
|
|
|
/* on some rigs, this accelerates the backup/restore */
|
|
|
|
rig_set_vfo(rig, RIG_VFO_MEM);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!strcmp(argv[optind], "save"))
|
|
|
|
{
|
2020-01-14 17:44:49 +00:00
|
|
|
#ifdef HAVE_XML2
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (xml)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = xml_save(rig, argv[optind + 1]);
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else
|
2020-01-14 17:44:49 +00:00
|
|
|
#endif
|
2017-10-06 23:58:42 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = csv_save(rig, argv[optind + 1]);
|
|
|
|
}
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(argv[optind], "load"))
|
|
|
|
{
|
2020-01-14 17:44:49 +00:00
|
|
|
#ifdef HAVE_XML2
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (xml)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = xml_load(rig, argv[optind + 1]);
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else
|
2020-01-14 17:44:49 +00:00
|
|
|
#endif
|
2017-10-06 23:58:42 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = csv_load(rig, argv[optind + 1]);
|
|
|
|
}
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(argv[optind], "save_parm"))
|
|
|
|
{
|
2020-01-14 17:44:49 +00:00
|
|
|
#ifdef HAVE_XML2
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (xml)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = xml_parm_save(rig, argv[optind + 1]);
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else
|
2020-01-14 17:44:49 +00:00
|
|
|
#endif
|
2017-10-06 23:58:42 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = csv_parm_save(rig, argv[optind + 1]);
|
|
|
|
}
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(argv[optind], "load_parm"))
|
|
|
|
{
|
2020-01-14 17:44:49 +00:00
|
|
|
#ifdef HAVE_XML2
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (xml)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = xml_parm_load(rig, argv[optind + 1]);
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else
|
2020-01-14 17:44:49 +00:00
|
|
|
#endif
|
2017-10-06 23:58:42 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = csv_parm_load(rig, argv[optind + 1]);
|
|
|
|
}
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(argv[optind], "clear"))
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
retcode = clear_chans(rig, argv[optind + 1]);
|
2017-10-06 23:58:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_close(rig); /* close port */
|
|
|
|
rig_cleanup(rig); /* if you care about memory */
|
2003-12-04 23:15:02 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (retcode != 0)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr, "Hamlib error: %s\n", rigerror(retcode));
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2003-12-04 23:15:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
void version()
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
printf("rigmem, %s\n\n", hamlib_version);
|
|
|
|
printf("%s\n", hamlib_copyright);
|
2003-12-04 23:15:02 +00:00
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2003-12-04 23:15:02 +00:00
|
|
|
void usage()
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
printf("Usage: rigmem [OPTION]... COMMAND...FILE\n"
|
|
|
|
"Backup/restore COMMANDs to a connected radio transceiver or receiver.\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
printf(
|
2017-10-06 23:58:42 +00:00
|
|
|
" -m, --model=ID select radio model number. See model list\n"
|
|
|
|
" -r, --rig-file=DEVICE set device of the radio to operate on\n"
|
|
|
|
" -s, --serial-speed=BAUD set serial speed of the serial port\n"
|
|
|
|
" -c, --civaddr=ID set CI-V address, decimal (for Icom rigs only)\n"
|
|
|
|
" -C, --set-conf=PARM=VAL set config parameters\n"
|
|
|
|
" -p, --set-separator=SEP set character separator instead of the CSV comma\n"
|
|
|
|
" -a, --all bypass mem_caps, apply to all fields of channel_t\n"
|
2005-04-20 13:33:18 +00:00
|
|
|
#ifdef HAVE_XML2
|
2017-10-06 23:58:42 +00:00
|
|
|
" -x, --xml use XML format instead of CSV\n"
|
2005-04-20 13:33:18 +00:00
|
|
|
#endif
|
2017-10-06 23:58:42 +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"
|
2017-08-09 18:09:55 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
printf(
|
|
|
|
"COMMANDs:\n"
|
|
|
|
" load\n"
|
|
|
|
" save\n"
|
|
|
|
" load_parm\n"
|
|
|
|
" save_parm\n"
|
|
|
|
" clear\n\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
printf("\nReport bugs to <hamlib-developer@lists.sourceforge.net>.\n");
|
2003-12-04 23:15:02 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2003-12-04 23:15:02 +00:00
|
|
|
int set_conf(RIG *rig, char *conf_parms)
|
|
|
|
{
|
2019-12-09 05:42:32 +00:00
|
|
|
char *p, *n;
|
2017-08-09 18:09:55 +00:00
|
|
|
|
|
|
|
p = conf_parms;
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
while (p && *p != '\0')
|
|
|
|
{
|
2019-12-09 23:12:13 +00:00
|
|
|
int ret;
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
/* FIXME: left hand value of = cannot be null */
|
2019-12-09 05:42:32 +00:00
|
|
|
char *q = strchr(p, '=');
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!q)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
return RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*q++ = '\0';
|
|
|
|
n = strchr(q, ',');
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (n)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
*n++ = '\0';
|
|
|
|
}
|
|
|
|
|
2019-12-09 23:12:13 +00:00
|
|
|
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (ret != RIG_OK)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2003-12-04 23:15:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pretty nasty, clears everything you have in rig memory
|
|
|
|
*/
|
2017-08-09 18:09:55 +00:00
|
|
|
int clear_chans(RIG *rig, const char *infilename)
|
2003-12-04 23:15:02 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
int i, j, ret;
|
|
|
|
channel_t chan;
|
|
|
|
|
|
|
|
memset(&chan, 0, sizeof(chan));
|
|
|
|
chan.freq = RIG_FREQ_NONE;
|
|
|
|
chan.tx_freq = RIG_FREQ_NONE;
|
|
|
|
chan.mode = RIG_MODE_NONE;
|
|
|
|
chan.tx_mode = RIG_MODE_NONE;
|
|
|
|
chan.vfo = RIG_VFO_MEM;
|
|
|
|
|
2019-12-09 05:42:32 +00:00
|
|
|
for (i = 0; rig->state.chan_list[i].type; i++)
|
2017-10-06 23:58:42 +00:00
|
|
|
{
|
2019-08-18 04:20:48 +00:00
|
|
|
for (j = rig->state.chan_list[i].startc;
|
|
|
|
j <= rig->state.chan_list[i].endc; j++)
|
2017-10-06 23:58:42 +00:00
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
|
|
|
|
chan.channel_num = j;
|
2020-11-30 05:32:14 +00:00
|
|
|
ret = rig_set_channel(rig, RIG_VFO_NONE, &chan);
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (ret != RIG_OK)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-12-04 23:15:02 +00:00
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|