2001-10-16 19:29:03 +00:00
|
|
|
/*
|
|
|
|
* Hamlib RPC backend - main file
|
2003-04-06 18:40:36 +00:00
|
|
|
* Copyright (c) 2001-2003 by Stephane Fillod
|
2001-10-16 19:29:03 +00:00
|
|
|
*
|
2003-05-16 16:31:46 +00:00
|
|
|
* $Id: rpcrig_backend.c,v 1.16 2003-05-16 16:31:46 fillods Exp $
|
2001-10-16 19:29:03 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library 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 Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
#include <math.h>
|
2002-09-13 06:59:54 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <netdb.h>
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2003-04-07 22:42:11 +00:00
|
|
|
#include "hamlib/rig.h"
|
|
|
|
#include "serial.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "token.h"
|
2003-04-16 22:30:43 +00:00
|
|
|
#include "register.h"
|
2003-04-07 22:42:11 +00:00
|
|
|
|
2001-10-16 19:29:03 +00:00
|
|
|
#include <rpc/rpc.h>
|
2002-12-16 22:07:02 +00:00
|
|
|
#ifdef HAVE_RPC_RPCENT_H
|
|
|
|
#include <rpc/rpcent.h>
|
|
|
|
#endif
|
2001-10-16 19:29:03 +00:00
|
|
|
#include "rpcrig.h"
|
|
|
|
|
|
|
|
#include "rpcrig_backend.h"
|
|
|
|
|
2002-09-13 06:59:54 +00:00
|
|
|
#define RIGPROTO "udp"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Borrowed from stringify.h
|
|
|
|
* Indirect stringification. Doing two levels allows the parameter to be a
|
|
|
|
* macro itself. For example, compile with -DFOO=bar, __stringify(FOO)
|
|
|
|
* converts to "bar".
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define r_stringify_1(x) #x
|
|
|
|
#define r_stringify(x) r_stringify_1(x)
|
2001-10-16 19:29:03 +00:00
|
|
|
|
|
|
|
struct rpcrig_priv_data {
|
|
|
|
CLIENT *cl;
|
2002-09-13 06:59:54 +00:00
|
|
|
unsigned long prognum;
|
2001-10-16 19:29:03 +00:00
|
|
|
};
|
|
|
|
|
2002-08-23 20:01:09 +00:00
|
|
|
#define SETBODY1(f, rpc_type, rig_arg) \
|
|
|
|
struct rpcrig_priv_data *priv; \
|
|
|
|
int *result; \
|
|
|
|
rpc_type##_x arg; \
|
|
|
|
\
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv; \
|
|
|
|
\
|
|
|
|
arg = rig_arg; \
|
|
|
|
result = f##_1(&arg, priv->cl); \
|
|
|
|
if (result == NULL) { \
|
|
|
|
clnt_perror(priv->cl, "##f##_1"); \
|
|
|
|
return -RIG_EPROTO; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return *result;
|
|
|
|
|
|
|
|
#define GETBODY1(f, rpc_type, rig_arg) \
|
|
|
|
struct rpcrig_priv_data *priv; \
|
|
|
|
rpc_type##_x arg; \
|
|
|
|
rpc_type##_res *res; \
|
|
|
|
\
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv; \
|
|
|
|
\
|
|
|
|
arg = *rig_arg; \
|
|
|
|
res = f##_1(&arg, priv->cl); \
|
|
|
|
if (res == NULL) { \
|
|
|
|
clnt_perror(priv->cl, "##f##_1"); \
|
|
|
|
return -RIG_EPROTO; \
|
|
|
|
} \
|
|
|
|
if (res->rigstatus == RIG_OK) \
|
|
|
|
*rig_arg = res->rpc_type##_res_u.rpc_type; \
|
|
|
|
\
|
|
|
|
return res->rigstatus;
|
|
|
|
|
|
|
|
#define SETBODYVFO1(f, rpc_type, rig_arg) \
|
|
|
|
struct rpcrig_priv_data *priv; \
|
|
|
|
int *result; \
|
|
|
|
rpc_type##_arg arg; \
|
|
|
|
\
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv; \
|
|
|
|
\
|
|
|
|
arg.vfo = vfo; \
|
|
|
|
arg.rpc_type = rig_arg; \
|
|
|
|
result = f##_1(&arg, priv->cl); \
|
|
|
|
if (result == NULL) { \
|
|
|
|
clnt_perror(priv->cl, "##f##_1"); \
|
|
|
|
return -RIG_EPROTO; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return *result;
|
|
|
|
|
|
|
|
#define GETBODYVFO1(f, rpc_type, rig_arg) \
|
|
|
|
struct rpcrig_priv_data *priv; \
|
|
|
|
rpc_type##_res *res; \
|
|
|
|
vfo_x v; \
|
|
|
|
\
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv; \
|
|
|
|
\
|
|
|
|
v = vfo; \
|
|
|
|
res = f##_1(&v, priv->cl); \
|
|
|
|
if (res == NULL) { \
|
|
|
|
clnt_perror(priv->cl, "##f##_1"); \
|
|
|
|
return -RIG_EPROTO; \
|
|
|
|
} \
|
|
|
|
if (res->rigstatus == RIG_OK) \
|
|
|
|
*rig_arg = res->rpc_type##_res_u.rpc_type; \
|
|
|
|
\
|
|
|
|
return res->rigstatus;
|
|
|
|
|
|
|
|
|
2002-09-13 06:59:54 +00:00
|
|
|
static unsigned long extract_prognum(const char val[])
|
|
|
|
{
|
|
|
|
if (val[0] == '+') {
|
|
|
|
return RIGPROG + atol(val+1);
|
|
|
|
} else
|
|
|
|
if (val[0] < '0' || val[0] > '9') {
|
|
|
|
struct rpcent *ent;
|
|
|
|
ent = getrpcbyname (val);
|
|
|
|
if (ent)
|
|
|
|
return ent->r_number;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return atol(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-16 19:29:03 +00:00
|
|
|
static int rpcrig_init(RIG *rig)
|
|
|
|
{
|
2002-09-13 06:59:54 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
if (!rig || !rig->caps)
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
|
|
|
|
rig->state.priv = malloc(sizeof(struct rpcrig_priv_data));
|
|
|
|
if (!rig->state.priv) {
|
|
|
|
/* whoops! memory shortage! */
|
|
|
|
return -RIG_ENOMEM;
|
|
|
|
}
|
2002-09-13 06:59:54 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
rig->state.rigport.type.rig = RIG_PORT_RPC;
|
2003-05-16 16:31:46 +00:00
|
|
|
rig->state.pttport.type.ptt = RIG_PTT_RIG;
|
|
|
|
rig->state.dcdport.type.dcd = RIG_DCD_RIG;
|
2001-12-26 23:44:05 +00:00
|
|
|
strcpy(rig->state.rigport.pathname, "localhost");
|
2002-09-13 06:59:54 +00:00
|
|
|
priv->prognum = RIGPROG;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rpcrig_cleanup(RIG *rig)
|
|
|
|
{
|
|
|
|
if (!rig)
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
|
|
|
|
if (rig->state.priv)
|
|
|
|
free(rig->state.priv);
|
|
|
|
|
|
|
|
rig->state.priv = NULL;
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
/*
|
|
|
|
* assumes rig!=NULL, rs->priv != NULL
|
|
|
|
*/
|
2001-10-16 19:29:03 +00:00
|
|
|
static int rpcrig_open(RIG *rig)
|
|
|
|
{
|
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
struct rig_state *rs;
|
2001-12-26 23:44:05 +00:00
|
|
|
model_x *mdl_res;
|
|
|
|
rigstate_res *rs_res;
|
2001-10-16 19:29:03 +00:00
|
|
|
rig_model_t model;
|
|
|
|
const struct rig_caps *caps;
|
2002-09-13 06:59:54 +00:00
|
|
|
char *server, *s;
|
2001-12-27 21:56:01 +00:00
|
|
|
int i;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
|
|
|
rs = &rig->state;
|
|
|
|
priv = (struct rpcrig_priv_data*)rs->priv;
|
2002-09-13 06:59:54 +00:00
|
|
|
server = strdup(rs->rigport.pathname);
|
|
|
|
s = strchr(server, ':');
|
|
|
|
if (s) {
|
|
|
|
unsigned long prognum;
|
|
|
|
*s = '\0';
|
|
|
|
prognum = extract_prognum(s+1);
|
|
|
|
if (prognum == 0) {
|
|
|
|
free(server);
|
|
|
|
return -RIG_ECONF;
|
|
|
|
}
|
|
|
|
priv->prognum = prognum;
|
|
|
|
}
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-09-13 06:59:54 +00:00
|
|
|
priv->cl = clnt_create(server, priv->prognum, RIGVERS, RIGPROTO);
|
2001-10-16 19:29:03 +00:00
|
|
|
if (priv->cl == NULL) {
|
|
|
|
clnt_pcreateerror(server);
|
2002-09-13 06:59:54 +00:00
|
|
|
free(server);
|
2001-10-16 19:29:03 +00:00
|
|
|
return -RIG_ECONF;
|
|
|
|
}
|
2001-12-26 23:44:05 +00:00
|
|
|
mdl_res = getmodel_1(NULL, priv->cl);
|
|
|
|
if (mdl_res == NULL) {
|
2001-10-16 19:29:03 +00:00
|
|
|
clnt_perror(priv->cl, server);
|
2001-12-16 11:14:47 +00:00
|
|
|
clnt_destroy(priv->cl);
|
2002-09-13 06:59:54 +00:00
|
|
|
free(server);
|
2001-12-26 23:44:05 +00:00
|
|
|
priv->cl = NULL;
|
2001-10-16 19:29:03 +00:00
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2001-12-26 23:44:05 +00:00
|
|
|
model = *mdl_res;
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s: model %d\n", __FUNCTION__, model);
|
2001-12-26 23:44:05 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* autoload if necessary
|
|
|
|
*/
|
|
|
|
rig_check_backend(model);
|
|
|
|
|
2001-10-16 19:29:03 +00:00
|
|
|
caps = rig_get_caps(model);
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
/*
|
|
|
|
* TODO: decide if it's the way to go.
|
|
|
|
* This for example breaks reentrancy
|
|
|
|
*/
|
|
|
|
//memcpy(&rpcrig_caps, caps, sizeof(struct rig_caps));
|
|
|
|
|
2001-10-16 19:29:03 +00:00
|
|
|
/*
|
|
|
|
* TODO: get these from RPC instead
|
|
|
|
*/
|
2001-12-26 23:44:05 +00:00
|
|
|
|
|
|
|
rs_res = getrigstate_1(NULL, priv->cl);
|
|
|
|
if (rs_res == NULL) {
|
|
|
|
clnt_perror(priv->cl, server);
|
|
|
|
clnt_destroy(priv->cl);
|
2002-09-13 06:59:54 +00:00
|
|
|
free(server);
|
2001-12-26 23:44:05 +00:00
|
|
|
priv->cl = NULL;
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2002-09-13 06:59:54 +00:00
|
|
|
free(server);
|
2001-12-26 23:44:05 +00:00
|
|
|
rs->has_get_func = rs_res->rigstate_res_u.state.has_get_func;
|
|
|
|
rs->has_set_func = rs_res->rigstate_res_u.state.has_set_func;
|
|
|
|
rs->has_get_level = rs_res->rigstate_res_u.state.has_get_level;
|
|
|
|
rs->has_set_level = rs_res->rigstate_res_u.state.has_set_level;
|
|
|
|
rs->has_get_parm = rs_res->rigstate_res_u.state.has_get_parm;
|
|
|
|
rs->has_set_parm = rs_res->rigstate_res_u.state.has_set_parm;
|
|
|
|
|
2001-12-27 21:56:01 +00:00
|
|
|
rs->max_rit = rs_res->rigstate_res_u.state.max_rit;
|
|
|
|
rs->max_xit = rs_res->rigstate_res_u.state.max_xit;
|
|
|
|
rs->max_ifshift = rs_res->rigstate_res_u.state.max_ifshift;
|
|
|
|
rs->announces = rs_res->rigstate_res_u.state.announces;
|
|
|
|
|
|
|
|
memcpy(rs->preamp, rs_res->rigstate_res_u.state.preamp,
|
|
|
|
sizeof(int)*MAXDBLSTSIZ);
|
|
|
|
memcpy(rs->attenuator, rs_res->rigstate_res_u.state.attenuator,
|
|
|
|
sizeof(int)*MAXDBLSTSIZ);
|
|
|
|
|
|
|
|
memcpy(rs->tuning_steps, rs_res->rigstate_res_u.state.tuning_steps,
|
|
|
|
sizeof(struct tuning_step_list)*TSLSTSIZ);
|
|
|
|
memcpy(rs->filters, rs_res->rigstate_res_u.state.filters,
|
|
|
|
sizeof(struct filter_list)*FLTLSTSIZ);
|
|
|
|
memcpy(rs->chan_list, rs_res->rigstate_res_u.state.chan_list,
|
|
|
|
sizeof(chan_t)*CHANLSTSIZ);
|
|
|
|
memcpy(rs->rx_range_list, rs_res->rigstate_res_u.state.rx_range_list,
|
|
|
|
sizeof(freq_range_t)*FRQRANGESIZ);
|
|
|
|
memcpy(rs->tx_range_list, rs_res->rigstate_res_u.state.tx_range_list,
|
|
|
|
sizeof(freq_range_t)*FRQRANGESIZ);
|
|
|
|
|
|
|
|
for (i=0; i<FRQRANGESIZ && !RIG_IS_FRNG_END(rs->rx_range_list[i]); i++) {
|
2001-10-16 19:29:03 +00:00
|
|
|
rs->vfo_list |= rs->rx_range_list[i].vfo;
|
2001-12-27 21:56:01 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<FRQRANGESIZ && !RIG_IS_FRNG_END(rs->tx_range_list[i]); i++) {
|
2001-10-16 19:29:03 +00:00
|
|
|
rs->vfo_list |= rs->tx_range_list[i].vfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rpcrig_close(RIG *rig)
|
|
|
|
{
|
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
if (priv->cl)
|
|
|
|
clnt_destroy(priv->cl);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_vfo(RIG *rig, vfo_t vfo)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODY1(setvfo, vfo, vfo);
|
2001-12-26 23:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_vfo(RIG *rig, vfo_t *vfo)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODY1(getvfo, vfo, vfo);
|
2001-12-26 23:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-16 19:29:03 +00:00
|
|
|
static int rpcrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|
|
|
{
|
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
struct rig_state *rs;
|
|
|
|
int *result;
|
|
|
|
freq_arg farg;
|
|
|
|
|
|
|
|
rs = &rig->state;
|
|
|
|
priv = (struct rpcrig_priv_data*)rs->priv;
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
farg.vfo = vfo;
|
|
|
|
freq_t2x(freq, &farg.freq);
|
2001-10-16 19:29:03 +00:00
|
|
|
result = setfreq_1(&farg, priv->cl);
|
|
|
|
if (result == NULL) {
|
2001-12-26 23:44:05 +00:00
|
|
|
clnt_perror(priv->cl, "setfreq_1");
|
2001-10-16 19:29:03 +00:00
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|
|
|
{
|
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
struct rig_state *rs;
|
|
|
|
freq_res *fres;
|
|
|
|
vfo_x v;
|
|
|
|
|
|
|
|
rs = &rig->state;
|
|
|
|
priv = (struct rpcrig_priv_data*)rs->priv;
|
|
|
|
|
|
|
|
v = vfo;
|
|
|
|
fres = getfreq_1(&v, priv->cl);
|
|
|
|
if (fres == NULL) {
|
2001-12-26 23:44:05 +00:00
|
|
|
clnt_perror(priv->cl, "getfreq_1");
|
2001-10-16 19:29:03 +00:00
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (fres->rigstatus == RIG_OK)
|
2001-12-26 23:44:05 +00:00
|
|
|
*freq = freq_x2t(&fres->freq_res_u.freq);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
|
|
|
return fres->rigstatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
int *result;
|
|
|
|
mode_arg marg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
marg.vfo = vfo;
|
|
|
|
mode_t2s(mode, width, &marg.mw);
|
|
|
|
result = setmode_1(&marg, priv->cl);
|
|
|
|
if (result == NULL) {
|
|
|
|
clnt_perror(priv->cl, "setmode_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *result;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
mode_res *mres;
|
|
|
|
vfo_x v;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
v = vfo;
|
|
|
|
mres = getmode_1(&v, priv->cl);
|
|
|
|
if (mres == NULL) {
|
|
|
|
clnt_perror(priv->cl, "getmode_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (mres->rigstatus == RIG_OK)
|
|
|
|
mode_s2t(&mres->mode_res_u.mw, mode, width);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
return mres->rigstatus;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
struct rig_state *rs;
|
|
|
|
int *result;
|
|
|
|
freq_arg farg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
rs = &rig->state;
|
|
|
|
priv = (struct rpcrig_priv_data*)rs->priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
farg.vfo = vfo;
|
|
|
|
freq_t2x(tx_freq, &farg.freq);
|
|
|
|
result = setsplitfreq_1(&farg, priv->cl);
|
|
|
|
if (result == NULL) {
|
|
|
|
clnt_perror(priv->cl, "setsplitfreq_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
return *result;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
struct rig_state *rs;
|
|
|
|
freq_res *fres;
|
|
|
|
vfo_x v;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
rs = &rig->state;
|
|
|
|
priv = (struct rpcrig_priv_data*)rs->priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
v = vfo;
|
|
|
|
fres = getsplitfreq_1(&v, priv->cl);
|
|
|
|
if (fres == NULL) {
|
|
|
|
clnt_perror(priv->cl, "getsplitfreq_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (fres->rigstatus == RIG_OK)
|
|
|
|
*tx_freq = freq_x2t(&fres->freq_res_u.freq);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
return fres->rigstatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rpcrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
int *result;
|
|
|
|
mode_arg marg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
marg.vfo = vfo;
|
|
|
|
mode_t2s(tx_mode, tx_width, &marg.mw);
|
|
|
|
result = setsplitmode_1(&marg, priv->cl);
|
|
|
|
if (result == NULL) {
|
|
|
|
clnt_perror(priv->cl, "setsplitmode_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
return *result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rpcrig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
mode_res *mres;
|
|
|
|
vfo_x v;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
v = vfo;
|
|
|
|
mres = getsplitmode_1(&v, priv->cl);
|
|
|
|
if (mres == NULL) {
|
|
|
|
clnt_perror(priv->cl, "getsplitmode_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (mres->rigstatus == RIG_OK)
|
|
|
|
mode_s2t(&mres->mode_res_u.mw, tx_mode, tx_width);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
return mres->rigstatus;
|
|
|
|
}
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2003-04-06 18:40:36 +00:00
|
|
|
static int rpcrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2003-04-06 18:40:36 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
int *result;
|
|
|
|
split_arg arg;
|
|
|
|
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
arg.vfo = vfo;
|
|
|
|
arg.split = split;
|
|
|
|
arg.tx_vfo = tx_vfo;
|
|
|
|
result = setsplitvfo_1(&arg, priv->cl);
|
|
|
|
if (result == NULL) {
|
|
|
|
clnt_perror(priv->cl, "setsplitvfo_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *result;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-06 18:40:36 +00:00
|
|
|
static int rpcrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2003-04-06 18:40:36 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
split_res *res;
|
|
|
|
vfo_x v;
|
|
|
|
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
v = vfo;
|
|
|
|
res = getsplitvfo_1(&v, priv->cl);
|
|
|
|
if (res == NULL) {
|
|
|
|
clnt_perror(priv->cl, "getsplitvfo_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (res->rigstatus == RIG_OK) {
|
|
|
|
*split = res->split_res_u.split.split;
|
|
|
|
*tx_vfo = res->split_res_u.split.tx_vfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res->rigstatus;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setptt, ptt, ptt);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getptt, ptt, ptt);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getdcd, dcd, dcd);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setrptrshift, rptrshift, rptr_shift);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getrptrshift, rptrshift, rptr_shift);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setrptroffs, shortfreq, rptr_offs);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getrptroffs, shortfreq, rptr_offs);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setctcsstone, tone, tone);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getctcsstone, tone, tone);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setdcscode, tone, code);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getdcscode, tone, code);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
|
|
|
|
static int rpcrig_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setctcsssql, tone, tone);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
|
|
|
|
static int rpcrig_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getctcsssql, tone, tone);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
|
|
|
|
static int rpcrig_set_dcs_sql(RIG *rig, vfo_t vfo, unsigned int code)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setdcssql, tone, code);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_dcs_sql(RIG *rig, vfo_t vfo, unsigned int *code)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getdcssql, tone, code);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
|
2001-10-16 19:29:03 +00:00
|
|
|
static int rpcrig_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setrit, shortfreq, rit);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getrit, shortfreq, rit);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setxit, shortfreq, xit);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getxit, shortfreq, xit);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setts, shortfreq, ts);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getts, shortfreq, ts);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
int *result;
|
|
|
|
setting_arg arg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
arg.vfo = vfo;
|
|
|
|
setting_t2x(func, &arg.setting);
|
|
|
|
arg.val.i = status;
|
|
|
|
result = setfunc_1(&arg, priv->cl);
|
|
|
|
if (result == NULL) {
|
|
|
|
clnt_perror(priv->cl, "setfunc_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *result;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
val_res *res;
|
|
|
|
setting_arg arg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
arg.vfo = vfo;
|
|
|
|
setting_t2x(func, &arg.setting);
|
|
|
|
arg.val.i = *status;
|
|
|
|
res = getfunc_1(&arg, priv->cl);
|
|
|
|
if (res == NULL) {
|
|
|
|
clnt_perror(priv->cl, "getfunc_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (res->rigstatus == RIG_OK)
|
|
|
|
*status = res->val_res_u.val.i;
|
|
|
|
|
|
|
|
return res->rigstatus;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
int *result;
|
|
|
|
setting_arg arg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
arg.vfo = vfo;
|
|
|
|
setting_t2x(level, &arg.setting);
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
arg.val.f = val.f;
|
|
|
|
else
|
|
|
|
arg.val.i = val.i;
|
|
|
|
result = setlevel_1(&arg, priv->cl);
|
|
|
|
if (result == NULL) {
|
|
|
|
clnt_perror(priv->cl, "setlevel_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
return *result;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
val_res *res;
|
|
|
|
setting_arg arg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
arg.vfo = vfo;
|
|
|
|
setting_t2x(level, &arg.setting);
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
arg.val.f = val->f;
|
|
|
|
else
|
|
|
|
arg.val.i = val->i;
|
|
|
|
res = getlevel_1(&arg, priv->cl);
|
|
|
|
if (res == NULL) {
|
|
|
|
clnt_perror(priv->cl, "getlevel_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (res->rigstatus == RIG_OK) {
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
val->f = res->val_res_u.val.f;
|
|
|
|
else
|
|
|
|
val->i = res->val_res_u.val.i;
|
|
|
|
}
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
return res->rigstatus;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_parm(RIG *rig, setting_t parm, value_t val)
|
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
int *result;
|
|
|
|
setting_arg arg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
setting_t2x(parm, &arg.setting);
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(parm))
|
|
|
|
arg.val.f = val.f;
|
|
|
|
else
|
|
|
|
arg.val.i = val.i;
|
|
|
|
result = setparm_1(&arg, priv->cl);
|
|
|
|
if (result == NULL) {
|
|
|
|
clnt_perror(priv->cl, "setparm_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *result;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_parm(RIG *rig, setting_t parm, value_t *val)
|
|
|
|
{
|
2001-12-26 23:44:05 +00:00
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
val_res *res;
|
|
|
|
setting_arg arg;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
|
|
|
|
|
|
|
setting_t2x(parm, &arg.setting);
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(parm))
|
|
|
|
arg.val.f = val->f;
|
|
|
|
else
|
|
|
|
arg.val.i = val->i;
|
|
|
|
res = getparm_1(&arg, priv->cl);
|
|
|
|
if (res == NULL) {
|
|
|
|
clnt_perror(priv->cl, "getparm_1");
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
if (res->rigstatus == RIG_OK) {
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(parm))
|
|
|
|
val->f = res->val_res_u.val.f;
|
|
|
|
else
|
|
|
|
val->i = res->val_res_u.val.i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res->rigstatus;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2002-08-23 20:01:09 +00:00
|
|
|
static int rpcrig_scan(RIG *rig, vfo_t vfo, scan_t rscan, int ch)
|
2001-12-26 23:44:05 +00:00
|
|
|
{
|
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
int *result;
|
2002-08-23 20:01:09 +00:00
|
|
|
scan_arg arg;
|
2001-12-26 23:44:05 +00:00
|
|
|
|
|
|
|
priv = (struct rpcrig_priv_data*)rig->state.priv;
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
arg.vfo = vfo;
|
2002-08-23 20:01:09 +00:00
|
|
|
arg.scan = rscan;
|
|
|
|
arg.ch = ch;
|
|
|
|
result = scan_1(&arg, priv->cl);
|
2001-12-26 23:44:05 +00:00
|
|
|
if (result == NULL) {
|
2002-08-23 20:01:09 +00:00
|
|
|
clnt_perror(priv->cl, "scan_1");
|
2001-12-26 23:44:05 +00:00
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *result;
|
|
|
|
}
|
|
|
|
|
2002-08-23 20:01:09 +00:00
|
|
|
static int rpcrig_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(vfoop, vfo_op, op);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_set_ant(RIG *rig, vfo_t vfo, ant_t ant)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setant, ant, ant);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-26 23:44:05 +00:00
|
|
|
static int rpcrig_get_ant(RIG *rig, vfo_t vfo, ant_t *ant)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getant, ant, ant);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_bank(RIG *rig, vfo_t vfo, int bank)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setbank, ch, bank);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_mem(RIG *rig, vfo_t vfo, int ch)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
SETBODYVFO1(setmem, ch, ch);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
|
|
|
{
|
2002-08-23 20:01:09 +00:00
|
|
|
GETBODYVFO1(getmem, ch, ch);
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_set_channel(RIG *rig, const channel_t *chan)
|
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-07-08 22:53:27 +00:00
|
|
|
return -RIG_ENIMPL;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_channel(RIG *rig, channel_t *chan)
|
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-07-08 22:53:27 +00:00
|
|
|
return -RIG_ENIMPL;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-23 20:01:09 +00:00
|
|
|
static int rpcrig_reset(RIG *rig, reset_t reset)
|
|
|
|
{
|
|
|
|
SETBODY1(reset, reset, reset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rpcrig_set_powerstat(RIG *rig, powerstat_t status)
|
|
|
|
{
|
|
|
|
SETBODY1(setpowerstat, powerstat, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_get_powerstat(RIG *rig, powerstat_t *status)
|
|
|
|
{
|
|
|
|
GETBODY1(getpowerstat, powerstat, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 07:46:13 +00:00
|
|
|
static int rpcrig_set_trn(RIG *rig, int trn)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-07-08 22:53:27 +00:00
|
|
|
return -RIG_ENIMPL;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-20 07:46:13 +00:00
|
|
|
static int rpcrig_get_trn(RIG *rig, int *trn)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-07-08 22:53:27 +00:00
|
|
|
return -RIG_ENIMPL;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *rpcrig_get_info(RIG *rig)
|
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rpcrig_send_dtmf(RIG *rig, vfo_t vfo, const char *digits)
|
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-07-08 22:53:27 +00:00
|
|
|
return -RIG_ENIMPL;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rpcrig_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-07-08 22:53:27 +00:00
|
|
|
return -RIG_ENIMPL;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rpcrig_send_morse(RIG *rig, vfo_t vfo, const char *msg)
|
|
|
|
{
|
2002-07-08 22:53:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE,"%s called\n", __FUNCTION__);
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-07-08 22:53:27 +00:00
|
|
|
return -RIG_ENIMPL;
|
2001-10-16 19:29:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-09-13 06:59:54 +00:00
|
|
|
#define TOK_PROGNUM TOKEN_BACKEND(1)
|
|
|
|
|
|
|
|
static const struct confparams rpcrig_cfg_params[] = {
|
|
|
|
{ TOK_PROGNUM, "prognum", "Program number", "RPC program number",
|
|
|
|
r_stringify(RIGPROG), RIG_CONF_NUMERIC, { .n = { 100000, ULONG_MAX, 1 } }
|
|
|
|
},
|
|
|
|
{ RIG_CONF_END, NULL, }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Assumes rig!=NULL, rig->state.priv!=NULL
|
|
|
|
*/
|
|
|
|
int rpcrig_set_conf(RIG *rig, token_t token, const char *val)
|
|
|
|
{
|
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
struct rig_state *rs;
|
|
|
|
|
|
|
|
rs = &rig->state;
|
|
|
|
priv = (struct rpcrig_priv_data*)rs->priv;
|
|
|
|
|
|
|
|
switch(token) {
|
|
|
|
case TOK_PROGNUM:
|
|
|
|
{
|
|
|
|
unsigned long prognum;
|
|
|
|
prognum = extract_prognum(val);
|
|
|
|
if (prognum == 0)
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
priv->prognum = prognum;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* assumes rig!=NULL,
|
|
|
|
* Assumes rig!=NULL, rig->state.priv!=NULL
|
|
|
|
* and val points to a buffer big enough to hold the conf value.
|
|
|
|
*/
|
|
|
|
int rpcrig_get_conf(RIG *rig, token_t token, char *val)
|
|
|
|
{
|
|
|
|
struct rpcrig_priv_data *priv;
|
|
|
|
struct rig_state *rs;
|
|
|
|
|
|
|
|
rs = &rig->state;
|
|
|
|
priv = (struct rpcrig_priv_data*)rs->priv;
|
|
|
|
|
|
|
|
switch(token) {
|
|
|
|
case TOK_PROGNUM:
|
|
|
|
sprintf(val, "%ld", priv->prognum);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-16 19:29:03 +00:00
|
|
|
/*
|
|
|
|
* Dummy rig capabilities.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct rig_caps rpcrig_caps = {
|
2002-08-16 17:43:02 +00:00
|
|
|
.rig_model = RIG_MODEL_RPC,
|
|
|
|
.model_name = "RPC rig",
|
|
|
|
.mfg_name = "Hamlib",
|
2003-04-22 19:31:47 +00:00
|
|
|
.version = "0.3",
|
2002-08-16 17:43:02 +00:00
|
|
|
.copyright = "LGPL",
|
2002-08-23 20:01:09 +00:00
|
|
|
.status = RIG_STATUS_ALPHA,
|
2002-08-16 17:43:02 +00:00
|
|
|
.rig_type = RIG_TYPE_OTHER,
|
|
|
|
.targetable_vfo = 0,
|
|
|
|
.ptt_type = RIG_PTT_NONE,
|
|
|
|
.dcd_type = RIG_DCD_NONE,
|
|
|
|
.port_type = RIG_PORT_NONE,
|
|
|
|
.has_get_func = RIG_FUNC_NONE,
|
|
|
|
.has_set_func = RIG_FUNC_NONE,
|
|
|
|
.has_get_level = RIG_LEVEL_NONE,
|
|
|
|
.has_set_level = RIG_LEVEL_NONE,
|
|
|
|
.has_get_parm = RIG_PARM_NONE,
|
|
|
|
.has_set_parm = RIG_PARM_NONE,
|
|
|
|
.ctcss_list = NULL,
|
|
|
|
.dcs_list = NULL,
|
|
|
|
.chan_list = { RIG_CHAN_END, },
|
|
|
|
.transceive = RIG_TRN_OFF,
|
|
|
|
.attenuator = { RIG_DBLST_END, },
|
|
|
|
.rx_range_list2 = { RIG_FRNG_END, },
|
|
|
|
.tx_range_list2 = { RIG_FRNG_END, },
|
|
|
|
.tuning_steps = { RIG_TS_END, },
|
|
|
|
.priv = NULL,
|
|
|
|
|
|
|
|
.rig_init = rpcrig_init,
|
|
|
|
.rig_cleanup = rpcrig_cleanup,
|
|
|
|
.rig_open = rpcrig_open,
|
|
|
|
.rig_close = rpcrig_close,
|
|
|
|
|
2002-09-13 06:59:54 +00:00
|
|
|
.cfgparams = rpcrig_cfg_params,
|
|
|
|
.set_conf = rpcrig_set_conf,
|
|
|
|
.get_conf = rpcrig_get_conf,
|
|
|
|
|
2002-08-16 17:43:02 +00:00
|
|
|
.set_freq = rpcrig_set_freq,
|
|
|
|
.get_freq = rpcrig_get_freq,
|
|
|
|
.set_mode = rpcrig_set_mode,
|
|
|
|
.get_mode = rpcrig_get_mode,
|
|
|
|
.set_vfo = rpcrig_set_vfo,
|
|
|
|
.get_vfo = rpcrig_get_vfo,
|
2001-10-16 19:29:03 +00:00
|
|
|
|
2002-08-16 17:43:02 +00:00
|
|
|
.set_powerstat = rpcrig_set_powerstat,
|
|
|
|
.get_powerstat = rpcrig_get_powerstat,
|
|
|
|
.set_level = rpcrig_set_level,
|
|
|
|
.get_level = rpcrig_get_level,
|
|
|
|
.set_func = rpcrig_set_func,
|
|
|
|
.get_func = rpcrig_get_func,
|
|
|
|
.set_parm = rpcrig_set_parm,
|
|
|
|
.get_parm = rpcrig_get_parm,
|
|
|
|
|
|
|
|
.get_info = rpcrig_get_info,
|
|
|
|
|
|
|
|
|
|
|
|
.set_ptt = rpcrig_set_ptt,
|
|
|
|
.get_ptt = rpcrig_get_ptt,
|
|
|
|
.get_dcd = rpcrig_get_dcd,
|
|
|
|
.set_rptr_shift = rpcrig_set_rptr_shift,
|
|
|
|
.get_rptr_shift = rpcrig_get_rptr_shift,
|
|
|
|
.set_rptr_offs = rpcrig_set_rptr_offs,
|
|
|
|
.get_rptr_offs = rpcrig_get_rptr_offs,
|
|
|
|
.set_ctcss_tone = rpcrig_set_ctcss_tone,
|
|
|
|
.get_ctcss_tone = rpcrig_get_ctcss_tone,
|
|
|
|
.set_dcs_code = rpcrig_set_dcs_code,
|
|
|
|
.get_dcs_code = rpcrig_get_dcs_code,
|
|
|
|
.set_ctcss_sql = rpcrig_set_ctcss_sql,
|
|
|
|
.get_ctcss_sql = rpcrig_get_ctcss_sql,
|
|
|
|
.set_dcs_sql = rpcrig_set_dcs_sql,
|
|
|
|
.get_dcs_sql = rpcrig_get_dcs_sql,
|
|
|
|
.set_split_freq = rpcrig_set_split_freq,
|
|
|
|
.get_split_freq = rpcrig_get_split_freq,
|
|
|
|
.set_split_mode = rpcrig_set_split_mode,
|
|
|
|
.get_split_mode = rpcrig_get_split_mode,
|
2003-04-06 18:40:36 +00:00
|
|
|
.set_split_vfo = rpcrig_set_split_vfo,
|
|
|
|
.get_split_vfo = rpcrig_get_split_vfo,
|
2002-08-16 17:43:02 +00:00
|
|
|
.set_rit = rpcrig_set_rit,
|
|
|
|
.get_rit = rpcrig_get_rit,
|
|
|
|
.set_xit = rpcrig_set_xit,
|
|
|
|
.get_xit = rpcrig_get_xit,
|
|
|
|
.set_ts = rpcrig_set_ts,
|
|
|
|
.get_ts = rpcrig_get_ts,
|
|
|
|
.set_ant = rpcrig_set_ant,
|
|
|
|
.get_ant = rpcrig_get_ant,
|
|
|
|
.set_bank = rpcrig_set_bank,
|
|
|
|
.set_mem = rpcrig_set_mem,
|
|
|
|
.get_mem = rpcrig_get_mem,
|
|
|
|
.vfo_op = rpcrig_vfo_op,
|
|
|
|
.send_dtmf = rpcrig_send_dtmf,
|
|
|
|
.recv_dtmf = rpcrig_recv_dtmf,
|
|
|
|
.send_morse = rpcrig_send_morse,
|
|
|
|
.set_channel = rpcrig_set_channel,
|
|
|
|
.get_channel = rpcrig_get_channel,
|
|
|
|
.set_trn = rpcrig_set_trn,
|
|
|
|
.get_trn = rpcrig_get_trn,
|
2002-08-23 20:01:09 +00:00
|
|
|
.scan = rpcrig_scan,
|
|
|
|
.reset = rpcrig_reset,
|
2001-10-16 19:29:03 +00:00
|
|
|
};
|
|
|
|
|
2003-04-16 22:30:43 +00:00
|
|
|
DECLARE_INITRIG_BACKEND(rpcrig)
|
2001-10-16 19:29:03 +00:00
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "rpcrig: _init called\n");
|
|
|
|
|
|
|
|
rig_register(&rpcrig_caps);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|