mirror of
https://github.com/Hamlib/Hamlib.git
synced 2024-09-21 10:27:18 +00:00
More set_conf/get_conf work
https://github.com/Hamlib/Hamlib/issues/971
This commit is contained in:
parent
2d2d5009e0
commit
02ffc6d6dc
@ -999,15 +999,19 @@ void *multicast_receiver(void *arg)
|
|||||||
__LINE__);
|
__LINE__);
|
||||||
|
|
||||||
int optval = 1;
|
int optval = 1;
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, (PCHAR)&optval, sizeof(optval)) < 0)
|
||||||
|
#else
|
||||||
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0)
|
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP address reuse: %s\n", __func__,
|
rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP address reuse: %s\n", __func__,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SO_REUSEPORT)
|
|
||||||
// Windows does not have SO_REUSEPORT. However, SO_REUSEADDR works in a similar way.
|
// Windows does not have SO_REUSEPORT. However, SO_REUSEADDR works in a similar way.
|
||||||
|
#if defined(SO_REUSEPORT)
|
||||||
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)) < 0)
|
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)) < 0)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP port reuse: %s\n", __func__,
|
rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP port reuse: %s\n", __func__,
|
||||||
@ -1038,7 +1042,11 @@ void *multicast_receiver(void *arg)
|
|||||||
mreq.imr_multiaddr.s_addr = inet_addr(args->multicast_addr);
|
mreq.imr_multiaddr.s_addr = inet_addr(args->multicast_addr);
|
||||||
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
if (setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (PCHAR)&mreq, sizeof(mreq)) < 0)
|
||||||
|
#else
|
||||||
if (setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
|
if (setsockopt(socket_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: error joining multicast group %s:%d: %s\n", __func__,
|
rig_debug(RIG_DEBUG_ERR, "%s: error joining multicast group %s:%d: %s\n", __func__,
|
||||||
args->multicast_addr, args->multicast_port, strerror(errno));
|
args->multicast_addr, args->multicast_port, strerror(errno));
|
||||||
|
@ -298,12 +298,28 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_amp, conf_parms);
|
char *token=strtok(conf_parms,",");
|
||||||
|
|
||||||
if (retcode != RIG_OK)
|
while(token)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
char mytoken[100], myvalue[100];
|
||||||
exit(2);
|
token_t lookup;
|
||||||
|
sscanf(token,"%99[^=]=%99s", mytoken, myvalue);
|
||||||
|
//printf("mytoken=%s,myvalue=%s\n",mytoken, myvalue);
|
||||||
|
lookup = amp_token_lookup(my_amp,mytoken);
|
||||||
|
if (lookup == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: no such token as '%s'\n", __func__, mytoken);
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retcode = amp_set_conf(my_amp, amp_token_lookup(my_amp,mytoken), myvalue);
|
||||||
|
if (retcode != RIG_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amp_file)
|
if (amp_file)
|
||||||
|
@ -1630,7 +1630,7 @@ int set_conf(AMP *my_amp, char *conf_parms)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: invalid token %s for this rig\n", __func__, p);
|
rig_debug(RIG_DEBUG_WARN, "%s: invalid token %s for this amp\n", __func__, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
p = n;
|
p = n;
|
||||||
|
@ -323,17 +323,30 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
char *token=strtok(conf_parms,",");
|
||||||
retcode = set_conf(my_amp, conf_parms);
|
|
||||||
|
|
||||||
if (retcode != RIG_OK)
|
while(token)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
char mytoken[100], myvalue[100];
|
||||||
exit(2);
|
token_t lookup;
|
||||||
|
sscanf(token,"%99[^=]=%99s", mytoken, myvalue);
|
||||||
|
//printf("mytoken=%s,myvalue=%s\n",mytoken, myvalue);
|
||||||
|
lookup = amp_token_lookup(my_amp,mytoken);
|
||||||
|
if (lookup == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: no such token as '%s'\n", __func__, mytoken);
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retcode = amp_set_conf(my_amp, amp_token_lookup(my_amp,mytoken), myvalue);
|
||||||
|
if (retcode != RIG_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (amp_file)
|
if (amp_file)
|
||||||
{
|
{
|
||||||
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
|
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "sprintflst.h"
|
#include "sprintflst.h"
|
||||||
#include "rigctl_parse.h"
|
#include "rigctl_parse.h"
|
||||||
#include "../rigs/icom/icom.h"
|
#include "../rigs/icom/icom.h"
|
||||||
|
#include "dumpcaps.h"
|
||||||
|
|
||||||
void range_print(FILE *fout, const struct freq_range_list range_list[], int rx);
|
void range_print(FILE *fout, const struct freq_range_list range_list[], int rx);
|
||||||
int range_sanity_check(const struct freq_range_list range_list[], int rx);
|
int range_sanity_check(const struct freq_range_list range_list[], int rx);
|
||||||
@ -1238,3 +1239,15 @@ int dumpconf(RIG *rig, FILE *fout)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dumpconf_list(RIG *rig, FILE *fout)
|
||||||
|
{
|
||||||
|
rig_token_foreach(rig, print_conf_list2, (rig_ptr_t)rig);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dumpconf_list_rot(ROT *rot, FILE *fout)
|
||||||
|
{
|
||||||
|
rot_token_foreach(rot, print_conf_list2, rot);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -242,3 +242,10 @@ int dumpcaps_rot(ROT *rot, FILE *fout)
|
|||||||
|
|
||||||
return backend_warnings;
|
return backend_warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dumpconf_list(ROT *rot, FILE *fout)
|
||||||
|
{
|
||||||
|
rot_token_foreach(rot, print_conf_list, rot);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -555,12 +555,28 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rig, conf_parms);
|
char *token=strtok(conf_parms,",");
|
||||||
|
|
||||||
if (retcode != RIG_OK)
|
while(token)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
char mytoken[100], myvalue[100];
|
||||||
exit(2);
|
token_t lookup;
|
||||||
|
sscanf(token,"%99[^=]=%99s", mytoken, myvalue);
|
||||||
|
//printf("mytoken=%s,myvalue=%s\n",mytoken, myvalue);
|
||||||
|
lookup = rig_token_lookup(my_rig,mytoken);
|
||||||
|
if (lookup == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: no such token as '%s'\n", __func__, mytoken);
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retcode = rig_set_conf(my_rig, rig_token_lookup(my_rig,mytoken), myvalue);
|
||||||
|
if (retcode != RIG_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rig_file)
|
if (rig_file)
|
||||||
|
@ -270,6 +270,8 @@ declare_proto_rig(hamlib_version);
|
|||||||
declare_proto_rig(test);
|
declare_proto_rig(test);
|
||||||
declare_proto_rig(cm108_get_bit);
|
declare_proto_rig(cm108_get_bit);
|
||||||
declare_proto_rig(cm108_set_bit);
|
declare_proto_rig(cm108_set_bit);
|
||||||
|
declare_proto_rig(set_conf);
|
||||||
|
declare_proto_rig(get_conf);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -390,6 +392,8 @@ static struct test_table test_list[] =
|
|||||||
{ 0xa8, "hamlib_version", ACTION(hamlib_version), ARG_NOVFO },
|
{ 0xa8, "hamlib_version", ACTION(hamlib_version), ARG_NOVFO },
|
||||||
{ 0xa9, "get_gpio", ACTION(cm108_get_bit), ARG_NOVFO | ARG_IN1 | ARG_OUT1, "GPIO#", "0/1" },
|
{ 0xa9, "get_gpio", ACTION(cm108_get_bit), ARG_NOVFO | ARG_IN1 | ARG_OUT1, "GPIO#", "0/1" },
|
||||||
{ 0xaa, "set_gpio", ACTION(cm108_set_bit), ARG_NOVFO | ARG_IN , "GPIO#", "0/1" },
|
{ 0xaa, "set_gpio", ACTION(cm108_set_bit), ARG_NOVFO | ARG_IN , "GPIO#", "0/1" },
|
||||||
|
{ 0xac, "set_conf", ACTION(set_conf), ARG_NOVFO | ARG_IN , "Token", "Token Value" },
|
||||||
|
{ 0xad, "get_conf", ACTION(get_conf), ARG_NOVFO | ARG_IN1 | ARG_OUT2, "Token", "Value"},
|
||||||
{ 0x00, "", NULL },
|
{ 0x00, "", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1989,6 +1993,21 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
|||||||
return 1; /* !=0, we want them all ! */
|
return 1; /* !=0, we want them all ! */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// short list for rigctl/rigctld display
|
||||||
|
int print_conf_list2(const struct confparams *cfp, rig_ptr_t data)
|
||||||
|
{
|
||||||
|
RIG *rig = (RIG *) data;
|
||||||
|
char buf[128] = "";
|
||||||
|
|
||||||
|
rig_get_conf(rig, cfp->token, buf);
|
||||||
|
fprintf(stdout,"%s: \"%s\"\n" "\t" "Default: %s, Value: %s\n",
|
||||||
|
cfp->name,
|
||||||
|
cfp->tooltip,
|
||||||
|
cfp->dflt,
|
||||||
|
buf);
|
||||||
|
|
||||||
|
return 1; /* !=0, we want them all ! */
|
||||||
|
}
|
||||||
|
|
||||||
static int hash_model_list(const struct rig_caps *caps, void *data)
|
static int hash_model_list(const struct rig_caps *caps, void *data)
|
||||||
{
|
{
|
||||||
@ -2040,58 +2059,6 @@ void list_models()
|
|||||||
hash_delete_all();
|
hash_delete_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int set_conf(RIG *my_rig, char *conf_parms)
|
|
||||||
{
|
|
||||||
char *p, *n;
|
|
||||||
int token;
|
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
|
||||||
p = conf_parms;
|
|
||||||
|
|
||||||
while (p && *p != '\0')
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* FIXME: left hand value of = cannot be null */
|
|
||||||
char *q = strchr(p, '=');
|
|
||||||
|
|
||||||
if (!q)
|
|
||||||
{
|
|
||||||
return (-RIG_EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
*q++ = '\0';
|
|
||||||
n = strchr(q, ',');
|
|
||||||
|
|
||||||
if (n)
|
|
||||||
{
|
|
||||||
*n++ = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
token = rig_token_lookup(my_rig, p);
|
|
||||||
|
|
||||||
if (token != 0)
|
|
||||||
{
|
|
||||||
ret = rig_set_conf(my_rig, rig_token_lookup(my_rig, p), q);
|
|
||||||
|
|
||||||
if (ret != RIG_OK)
|
|
||||||
{
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: invalid token %s for this rig\n", __func__, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
p = n;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (RIG_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* static int (f)(RIG *rig, FILE *fout, int interactive, const struct test_table *cmd,
|
* static int (f)(RIG *rig, FILE *fout, int interactive, const struct test_table *cmd,
|
||||||
* vfo_t vfo, const void *arg1, const void *arg2, const void *arg3)
|
* vfo_t vfo, const void *arg1, const void *arg2, const void *arg3)
|
||||||
@ -5790,3 +5757,62 @@ declare_proto_rig(cm108_set_bit)
|
|||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_proto_rig(get_conf)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: \n", __func__);
|
||||||
|
if (arg1 == NULL || arg1[0] == '?')
|
||||||
|
{
|
||||||
|
dumpconf_list(rig, stdout);
|
||||||
|
debugmsgsave[0] = 0;
|
||||||
|
debugmsgsave2[0] = 0;
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
token_t mytoken = rig_token_lookup(rig, arg1);
|
||||||
|
if (mytoken == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: unknown token '%s' for this rig\n", __func__, arg1);
|
||||||
|
ret = -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char value[4096]; // no max value known -- should we limit it?
|
||||||
|
ret = rig_get_conf(rig, mytoken, value);
|
||||||
|
if (ret != RIG_OK)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
fprintf(fout, "%s=%s\n", arg1, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
declare_proto_rig(set_conf)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
||||||
|
|
||||||
|
|
||||||
|
if (arg1[0] == '?')
|
||||||
|
{
|
||||||
|
dumpconf_list(rig, fout);
|
||||||
|
debugmsgsave[0] = 0;
|
||||||
|
debugmsgsave2[0] = 0;
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
token_t mytoken = rig_token_lookup(rig, arg1);
|
||||||
|
if (mytoken == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: unknown token '%s' for this rig\n", __func__, arg1);
|
||||||
|
ret = -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = rig_set_conf(rig, rig_token_lookup(rig, arg1), arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
int dumpcaps(RIG *, FILE *);
|
int dumpcaps(RIG *, FILE *);
|
||||||
int dumpstate(RIG *, FILE *);
|
int dumpstate(RIG *, FILE *);
|
||||||
int dumpconf(RIG *, FILE *);
|
int dumpconf(RIG *, FILE *);
|
||||||
|
int dumpconf_list(RIG *, FILE *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prototypes
|
* Prototypes
|
||||||
@ -47,6 +48,7 @@ void version();
|
|||||||
void list_models();
|
void list_models();
|
||||||
int dump_chan(FILE *, RIG *, channel_t *);
|
int dump_chan(FILE *, RIG *, channel_t *);
|
||||||
int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
|
int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
|
||||||
|
int print_conf_list2(const struct confparams *cfp, rig_ptr_t data);
|
||||||
int set_conf(RIG *my_rig, char *conf_parms);
|
int set_conf(RIG *my_rig, char *conf_parms);
|
||||||
|
|
||||||
typedef void (*sync_cb_t)(int);
|
typedef void (*sync_cb_t)(int);
|
||||||
|
@ -492,7 +492,8 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rig, conf_parms);
|
retcode = -RIG_ENIMPL;
|
||||||
|
// retcode = set_conf(my_rig, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK)
|
if (retcode != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -659,13 +659,28 @@ int main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "Please check with --list option.\n");
|
fprintf(stderr, "Please check with --list option.\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rig, conf_parms);
|
char *token=strtok(conf_parms,",");
|
||||||
|
while(token)
|
||||||
if (retcode != RIG_OK)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
char mytoken[100], myvalue[100];
|
||||||
exit(2);
|
token_t lookup;
|
||||||
|
sscanf(token,"%99[^=]=%99s", mytoken, myvalue);
|
||||||
|
//printf("mytoken=%s,myvalue=%s\n",mytoken, myvalue);
|
||||||
|
lookup = rig_token_lookup(my_rig,mytoken);
|
||||||
|
if (lookup == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: no such token as '%s'\n", __func__, mytoken);
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retcode = rig_set_conf(my_rig, rig_token_lookup(my_rig,mytoken), myvalue);
|
||||||
|
if (retcode != RIG_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rig_file)
|
if (rig_file)
|
||||||
|
@ -674,7 +674,8 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rig, conf_parms);
|
retcode = -RIG_ENIMPL;
|
||||||
|
// retcode = set_conf(my_rig, conf_parms);
|
||||||
|
|
||||||
if (retcode != RIG_OK)
|
if (retcode != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -339,12 +339,28 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rot, conf_parms);
|
char *token=strtok(conf_parms,",");
|
||||||
|
|
||||||
if (retcode != RIG_OK)
|
while(token)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
char mytoken[100], myvalue[100];
|
||||||
exit(2);
|
token_t lookup;
|
||||||
|
sscanf(token,"%99[^=]=%99s", mytoken, myvalue);
|
||||||
|
//printf("mytoken=%s,myvalue=%s\n",mytoken, myvalue);
|
||||||
|
lookup = rot_token_lookup(my_rot,mytoken);
|
||||||
|
if (lookup == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: no such token as '%s', use -L switch to see\n", __func__, mytoken);
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retcode = rot_set_conf(my_rot, rot_token_lookup(my_rot,mytoken), myvalue);
|
||||||
|
if (retcode != RIG_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rot_file)
|
if (rot_file)
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// TODO: Add "symmetric" set_conf + get_conf to rigctl+rotctl
|
|
||||||
|
|
||||||
#include <hamlib/config.h>
|
#include <hamlib/config.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -65,7 +63,7 @@ extern int read_history();
|
|||||||
#include <hamlib/rotator.h>
|
#include <hamlib/rotator.h>
|
||||||
#include "iofunc.h"
|
#include "iofunc.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "dumpcaps_rot.h"
|
||||||
|
|
||||||
/* HAVE_SSLEEP is defined when Windows Sleep is found
|
/* HAVE_SSLEEP is defined when Windows Sleep is found
|
||||||
* HAVE_SLEEP is defined when POSIX sleep is found
|
* HAVE_SLEEP is defined when POSIX sleep is found
|
||||||
@ -189,10 +187,12 @@ declare_proto_rot(set_parm);
|
|||||||
declare_proto_rot(get_parm);
|
declare_proto_rot(get_parm);
|
||||||
declare_proto_rot(get_info);
|
declare_proto_rot(get_info);
|
||||||
declare_proto_rot(get_status);
|
declare_proto_rot(get_status);
|
||||||
declare_proto_rot(inter_set_conf); /* interactive mode set_conf */
|
declare_proto_rot(set_conf);
|
||||||
|
declare_proto_rot(get_conf);
|
||||||
declare_proto_rot(send_cmd);
|
declare_proto_rot(send_cmd);
|
||||||
declare_proto_rot(dump_state);
|
declare_proto_rot(dump_state);
|
||||||
declare_proto_rot(dump_caps);
|
declare_proto_rot(dump_caps);
|
||||||
|
declare_proto_rot(dump_conf);
|
||||||
/* Follows are functions from locator.c */
|
/* Follows are functions from locator.c */
|
||||||
declare_proto_rot(loc2lonlat);
|
declare_proto_rot(loc2lonlat);
|
||||||
declare_proto_rot(lonlat2loc);
|
declare_proto_rot(lonlat2loc);
|
||||||
@ -224,11 +224,12 @@ struct test_table test_list[] =
|
|||||||
{ 'u', "get_func", ACTION(get_func), ARG_IN1 | ARG_OUT2, "Func", "Func Status" },
|
{ 'u', "get_func", ACTION(get_func), ARG_IN1 | ARG_OUT2, "Func", "Func Status" },
|
||||||
{ 'X', "set_parm", ACTION(set_parm), ARG_IN, "Parm", "Parm Value" },
|
{ 'X', "set_parm", ACTION(set_parm), ARG_IN, "Parm", "Parm Value" },
|
||||||
{ 'x', "get_parm", ACTION(get_parm), ARG_IN1 | ARG_OUT2, "Parm", "Parm Value" },
|
{ 'x', "get_parm", ACTION(get_parm), ARG_IN1 | ARG_OUT2, "Parm", "Parm Value" },
|
||||||
{ 'C', "set_conf", ACTION(inter_set_conf), ARG_IN, "Token", "Value" },
|
{ 'C', "set_conf", ACTION(set_conf), ARG_IN, "Token", "Value" },
|
||||||
{ '_', "get_info", ACTION(get_info), ARG_OUT, "Info" },
|
{ '_', "get_info", ACTION(get_info), ARG_OUT, "Info" },
|
||||||
{ 's', "get_status", ACTION(get_status), ARG_OUT, "Status flags" },
|
{ 's', "get_status", ACTION(get_status), ARG_OUT, "Status flags" },
|
||||||
{ 'w', "send_cmd", ACTION(send_cmd), ARG_IN1 | ARG_IN_LINE | ARG_OUT2, "Cmd", "Reply" },
|
{ 'w', "send_cmd", ACTION(send_cmd), ARG_IN1 | ARG_IN_LINE | ARG_OUT2, "Cmd", "Reply" },
|
||||||
{ '1', "dump_caps", ACTION(dump_caps), },
|
{ '1', "dump_caps", ACTION(dump_caps), },
|
||||||
|
{ '3', "dump_conf", ACTION(dump_conf), },
|
||||||
{ 0x8f, "dump_state", ACTION(dump_state), ARG_OUT },
|
{ 0x8f, "dump_state", ACTION(dump_state), ARG_OUT },
|
||||||
{ 'L', "lonlat2loc", ACTION(lonlat2loc), ARG_IN1 | ARG_IN2 | ARG_IN3 | ARG_OUT1, "Longitude", "Latitude", "Loc Len [2-12]", "Locator" },
|
{ 'L', "lonlat2loc", ACTION(lonlat2loc), ARG_IN1 | ARG_IN2 | ARG_IN3 | ARG_OUT1, "Longitude", "Latitude", "Loc Len [2-12]", "Locator" },
|
||||||
{ 'l', "loc2lonlat", ACTION(loc2lonlat), ARG_IN1 | ARG_OUT1 | ARG_OUT2, "Locator", "Longitude", "Latitude" },
|
{ 'l', "loc2lonlat", ACTION(loc2lonlat), ARG_IN1 | ARG_OUT1 | ARG_OUT2, "Locator", "Longitude", "Latitude" },
|
||||||
@ -240,6 +241,7 @@ struct test_table test_list[] =
|
|||||||
{ 'A', "a_sp2a_lp", ACTION(az_sp2az_lp), ARG_IN1 | ARG_OUT1, "Short Path Deg", "Long Path Deg" },
|
{ 'A', "a_sp2a_lp", ACTION(az_sp2az_lp), ARG_IN1 | ARG_OUT1, "Short Path Deg", "Long Path Deg" },
|
||||||
{ 'a', "d_sp2d_lp", ACTION(dist_sp2dist_lp), ARG_IN1 | ARG_OUT1, "Short Path km", "Long Path km" },
|
{ 'a', "d_sp2d_lp", ACTION(dist_sp2dist_lp), ARG_IN1 | ARG_OUT1, "Short Path km", "Long Path km" },
|
||||||
{ 0x8c, "pause", ACTION(pause), ARG_IN, "Seconds" },
|
{ 0x8c, "pause", ACTION(pause), ARG_IN, "Seconds" },
|
||||||
|
{ 0xad, "get_conf", ACTION(get_conf), ARG_IN1 | ARG_OUT2, "Token", "Value"},
|
||||||
{ 0x00, "", NULL },
|
{ 0x00, "", NULL },
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -1574,7 +1576,7 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
|||||||
char buf[128] = "";
|
char buf[128] = "";
|
||||||
|
|
||||||
rot_get_conf2(rot, cfp->token, buf, sizeof(buf));
|
rot_get_conf2(rot, cfp->token, buf, sizeof(buf));
|
||||||
printf("%s: \"%s\"\n" "\tDefault: %s, Value: %s\n",
|
fprintf(stdout,"%s: \"%s\"\n" "\tDefault: %s, Value: %s\n",
|
||||||
cfp->name,
|
cfp->name,
|
||||||
cfp->tooltip,
|
cfp->tooltip,
|
||||||
cfp->dflt,
|
cfp->dflt,
|
||||||
@ -1583,14 +1585,14 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
|||||||
switch (cfp->type)
|
switch (cfp->type)
|
||||||
{
|
{
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
printf("\tRange: %.1f..%.1f, step %.1f\n",
|
fprintf(stdout,"\tRange: %.1f..%.1f, step %.1f\n",
|
||||||
cfp->u.n.min,
|
cfp->u.n.min,
|
||||||
cfp->u.n.max,
|
cfp->u.n.max,
|
||||||
cfp->u.n.step);
|
cfp->u.n.step);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_CHECKBUTTON:
|
case RIG_CONF_CHECKBUTTON:
|
||||||
printf("\tCheckbox: 0,1\n");
|
fprintf(stdout,"\tCheckbox: 0,1\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_COMBO:
|
case RIG_CONF_COMBO:
|
||||||
@ -1599,14 +1601,14 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\tCombo: %s", cfp->u.c.combostr[0]);
|
fprintf(stdout,"\tCombo: %s", cfp->u.c.combostr[0]);
|
||||||
|
|
||||||
for (i = 1 ; i < RIG_COMBO_MAX && cfp->u.c.combostr[i]; i++)
|
for (i = 1 ; i < RIG_COMBO_MAX && cfp->u.c.combostr[i]; i++)
|
||||||
{
|
{
|
||||||
printf(", %s", cfp->u.c.combostr[i]);
|
fprintf(stdout,", %s", cfp->u.c.combostr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
fprintf(stdout,"\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1666,55 +1668,64 @@ void list_models()
|
|||||||
hash_delete_all();
|
hash_delete_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_proto_rot(get_conf)
|
||||||
int set_conf(ROT *my_rot, char *conf_parms)
|
|
||||||
{
|
{
|
||||||
char *p;
|
int ret;
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: \n", __func__);
|
||||||
rot_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
if (arg1 == NULL || arg1[0] == '?')
|
||||||
p = conf_parms;
|
|
||||||
|
|
||||||
while (p && *p != '\0')
|
|
||||||
{
|
{
|
||||||
int token;
|
dumpconf_list(rot, fout);
|
||||||
char *q, *n = NULL;
|
debugmsgsave[0] = 0;
|
||||||
/* FIXME: left hand value of = cannot be null */
|
debugmsgsave2[0] = 0;
|
||||||
q = strchr(p, '=');
|
return RIG_OK;
|
||||||
|
}
|
||||||
if (!q)
|
token_t mytoken = rot_token_lookup(rot, arg1);
|
||||||
|
if (mytoken == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: unknown token '%s' for this rot\n", __func__, arg1);
|
||||||
|
ret = -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char value[4096];
|
||||||
|
ret = rot_get_conf(rot, rot_token_lookup(rot, arg1), value);
|
||||||
|
if (ret != RIG_OK)
|
||||||
{
|
{
|
||||||
return RIG_EINVAL;
|
return ret;
|
||||||
}
|
}
|
||||||
|
fprintf(fout, "%s=%s\n", arg1, value);
|
||||||
*q++ = '\0';
|
|
||||||
n = strchr(q, ',');
|
|
||||||
|
|
||||||
if (n)
|
|
||||||
{
|
|
||||||
*n++ = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
token = rot_token_lookup(my_rot, p);
|
|
||||||
|
|
||||||
if (token != 0)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
ret = rot_set_conf(my_rot, token, q);
|
|
||||||
|
|
||||||
if (ret != RIG_OK)
|
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: invalid token %s for this rig\n", __func__, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
p = n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 'C' */
|
||||||
|
declare_proto_rot(set_conf)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
||||||
|
|
||||||
|
if (arg1[0] == '?')
|
||||||
|
{
|
||||||
|
dumpconf_list(rot, fout);
|
||||||
|
debugmsgsave[0] = 0;
|
||||||
|
debugmsgsave2[0] = 0;
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
token_t mytoken = rot_token_lookup(rot, arg1);
|
||||||
|
if (mytoken == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: unknown token '%s' for this rot\n", __func__, arg1);
|
||||||
|
ret = -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = rot_set_conf(rot, rot_token_lookup(rot, arg1), arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2344,6 +2355,7 @@ declare_proto_rot(get_parm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0 // replace by set_conf
|
||||||
/* 'C' */
|
/* 'C' */
|
||||||
declare_proto_rot(inter_set_conf)
|
declare_proto_rot(inter_set_conf)
|
||||||
{
|
{
|
||||||
@ -2361,6 +2373,7 @@ declare_proto_rot(inter_set_conf)
|
|||||||
SNPRINTF(buf, sizeof(buf), "%s=%s", arg1, arg2);
|
SNPRINTF(buf, sizeof(buf), "%s=%s", arg1, arg2);
|
||||||
return set_conf(rot, buf);
|
return set_conf(rot, buf);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* '1' */
|
/* '1' */
|
||||||
declare_proto_rot(dump_caps)
|
declare_proto_rot(dump_caps)
|
||||||
@ -2370,6 +2383,14 @@ declare_proto_rot(dump_caps)
|
|||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare_proto_rot(dump_conf)
|
||||||
|
{
|
||||||
|
ENTERFUNC2;
|
||||||
|
|
||||||
|
dumpconf_list(rot, fout);
|
||||||
|
|
||||||
|
RETURNFUNC2(RIG_OK);
|
||||||
|
}
|
||||||
|
|
||||||
/* For rotctld internal use
|
/* For rotctld internal use
|
||||||
* '0x8f'
|
* '0x8f'
|
||||||
@ -2862,3 +2883,20 @@ declare_proto_rot(pause)
|
|||||||
sleep(seconds);
|
sleep(seconds);
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// short list for rigctl/rigctld display
|
||||||
|
int print_conf_list2(const struct confparams *cfp, rig_ptr_t data, FILE *fout)
|
||||||
|
{
|
||||||
|
ROT *rot = (ROT *) data;
|
||||||
|
char buf[128] = "";
|
||||||
|
|
||||||
|
rot_get_conf(rot, cfp->token, buf);
|
||||||
|
fprintf(fout,"%s: \"%s\"\n" "\t" "Default: %s, Value: %s\n",
|
||||||
|
cfp->name,
|
||||||
|
cfp->tooltip,
|
||||||
|
cfp->dflt,
|
||||||
|
buf);
|
||||||
|
|
||||||
|
return 1; /* !=0, we want them all ! */
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ void usage_rot(FILE *);
|
|||||||
void version();
|
void version();
|
||||||
void list_models();
|
void list_models();
|
||||||
int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
|
int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
|
||||||
|
int print_conf_list2(const struct confparams *cfp, rig_ptr_t data, FILE *fout);
|
||||||
int set_conf(ROT *my_rot, char *conf_parms);
|
int set_conf(ROT *my_rot, char *conf_parms);
|
||||||
|
|
||||||
int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char **argv, int argc,
|
int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, const char **argv, int argc,
|
||||||
|
@ -345,12 +345,28 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
retcode = set_conf(my_rot, conf_parms);
|
char *token=strtok(conf_parms,",");
|
||||||
|
|
||||||
if (retcode != RIG_OK)
|
while(token)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
char mytoken[100], myvalue[100];
|
||||||
exit(2);
|
token_t lookup;
|
||||||
|
sscanf(token,"%99[^=]=%99s", mytoken, myvalue);
|
||||||
|
//printf("mytoken=%s,myvalue=%s\n",mytoken, myvalue);
|
||||||
|
lookup = rot_token_lookup(my_rot,mytoken);
|
||||||
|
if (lookup == 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: no such token as '%s', use -L switch to see\n", __func__, mytoken);
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
retcode = rot_set_conf(my_rot, rot_token_lookup(my_rot,mytoken), myvalue);
|
||||||
|
if (retcode != RIG_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
token = strtok(NULL, ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rot_file)
|
if (rot_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user