2007-05-21 20:02:57 +00:00
|
|
|
/*
|
2008-01-05 15:06:35 +00:00
|
|
|
* rigsmtr.c - (C) Stephane Fillod 2007
|
2007-05-21 20:02:57 +00:00
|
|
|
*
|
2008-01-05 15:06:35 +00:00
|
|
|
* This program output S-meter vs. Azimuth curve using Hamlib.
|
2007-05-21 20:02:57 +00:00
|
|
|
*
|
|
|
|
*
|
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.
|
2007-05-21 20:02:57 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include <getopt.h>
|
|
|
|
|
|
|
|
#include <hamlib/rig.h>
|
|
|
|
#include <hamlib/rotator.h>
|
|
|
|
#include "misc.h"
|
2023-02-14 19:02:02 +00:00
|
|
|
#include "riglist.h"
|
|
|
|
#include "rotlist.h"
|
2007-05-21 20:02:57 +00:00
|
|
|
|
2011-08-22 01:51:06 +00:00
|
|
|
/*
|
2007-05-21 20:02:57 +00:00
|
|
|
* Prototypes
|
|
|
|
*/
|
|
|
|
static void usage();
|
|
|
|
static void version();
|
|
|
|
static int set_conf_rig(RIG *rig, char *conf_parms);
|
|
|
|
static int set_conf_rot(ROT *rot, char *conf_parms);
|
|
|
|
|
|
|
|
/*
|
2011-08-22 01:51:06 +00:00
|
|
|
* Reminder: when adding long options,
|
2007-05-21 20:02:57 +00:00
|
|
|
* keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks.
|
|
|
|
* NB: do NOT use -W since it's reserved by POSIX.
|
|
|
|
*/
|
|
|
|
#define SHORT_OPTIONS "m:r:s:c:C:M:R:S:N:vhV"
|
2017-10-06 23:58:42 +00:00
|
|
|
static struct option long_options[] =
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
{"model", 1, 0, 'm'},
|
|
|
|
{"rig-file", 1, 0, 'r'},
|
|
|
|
{"serial-speed", 1, 0, 's'},
|
|
|
|
{"civaddr", 1, 0, 'c'},
|
|
|
|
{"set-conf", 1, 0, 'C'},
|
|
|
|
{"rot-model", 1, 0, 'M'},
|
|
|
|
{"rot-file", 1, 0, 'R'},
|
|
|
|
{"rot-serial-speed", 1, 0, 'S'},
|
|
|
|
{"rot-set-conf", 1, 0, 'N'},
|
|
|
|
{"verbose", 0, 0, 'v'},
|
|
|
|
{"help", 0, 0, 'h'},
|
|
|
|
{"version", 0, 0, 'V'},
|
|
|
|
{0, 0, 0, 0}
|
2007-05-21 20:02:57 +00:00
|
|
|
};
|
|
|
|
|
2020-04-01 19:51:50 +00:00
|
|
|
#define MAXCONFLEN 1024
|
2007-05-21 20:02:57 +00:00
|
|
|
|
|
|
|
|
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 (instance) */
|
|
|
|
ROT *rot; /* handle to rotator (instance) */
|
|
|
|
rig_model_t rig_model = RIG_MODEL_DUMMY;
|
|
|
|
rot_model_t rot_model = ROT_MODEL_DUMMY;
|
|
|
|
|
|
|
|
int retcode; /* generic return code from functions */
|
|
|
|
|
|
|
|
int verbose = 0;
|
|
|
|
const char *rig_file = NULL, *rot_file = NULL;
|
|
|
|
int serial_rate = 0;
|
|
|
|
int rot_serial_rate = 0;
|
|
|
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
|
|
|
char rig_conf_parms[MAXCONFLEN] = "";
|
|
|
|
char rot_conf_parms[MAXCONFLEN] = "";
|
|
|
|
|
|
|
|
/* int with_rot = 1; */
|
|
|
|
azimuth_t azimuth;
|
|
|
|
elevation_t elevation;
|
|
|
|
unsigned step = 1000000; /* 1e6 us */
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_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 (*rig_conf_parms != '\0')
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
strcat(rig_conf_parms, ",");
|
|
|
|
}
|
|
|
|
|
2020-04-01 19:51:50 +00:00
|
|
|
if (strlen(rig_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(rig_conf_parms, optarg, MAXCONFLEN - strlen(rig_conf_parms));
|
|
|
|
break;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
rot_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
rot_file = 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
rot_serial_rate = atoi(optarg);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'N':
|
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 (*rot_conf_parms != '\0')
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
strcat(rot_conf_parms, ",");
|
|
|
|
}
|
|
|
|
|
|
|
|
strncat(rot_conf_parms, optarg, MAXCONFLEN - strlen(rot_conf_parms));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
verbose++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
usage(); /* unknown option? */
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose);
|
|
|
|
|
2021-03-20 03:56:18 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "rigsmtr, %s\n", hamlib_version2);
|
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");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The radio
|
|
|
|
*/
|
|
|
|
rig = rig_init(rig_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
|
|
|
rig_model);
|
|
|
|
|
|
|
|
fprintf(stderr, "Please check with --list option.\n");
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = set_conf_rig(rig, 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);
|
|
|
|
}
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (rig_file)
|
|
|
|
{
|
2022-01-25 23:41:26 +00:00
|
|
|
strncpy(rig->state.rigport.pathname, rig_file, HAMLIB_FILPATHLEN - 1);
|
2017-08-09 18:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: bound checking and port type == serial */
|
2017-10-06 23:58:42 +00:00
|
|
|
if (serial_rate != 0)
|
|
|
|
{
|
2022-01-25 23:41:26 +00:00
|
|
|
rig->state.rigport.parm.serial.rate = serial_rate;
|
2017-08-09 18:09:55 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!rig_has_get_level(rig, RIG_LEVEL_STRENGTH))
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"rig backend for %s could not get S-Meter"
|
Fix spelling errors
Fixed using the following command:
codespell --write-changes --summary --skip=*.m4 --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
codespell --write-changes --summary --skip=aclocal.m4,lib --ignore-words-list="develope,get's,quitt,setts,som,ue,vektor"
Codespell home page: https://github.com/codespell-project/codespell
2020-07-24 07:02:12 +00:00
|
|
|
"or has insufficient capability\nSorry\n",
|
2017-08-09 18:09:55 +00:00
|
|
|
rig->caps->model_name);
|
|
|
|
exit(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The rotator
|
|
|
|
*/
|
|
|
|
rot = rot_init(rot_model);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!rot)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr,
|
|
|
|
"Unknown rot num %d, or initialization error.\n",
|
|
|
|
rot_model);
|
|
|
|
|
|
|
|
fprintf(stderr, "Please check with --list option.\n");
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = set_conf_rot(rot, rot_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);
|
|
|
|
}
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (rot_file)
|
|
|
|
{
|
2021-03-06 20:59:57 +00:00
|
|
|
strncpy(rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
|
2017-08-09 18:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: bound checking and port type == serial */
|
2017-10-06 23:58:42 +00:00
|
|
|
if (rot_serial_rate != 0)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
rot->state.rotport.parm.serial.rate = rot_serial_rate;
|
|
|
|
}
|
|
|
|
|
|
|
|
retcode = rot_open(rot);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (retcode != RIG_OK && rot_model != ROT_MODEL_DUMMY)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
fprintf(stderr, "rot_open: error = %s \n", rigerror(retcode));
|
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Commenting out to quell "set but not used" warning.
|
|
|
|
* Enable when needed for further functionality. -N0NB
|
|
|
|
*/
|
|
|
|
/* if (rot_model == ROT_MODEL_DUMMY) */
|
|
|
|
/* with_rot = 1; */
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (verbose > 0)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
printf("Opened rotator model %d, '%s'\n",
|
|
|
|
rot->caps->rot_model,
|
|
|
|
rot->caps->model_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************/
|
2017-10-06 23:58:42 +00:00
|
|
|
if (optind < argc)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
step = atof(argv[optind]) * 1e6;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "Setting rotator to azimuth %.1f°\n", rot->state.min_az);
|
|
|
|
rot_set_position(rot, rot->state.min_az, 0);
|
|
|
|
fprintf(stderr, "Wait for rotator to move...\n");
|
|
|
|
rot_get_position(rot, &azimuth, &elevation);
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
while (fabs(azimuth - rot->state.min_az) > 1.)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
rot_get_position(rot, &azimuth, &elevation);
|
2020-01-08 05:18:56 +00:00
|
|
|
hl_usleep(step);
|
2017-08-09 18:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "Now initiating full 360° rotation...\n");
|
|
|
|
rot_set_position(rot, rot->state.max_az, 0);
|
|
|
|
|
|
|
|
/* TODO: check CW or CCW */
|
|
|
|
/* disable AGC? */
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
while (fabs(rot->state.max_az - azimuth) > 1.)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
value_t strength;
|
|
|
|
|
|
|
|
rig_get_level(rig, RIG_VFO_CURR, RIG_LEVEL_STRENGTH, &strength);
|
|
|
|
|
|
|
|
rot_get_position(rot, &azimuth, &elevation);
|
|
|
|
|
|
|
|
printf("%.1f %d\n", azimuth, strength.i);
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_close(rig);
|
|
|
|
rot_close(rot);
|
|
|
|
|
|
|
|
return 0;
|
2007-05-21 20:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void version()
|
|
|
|
{
|
2021-03-20 03:56:18 +00:00
|
|
|
printf("rigsmtr, %s\n\n", hamlib_version2);
|
2017-08-09 18:09:55 +00:00
|
|
|
printf("%s\n", hamlib_copyright);
|
2007-05-21 20:02:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2007-05-21 20:02:57 +00:00
|
|
|
void usage()
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
printf("Usage: rigsmtr [OPTION]... [time]\n"
|
|
|
|
"Input S-Meter vs Azimuth.\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"
|
|
|
|
" -M, --rot-model=ID select rotator model number. See model list\n"
|
|
|
|
" -R, --rot-file=DEVICE set device of the rotator to operate on\n"
|
|
|
|
" -S, --rot-serial-speed=BAUD set serial speed of the serial port\n"
|
|
|
|
" -N, --rot-set-conf=PARM=VAL set rotator config parameters\n"
|
|
|
|
" -v, --verbose set verbose mode, cumulative\n"
|
|
|
|
" -h, --help display this help and exit\n"
|
|
|
|
" -V, --version output version information and exit\n\n"
|
2017-08-09 18:09:55 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
printf("\nReport bugs to <hamlib-developer@lists.sourceforge.net>.\n");
|
2007-05-21 20:02:57 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2007-05-21 20:02:57 +00:00
|
|
|
int set_conf_rig(RIG *rig, char *conf_parms)
|
|
|
|
{
|
2019-12-24 05:13:40 +00:00
|
|
|
char *p;
|
2017-08-09 18:09:55 +00:00
|
|
|
|
|
|
|
p = conf_parms;
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
while (p && *p != '\0')
|
|
|
|
{
|
2020-01-14 18:19:16 +00:00
|
|
|
int ret;
|
2019-12-24 05:13:40 +00:00
|
|
|
char *q, *n = NULL;
|
2017-08-09 18:09:55 +00:00
|
|
|
/* FIXME: left hand value of = cannot be null */
|
|
|
|
q = strchr(p, '=');
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (!q)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
return RIG_EINVAL;
|
|
|
|
|
2019-12-24 05:13:40 +00:00
|
|
|
*q++ = '\0';
|
|
|
|
n = strchr(q, ',');
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2019-12-24 05:13:40 +00:00
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
*n++ = '\0';
|
|
|
|
}
|
2017-08-09 18:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
|
|
|
|
|
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;
|
2007-05-21 20:02:57 +00:00
|
|
|
}
|
|
|
|
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2007-05-21 20:02:57 +00:00
|
|
|
int set_conf_rot(ROT *rot, char *conf_parms)
|
|
|
|
{
|
2019-12-24 05:13:40 +00:00
|
|
|
char *p;
|
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-24 05:13:40 +00:00
|
|
|
char *q, *n = NULL;
|
|
|
|
int ret;
|
2017-08-09 18:09:55 +00:00
|
|
|
/* FIXME: left hand value of = cannot be null */
|
|
|
|
q = strchr(p, '=');
|
|
|
|
|
2017-10-06 23:58:42 +00:00
|
|
|
if (q)
|
|
|
|
{
|
2017-08-09 18:09:55 +00:00
|
|
|
*q++ = '\0';
|
|
|
|
|
2019-12-24 05:11:36 +00:00
|
|
|
n = strchr(q, ',');
|
2017-08-09 18:09:55 +00:00
|
|
|
|
2019-12-24 05:11:36 +00:00
|
|
|
if (n)
|
|
|
|
{
|
|
|
|
*n++ = '\0';
|
|
|
|
}
|
2017-08-09 18:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = rot_set_conf(rot, rot_token_lookup(rot, p), q);
|
|
|
|
|
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;
|
2007-05-21 20:02:57 +00:00
|
|
|
}
|