2008-09-21 19:34:16 +00:00
|
|
|
/*
|
|
|
|
* Hamlib Netrigctl backend - main file
|
2010-05-11 21:30:39 +00:00
|
|
|
* Copyright (c) 2001-2010 by Stephane Fillod
|
2008-09-21 19:34:16 +00:00
|
|
|
*
|
|
|
|
*
|
2011-08-20 23:37:17 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2008-09-21 19:34:16 +00:00
|
|
|
*
|
2011-08-20 23:37:17 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2008-09-21 19:34:16 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-08-20 23:37:17 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2008-09-21 19:34:16 +00:00
|
|
|
*
|
2011-08-20 23:37:17 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2008-09-21 19:34:16 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2011-08-20 23:37:17 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2008-09-21 19:34:16 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-02-04 13:41:36 +00:00
|
|
|
#include <hamlib/config.h>
|
2008-09-21 19:34:16 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "hamlib/rig.h"
|
2017-07-07 09:52:35 +00:00
|
|
|
#include "network.h"
|
|
|
|
#include "serial.h"
|
2008-09-21 19:34:16 +00:00
|
|
|
#include "iofunc.h"
|
|
|
|
#include "misc.h"
|
2010-05-11 21:30:39 +00:00
|
|
|
#include "num_stdio.h"
|
2008-09-21 19:34:16 +00:00
|
|
|
|
|
|
|
#include "dummy.h"
|
|
|
|
|
2020-10-06 20:50:37 +00:00
|
|
|
#define CMD_MAX 64
|
2021-04-29 15:49:29 +00:00
|
|
|
#define BUF_MAX 1024
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2010-05-11 21:30:39 +00:00
|
|
|
#define CHKSCN1ARG(a) if ((a) != 1) return -RIG_EPROTO; else do {} while(0)
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
struct netrigctl_priv_data
|
|
|
|
{
|
2019-02-05 18:05:51 +00:00
|
|
|
vfo_t vfo_curr;
|
|
|
|
int rigctld_vfo_mode;
|
2021-11-19 22:19:18 +00:00
|
|
|
vfo_t rx_vfo;
|
|
|
|
vfo_t tx_vfo;
|
2019-02-05 18:05:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int netrigctl_get_vfo_mode(RIG *rig)
|
|
|
|
{
|
2019-03-01 13:32:05 +00:00
|
|
|
struct netrigctl_priv_data *priv;
|
|
|
|
priv = (struct netrigctl_priv_data *)rig->state.priv;
|
|
|
|
return priv->rigctld_vfo_mode;
|
2019-02-05 18:05:51 +00:00
|
|
|
}
|
|
|
|
|
2008-10-27 22:23:36 +00:00
|
|
|
/*
|
|
|
|
* Helper function with protocol return code parsing
|
|
|
|
*/
|
|
|
|
static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf)
|
|
|
|
{
|
2019-03-01 13:32:05 +00:00
|
|
|
int ret;
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called len=%d\n", __func__, len);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
/* flush anything in the read buffer before command is sent */
|
2022-01-25 23:41:26 +00:00
|
|
|
rig_flush(&rig->state.rigport);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-25 23:41:26 +00:00
|
|
|
ret = write_block(&rig->state.rigport, (unsigned char *) cmd, len);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2018-05-09 13:14:04 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2017-07-07 09:52:35 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (strncmp(buf, NETRIGCTL_RET, strlen(NETRIGCTL_RET)) == 0)
|
|
|
|
{
|
|
|
|
return atoi(buf + strlen(NETRIGCTL_RET));
|
|
|
|
}
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return ret;
|
2008-10-27 22:23:36 +00:00
|
|
|
}
|
|
|
|
|
2019-02-05 18:05:51 +00:00
|
|
|
/* this will fill vfostr with the vfo value if the vfo mode is enabled
|
|
|
|
* otherwise string will be null terminated
|
|
|
|
* this allows us to use the string in snprintf in either mode
|
|
|
|
*/
|
|
|
|
static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
|
|
|
|
{
|
2019-12-09 23:12:13 +00:00
|
|
|
struct netrigctl_priv_data *priv;
|
|
|
|
|
2020-10-06 20:50:37 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called vfo=%s\n", __func__, rig_strvfo(vfo));
|
2020-10-07 04:14:27 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (len < 5)
|
|
|
|
{
|
2019-11-30 16:04:31 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: len must be >=5, len=%d\n", __func__, len);
|
2019-03-01 13:32:05 +00:00
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
vfostr[0] = 0;
|
|
|
|
|
|
|
|
priv = (struct netrigctl_priv_data *)rig->state.priv;
|
|
|
|
|
|
|
|
if (vfo == RIG_VFO_CURR)
|
|
|
|
{
|
2020-10-07 04:14:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: vfo==RIG_VFO_CURR, curr=%s\n", __func__,
|
|
|
|
rig_strvfo(priv->vfo_curr));
|
2019-03-01 13:32:05 +00:00
|
|
|
vfo = priv->vfo_curr;
|
2020-05-27 17:23:08 +00:00
|
|
|
|
|
|
|
if (vfo == RIG_VFO_NONE) { vfo = RIG_VFO_A; }
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
2021-11-28 18:41:10 +00:00
|
|
|
else if (vfo == RIG_VFO_RX) { vfo = priv->rx_vfo; }
|
|
|
|
else if (vfo == RIG_VFO_TX) { vfo = priv->tx_vfo; }
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2020-05-27 17:21:41 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: vfo_opt=%d\n", __func__, rig->state.vfo_opt);
|
|
|
|
|
2021-03-26 19:25:32 +00:00
|
|
|
if (rig->state.vfo_opt || priv->rigctld_vfo_mode)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2020-10-07 04:14:27 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: vfo_opt vfo=%u\n", __func__, vfo);
|
|
|
|
char *myvfo;
|
|
|
|
|
|
|
|
switch (vfo)
|
|
|
|
{
|
|
|
|
case RIG_VFO_B: myvfo = "VFOB"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_C: myvfo = "VFOC"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_MAIN: myvfo = "Main"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_MAIN_A: myvfo = "MainA"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_MAIN_B: myvfo = "MainB"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_SUB: myvfo = "Sub"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_SUB_A: myvfo = "SubA"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_SUB_B: myvfo = "SubB"; break;
|
|
|
|
|
|
|
|
case RIG_VFO_MEM: myvfo = "MEM"; break;
|
|
|
|
|
|
|
|
default: myvfo = "VFOA";
|
|
|
|
}
|
|
|
|
|
2022-01-19 05:16:45 +00:00
|
|
|
SNPRINTF(vfostr, len, " %s", myvfo);
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2019-02-05 18:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_init(RIG *rig)
|
|
|
|
{
|
2019-12-19 04:34:37 +00:00
|
|
|
// cppcheck says leak here but it's freed in cleanup
|
2020-01-05 23:07:09 +00:00
|
|
|
struct netrigctl_priv_data *priv;
|
2019-12-09 23:12:13 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (!rig || !rig->caps)
|
|
|
|
{
|
2019-02-05 18:05:51 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
2020-01-13 04:45:31 +00:00
|
|
|
rig->state.priv = (struct netrigctl_priv_data *)malloc(sizeof(
|
|
|
|
struct netrigctl_priv_data));
|
2019-02-05 18:05:51 +00:00
|
|
|
|
2020-01-13 04:45:31 +00:00
|
|
|
if (!rig->state.priv)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2019-02-05 18:05:51 +00:00
|
|
|
return -RIG_ENOMEM;
|
|
|
|
}
|
|
|
|
|
2020-01-13 04:45:31 +00:00
|
|
|
priv = rig->state.priv;
|
2019-02-05 18:05:51 +00:00
|
|
|
memset(priv, 0, sizeof(struct netrigctl_priv_data));
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, rig->caps->version);
|
2019-02-05 18:05:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* set arbitrary initial status
|
|
|
|
* VFO will be updated in open call
|
|
|
|
*/
|
|
|
|
priv->vfo_curr = RIG_VFO_A;
|
|
|
|
priv->rigctld_vfo_mode = 0;
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2019-02-05 18:05:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_cleanup(RIG *rig)
|
|
|
|
{
|
2019-03-01 13:32:05 +00:00
|
|
|
if (rig->state.priv) { free(rig->state.priv); }
|
|
|
|
|
|
|
|
rig->state.priv = NULL;
|
|
|
|
return RIG_OK;
|
2019-02-05 18:05:51 +00:00
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-29 15:49:29 +00:00
|
|
|
int parse_array_int(const char *s, const char *delim, int *array, int array_len)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
char *dup = strdup(s);
|
|
|
|
char *rest = dup;
|
2021-04-29 22:23:37 +00:00
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
while ((p = strtok_r(rest, delim, &rest)))
|
2021-04-29 15:49:29 +00:00
|
|
|
{
|
2021-04-29 22:23:37 +00:00
|
|
|
if (n == array_len) // too many items
|
|
|
|
{
|
2021-04-29 15:49:29 +00:00
|
|
|
return n;
|
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2021-04-29 15:49:29 +00:00
|
|
|
array[n] = atoi(p);
|
|
|
|
//printf("%d\n", array[n]);
|
|
|
|
++n;
|
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2021-04-29 15:49:29 +00:00
|
|
|
free(dup);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2021-04-29 22:23:37 +00:00
|
|
|
int parse_array_double(const char *s, const char *delim, double *array,
|
|
|
|
int array_len)
|
2021-04-29 15:49:29 +00:00
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
char *dup = strdup(s);
|
|
|
|
char *rest = dup;
|
2021-04-29 22:23:37 +00:00
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
while ((p = strtok_r(rest, delim, &rest)))
|
2021-04-29 15:49:29 +00:00
|
|
|
{
|
2021-04-29 22:23:37 +00:00
|
|
|
if (n == array_len) // too many items
|
|
|
|
{
|
2021-04-29 15:49:29 +00:00
|
|
|
return n;
|
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2021-04-29 15:49:29 +00:00
|
|
|
array[n] = atof(p);
|
|
|
|
//printf("%f\n", array[n]);
|
|
|
|
++n;
|
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2021-04-29 15:49:29 +00:00
|
|
|
free(dup);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-09-21 19:34:16 +00:00
|
|
|
static int netrigctl_open(RIG *rig)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret, i;
|
2019-03-01 13:32:05 +00:00
|
|
|
struct rig_state *rs = &rig->state;
|
|
|
|
int prot_ver;
|
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2019-12-09 23:12:13 +00:00
|
|
|
struct netrigctl_priv_data *priv;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
priv = (struct netrigctl_priv_data *)rig->state.priv;
|
2021-11-19 22:19:18 +00:00
|
|
|
priv->rx_vfo = RIG_VFO_A;
|
|
|
|
priv->tx_vfo = RIG_VFO_B;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\chk_vfo\n");
|
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2021-02-28 15:46:01 +00:00
|
|
|
if (sscanf(buf, "CHKVFO %d", &priv->rigctld_vfo_mode) == 1)
|
2021-02-05 23:33:59 +00:00
|
|
|
{
|
2021-11-24 15:03:26 +00:00
|
|
|
rig->state.vfo_opt = 1;
|
2021-02-05 23:33:59 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: chkvfo=%d\n", __func__, priv->rigctld_vfo_mode);
|
|
|
|
}
|
|
|
|
else if (ret == 2)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2020-05-27 17:21:41 +00:00
|
|
|
if (buf[0]) { sscanf(buf, "%d", &priv->rigctld_vfo_mode); }
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
2019-08-30 23:38:25 +00:00
|
|
|
else if (ret < 0)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_WARN, "%s: chk_vfo error: %s\n", __func__,
|
2019-03-01 13:32:05 +00:00
|
|
|
rigerror(ret));
|
|
|
|
}
|
2020-05-27 17:23:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: unknown return from netrigctl_transaction=%d\n",
|
|
|
|
__func__, ret);
|
2020-05-27 17:21:41 +00:00
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo_mode=%d\n", __func__,
|
2019-03-01 13:32:05 +00:00
|
|
|
priv->rigctld_vfo_mode);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\dump_state\n");
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
prot_ver = atoi(buf);
|
|
|
|
#define RIGCTLD_PROT_VER 0
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (prot_ver < RIGCTLD_PROT_VER)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-07-24 19:23:38 +00:00
|
|
|
rs->deprecated_itu_region = atoi(buf);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2021-03-06 18:37:53 +00:00
|
|
|
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = num_sscanf(buf, "%"SCNfreq"%"SCNfreq"%"SCNXll"%d%d%x%x",
|
2020-03-19 17:10:20 +00:00
|
|
|
&(rs->rx_range_list[i].startf),
|
|
|
|
&(rs->rx_range_list[i].endf),
|
|
|
|
&(rs->rx_range_list[i].modes),
|
|
|
|
&(rs->rx_range_list[i].low_power),
|
|
|
|
&(rs->rx_range_list[i].high_power),
|
|
|
|
&(rs->rx_range_list[i].vfo),
|
|
|
|
&(rs->rx_range_list[i].ant)
|
2019-03-01 13:32:05 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if (ret != 7)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RIG_IS_FRNG_END(rs->rx_range_list[i]))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-06 18:37:53 +00:00
|
|
|
for (i = 0; i < HAMLIB_FRQRANGESIZ; i++)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = num_sscanf(buf, "%"SCNfreq"%"SCNfreq"%"SCNXll"%d%d%x%x",
|
2019-08-18 04:20:48 +00:00
|
|
|
&rs->tx_range_list[i].startf,
|
|
|
|
&rs->tx_range_list[i].endf,
|
2019-03-01 13:32:05 +00:00
|
|
|
&rs->tx_range_list[i].modes,
|
|
|
|
&rs->tx_range_list[i].low_power,
|
|
|
|
&rs->tx_range_list[i].high_power,
|
|
|
|
&rs->tx_range_list[i].vfo,
|
|
|
|
&rs->tx_range_list[i].ant
|
|
|
|
);
|
|
|
|
|
|
|
|
if (ret != 7)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RIG_IS_FRNG_END(rs->tx_range_list[i]))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2021-04-22 04:48:29 +00:00
|
|
|
|
|
|
|
switch (i)
|
2021-04-14 03:22:05 +00:00
|
|
|
{
|
|
|
|
}
|
2021-04-22 04:48:29 +00:00
|
|
|
|
2021-04-14 03:22:05 +00:00
|
|
|
rig->caps->tx_range_list1->startf = rs->tx_range_list[i].startf;
|
|
|
|
rig->caps->tx_range_list1->endf = rs->tx_range_list[i].endf;
|
|
|
|
rig->caps->tx_range_list1->modes = rs->tx_range_list[i].modes;
|
|
|
|
rig->caps->tx_range_list1->low_power = rs->tx_range_list[i].low_power;
|
|
|
|
rig->caps->tx_range_list1->high_power = rs->tx_range_list[i].high_power;
|
|
|
|
rig->caps->tx_range_list1->vfo = rs->tx_range_list[i].vfo;
|
|
|
|
rig->caps->tx_range_list1->ant = rs->tx_range_list[i].ant;
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2021-03-06 18:37:53 +00:00
|
|
|
for (i = 0; i < HAMLIB_TSLSTSIZ; i++)
|
2017-03-31 17:17:16 +00:00
|
|
|
{
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = sscanf(buf, "%"SCNXll"%ld",
|
|
|
|
&rs->tuning_steps[i].modes,
|
|
|
|
&rs->tuning_steps[i].ts);
|
|
|
|
|
|
|
|
if (ret != 2)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RIG_IS_TS_END(rs->tuning_steps[i]))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2017-03-31 17:17:16 +00:00
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-06 18:37:53 +00:00
|
|
|
for (i = 0; i < HAMLIB_FLTLSTSIZ; i++)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = sscanf(buf, "%"SCNXll"%ld",
|
|
|
|
&rs->filters[i].modes,
|
|
|
|
&rs->filters[i].width);
|
|
|
|
|
|
|
|
if (ret != 2)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RIG_IS_FLT_END(rs->filters[i]))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
#if 0
|
|
|
|
/* TODO */
|
2021-03-11 12:42:21 +00:00
|
|
|
chan_t chan_list[HAMLIB_CHANLSTSIZ]; /*!< Channel list, zero ended */
|
2019-03-01 13:32:05 +00:00
|
|
|
#endif
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 13:47:01 +00:00
|
|
|
rig->caps->max_rit = rs->max_rit = atol(buf);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 13:47:01 +00:00
|
|
|
rig->caps->max_xit = rs->max_xit = atol(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 13:47:01 +00:00
|
|
|
rig->caps->max_ifshift = rs->max_ifshift = atol(buf);
|
2008-11-02 17:32:37 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
rs->announces = atoi(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = sscanf(buf, "%d%d%d%d%d%d%d",
|
|
|
|
&rs->preamp[0], &rs->preamp[1],
|
|
|
|
&rs->preamp[2], &rs->preamp[3],
|
|
|
|
&rs->preamp[4], &rs->preamp[5],
|
|
|
|
&rs->preamp[6]);
|
2021-04-24 13:47:01 +00:00
|
|
|
rig->caps->preamp[0] = rs->preamp[0];
|
|
|
|
rig->caps->preamp[1] = rs->preamp[1];
|
|
|
|
rig->caps->preamp[2] = rs->preamp[2];
|
|
|
|
rig->caps->preamp[3] = rs->preamp[3];
|
|
|
|
rig->caps->preamp[4] = rs->preamp[4];
|
|
|
|
rig->caps->preamp[5] = rs->preamp[5];
|
|
|
|
rig->caps->preamp[6] = rs->preamp[6];
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-06 18:37:53 +00:00
|
|
|
if (ret < 0 || ret >= HAMLIB_MAXDBLSTSIZ)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
|
|
|
ret = 0;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 13:47:01 +00:00
|
|
|
rig->caps->preamp[ret] = rs->preamp[ret] = RIG_DBLST_END;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = sscanf(buf, "%d%d%d%d%d%d%d",
|
|
|
|
&rs->attenuator[0], &rs->attenuator[1],
|
|
|
|
&rs->attenuator[2], &rs->attenuator[3],
|
|
|
|
&rs->attenuator[4], &rs->attenuator[5],
|
|
|
|
&rs->attenuator[6]);
|
2021-04-24 13:47:01 +00:00
|
|
|
rig->caps->attenuator[0] = rs->attenuator[0];
|
|
|
|
rig->caps->attenuator[1] = rs->attenuator[1];
|
|
|
|
rig->caps->attenuator[2] = rs->attenuator[2];
|
|
|
|
rig->caps->attenuator[3] = rs->attenuator[3];
|
|
|
|
rig->caps->attenuator[4] = rs->attenuator[4];
|
|
|
|
rig->caps->attenuator[5] = rs->attenuator[5];
|
|
|
|
rig->caps->attenuator[6] = rs->attenuator[6];
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-06 18:37:53 +00:00
|
|
|
if (ret < 0 || ret >= HAMLIB_MAXDBLSTSIZ)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
|
|
|
ret = 0;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 13:47:01 +00:00
|
|
|
rig->caps->attenuator[ret] = rs->attenuator[ret] = RIG_DBLST_END;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 14:16:40 +00:00
|
|
|
rig->caps->has_get_func = rs->has_get_func = strtoll(buf, NULL, 0);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 14:16:40 +00:00
|
|
|
rig->caps->has_set_func = rs->has_set_func = strtoll(buf, NULL, 0);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 14:16:40 +00:00
|
|
|
rig->caps->has_get_level = rs->has_get_level = strtoll(buf, NULL, 0);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-28 22:39:08 +00:00
|
|
|
#if 0 // don't think we need this anymore
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (rs->has_get_level & RIG_LEVEL_RAWSTR)
|
|
|
|
{
|
|
|
|
/* include STRENGTH because the remote rig may be able to
|
|
|
|
provide a front end emulation, if it can't then an
|
|
|
|
-RIG_EINVAL will be returned */
|
|
|
|
rs->has_get_level |= RIG_LEVEL_STRENGTH;
|
2021-04-24 14:16:40 +00:00
|
|
|
rig->caps->has_get_level |= RIG_LEVEL_STRENGTH;
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2021-04-28 22:39:08 +00:00
|
|
|
#endif
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2019-02-05 18:05:51 +00:00
|
|
|
|
2021-04-24 14:16:40 +00:00
|
|
|
rig->caps->has_set_level = rs->has_set_level = strtoll(buf, NULL, 0);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-09-07 04:52:48 +00:00
|
|
|
rs->has_get_parm = strtoll(buf, NULL, 0);
|
2019-02-05 18:05:51 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-24 14:16:40 +00:00
|
|
|
rig->caps->has_set_parm = rs->has_set_parm = strtoll(buf, NULL, 0);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
#if 0
|
|
|
|
gran_t level_gran[RIG_SETTING_MAX]; /*!< level granularity */
|
|
|
|
gran_t parm_gran[RIG_SETTING_MAX]; /*!< parm granularity */
|
|
|
|
#endif
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-15 22:51:22 +00:00
|
|
|
for (i = 0; i < HAMLIB_FRQRANGESIZ
|
|
|
|
&& !RIG_IS_FRNG_END(rs->rx_range_list[i]); i++)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
|
|
|
rs->mode_list |= rs->rx_range_list[i].modes;
|
|
|
|
rs->vfo_list |= rs->rx_range_list[i].vfo;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-15 22:51:22 +00:00
|
|
|
for (i = 0; i < HAMLIB_FRQRANGESIZ
|
|
|
|
&& !RIG_IS_FRNG_END(rs->tx_range_list[i]); i++)
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
|
|
|
rs->mode_list |= rs->tx_range_list[i].modes;
|
|
|
|
rs->vfo_list |= rs->tx_range_list[i].vfo;
|
|
|
|
}
|
2021-11-28 18:41:10 +00:00
|
|
|
|
|
|
|
if (rs->vfo_list == 0)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo_list empty, defaulting to A/B\n",
|
|
|
|
__func__);
|
|
|
|
rs->vfo_list = RIG_VFO_A | RIG_VFO_B;
|
2021-11-19 22:19:18 +00:00
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-04-04 14:38:50 +00:00
|
|
|
if (prot_ver == 0) { return RIG_OK; }
|
|
|
|
|
|
|
|
// otherwise we continue reading protocol 1 fields
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2021-04-29 15:49:29 +00:00
|
|
|
char setting[32], value[1024];
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2020-04-04 14:38:50 +00:00
|
|
|
strtok(buf, "\r\n"); // chop the EOL
|
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strncmp(buf, "done", 4) == 0) { return RIG_OK; }
|
|
|
|
|
2022-04-02 21:21:10 +00:00
|
|
|
if (sscanf(buf, "%31[^=]=%1023[^\t\n]", setting, value) == 2)
|
2020-04-04 14:38:50 +00:00
|
|
|
{
|
|
|
|
if (strcmp(setting, "vfo_ops") == 0)
|
|
|
|
{
|
2020-09-07 04:52:48 +00:00
|
|
|
rig->caps->vfo_ops = strtoll(value, NULL, 0);
|
2020-06-10 03:37:03 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: %s set to %d\n", __func__, setting,
|
|
|
|
rig->caps->vfo_ops);
|
2020-04-04 14:38:50 +00:00
|
|
|
}
|
2020-05-30 21:59:36 +00:00
|
|
|
else if (strcmp(setting, "ptt_type") == 0)
|
|
|
|
{
|
2020-06-01 11:21:48 +00:00
|
|
|
ptt_type_t temp = (ptt_type_t)strtol(value, NULL, 0);
|
2022-05-20 14:06:17 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: ptt_type='%s'(%d)\n", __func__, value, temp);
|
2020-06-10 03:37:03 +00:00
|
|
|
|
2022-05-21 18:23:51 +00:00
|
|
|
if (RIG_PTT_RIG_MICDATA == rig->state.pttport.type.ptt
|
|
|
|
|| temp == RIG_PTT_RIG_MICDATA)
|
2020-06-01 11:21:48 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* remote PTT must always be RIG_PTT_RIG_MICDATA
|
|
|
|
* if there is any PTT capability and we have not
|
|
|
|
* locally overridden it
|
|
|
|
*/
|
2022-01-25 23:41:26 +00:00
|
|
|
rig->state.pttport.type.ptt = RIG_PTT_RIG_MICDATA;
|
2021-04-24 04:40:40 +00:00
|
|
|
rig->caps->ptt_type = RIG_PTT_RIG_MICDATA;
|
2020-06-10 03:37:03 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: %s set to %d\n", __func__, setting,
|
2022-01-25 23:41:26 +00:00
|
|
|
rig->state.pttport.type.ptt);
|
2020-06-01 11:21:48 +00:00
|
|
|
}
|
2021-04-24 04:40:40 +00:00
|
|
|
else
|
|
|
|
{
|
2022-05-20 14:06:17 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt_type= %d\n", __func__, temp);
|
2022-01-25 23:41:26 +00:00
|
|
|
rig->state.pttport.type.ptt = temp;
|
2021-04-24 04:40:40 +00:00
|
|
|
rig->caps->ptt_type = temp;
|
|
|
|
}
|
2020-05-30 21:59:36 +00:00
|
|
|
}
|
2021-08-26 11:49:24 +00:00
|
|
|
|
2021-06-29 03:27:26 +00:00
|
|
|
// setting targetable_vfo this way breaks WSJTX in rig split with rigctld
|
|
|
|
// Ends up putting VFOB freq on VFOA
|
|
|
|
// Have to figure out why but disabling this fixes it for now
|
2021-08-25 20:13:21 +00:00
|
|
|
#if 0
|
2020-10-07 04:14:27 +00:00
|
|
|
else if (strcmp(setting, "targetable_vfo") == 0)
|
|
|
|
{
|
2021-03-31 16:40:48 +00:00
|
|
|
rig->caps->targetable_vfo = strtol(value, NULL, 0);
|
2021-04-04 17:50:07 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: targetable_vfo=0x%2x\n", __func__,
|
|
|
|
rig->caps->targetable_vfo);
|
2021-01-08 22:37:53 +00:00
|
|
|
}
|
2021-08-26 11:49:24 +00:00
|
|
|
|
2021-06-29 03:27:26 +00:00
|
|
|
#endif
|
2021-01-08 22:37:53 +00:00
|
|
|
else if (strcmp(setting, "has_set_vfo") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
2021-01-09 16:13:17 +00:00
|
|
|
|
|
|
|
if (!has) { rig->caps->set_vfo = NULL; }
|
2021-01-08 22:37:53 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(setting, "has_get_vfo") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
2021-01-09 16:13:17 +00:00
|
|
|
|
|
|
|
if (!has) { rig->caps->get_vfo = NULL; }
|
2021-01-08 22:37:53 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(setting, "has_set_freq") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
2021-01-09 16:13:17 +00:00
|
|
|
|
|
|
|
if (!has) { rig->caps->set_freq = NULL; }
|
2021-01-08 22:37:53 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(setting, "has_get_freq") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
2021-01-09 16:13:17 +00:00
|
|
|
|
|
|
|
if (!has) { rig->caps->get_freq = NULL; }
|
2020-10-07 04:14:27 +00:00
|
|
|
}
|
2021-04-28 22:39:08 +00:00
|
|
|
else if (strcmp(setting, "has_set_conf") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
|
|
|
|
|
|
|
if (!has) { rig->caps->set_conf = NULL; }
|
|
|
|
}
|
|
|
|
else if (strcmp(setting, "has_get_conf") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
|
|
|
|
|
|
|
if (!has) { rig->caps->get_conf = NULL; }
|
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2021-04-28 22:39:08 +00:00
|
|
|
#if 0 // for the future
|
|
|
|
else if (strcmp(setting, "has_set_trn") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
|
|
|
|
|
|
|
if (!has) { rig->caps->set_trn = NULL; }
|
|
|
|
}
|
|
|
|
else if (strcmp(setting, "has_get_trn") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
|
|
|
|
|
|
|
if (!has) { rig->caps->get_trn = NULL; }
|
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
2021-04-28 22:39:08 +00:00
|
|
|
#endif
|
|
|
|
else if (strcmp(setting, "has_power2mW") == 0)
|
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
|
|
|
|
|
|
|
if (!has) { rig->caps->power2mW = NULL; }
|
|
|
|
}
|
2021-04-29 15:49:29 +00:00
|
|
|
else if (strcmp(setting, "has_mW2power") == 0)
|
2021-04-28 22:39:08 +00:00
|
|
|
{
|
|
|
|
int has = strtol(value, NULL, 0);
|
|
|
|
|
|
|
|
if (!has) { rig->caps->mW2power = NULL; }
|
|
|
|
}
|
2021-04-09 20:35:30 +00:00
|
|
|
else if (strcmp(setting, "timeout") == 0)
|
|
|
|
{
|
2021-07-12 16:22:26 +00:00
|
|
|
// use the rig's timeout value pluse 500ms for potential network delays
|
|
|
|
rig->caps->timeout = strtol(value, NULL, 0) + 500;
|
2021-04-22 04:48:29 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: timeout value = '%s', final timeout=%d\n",
|
|
|
|
__func__, value, rig->caps->timeout);
|
2021-04-09 20:35:30 +00:00
|
|
|
}
|
2021-12-12 04:54:54 +00:00
|
|
|
else if (strcmp(setting, "rig_model") == 0)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: rig_model=%s\n", __func__, value);
|
|
|
|
}
|
|
|
|
else if (strcmp(setting, "rigctld_version") == 0)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: rigctld_version=%s\n", __func__, value);
|
|
|
|
}
|
2021-04-29 15:49:29 +00:00
|
|
|
else if (strcmp(setting, "ctcss_list") == 0)
|
|
|
|
{
|
|
|
|
int n;
|
|
|
|
double ctcss[CTCSS_LIST_SIZE];
|
|
|
|
rig->caps->ctcss_list = calloc(CTCSS_LIST_SIZE, sizeof(tone_t));
|
|
|
|
n = parse_array_double(value, " \n\r", ctcss, CTCSS_LIST_SIZE);
|
2021-04-29 22:23:37 +00:00
|
|
|
|
|
|
|
for (i = 0; i < CTCSS_LIST_SIZE && ctcss[i] != 0; ++i) { rig->caps->ctcss_list[i] = ctcss[i] * 10; }
|
|
|
|
|
|
|
|
if (n < CTCSS_LIST_SIZE) { rig->caps->ctcss_list[n] = 0; }
|
2021-04-29 15:49:29 +00:00
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
else if (strcmp(setting, "dcs_list") == 0)
|
2021-04-29 15:49:29 +00:00
|
|
|
{
|
|
|
|
int n;
|
2021-04-29 22:23:37 +00:00
|
|
|
int dcs[DCS_LIST_SIZE + 1];
|
2021-04-29 15:49:29 +00:00
|
|
|
rig->caps->dcs_list = calloc(DCS_LIST_SIZE, sizeof(tone_t));
|
|
|
|
n = parse_array_int(value, " \n\r", dcs, DCS_LIST_SIZE);
|
2021-04-29 22:23:37 +00:00
|
|
|
|
|
|
|
for (i = 0; i < DCS_LIST_SIZE && dcs[i] != 0; i++) { rig->caps->dcs_list[i] = dcs[i]; }
|
|
|
|
|
|
|
|
if (n < DCS_LIST_SIZE) { rig->caps->dcs_list[n] = 0; }
|
2021-04-29 15:49:29 +00:00
|
|
|
}
|
2020-04-04 14:38:50 +00:00
|
|
|
else
|
|
|
|
{
|
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
|
|
|
// not an error -- just a warning for backward compatibility
|
2020-04-04 14:38:50 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: unknown setting='%s'\n", __func__, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR,
|
|
|
|
"%s: invalid dumpcaps line, expected 'setting=value', got '%s'\n", __func__,
|
|
|
|
buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
while (1);
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_close(RIG *rig)
|
|
|
|
{
|
2020-05-03 22:08:29 +00:00
|
|
|
int ret;
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-05-03 22:08:29 +00:00
|
|
|
ret = netrigctl_transaction(rig, "q\n", 2, buf);
|
|
|
|
|
|
|
|
if (ret != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: close error %s\n", __func__, rigerror(ret));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-05-28 04:40:33 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: done\n", __func__);
|
2020-05-03 22:24:42 +00:00
|
|
|
usleep(10 * 1000);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-05-27 17:21:41 +00:00
|
|
|
#if 1 // implement set_freq VFO later if it can be detected
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "F%s %"FREQFMT"\n", vfostr, freq);
|
2020-05-13 22:44:17 +00:00
|
|
|
#else
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "F %"FREQFMT"\n", freq);
|
2020-05-13 22:44:17 +00:00
|
|
|
#endif
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2020-05-27 17:23:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: cmd=%s\n", __func__, strtok(cmd, "\r\n"));
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
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
|
|
|
#if 0 // disable until we figure out if we can do this without breaking backwards compatibility
|
2020-04-22 15:03:26 +00:00
|
|
|
char vfotmp[16];
|
2020-05-27 17:21:41 +00:00
|
|
|
#endif
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-07-03 13:05:13 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called, vfo=%s\n", __func__,
|
|
|
|
rig_strvfo(vfo));
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "f%s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2020-05-27 17:23:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: cmd=%s, reply=%s\n", __func__, strtok(cmd,
|
|
|
|
"\r\n"), buf);
|
2020-05-27 17:21:41 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
CHKSCN1ARG(num_sscanf(buf, "%"SCNfreq, freq));
|
2020-05-03 22:08:29 +00:00
|
|
|
|
2020-05-13 22:44:17 +00:00
|
|
|
#if 0 // implement set_freq VFO later if it can be detected
|
2022-01-25 23:41:26 +00:00
|
|
|
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1);
|
2020-05-03 22:08:29 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*vfotmp = rig_parse_vfo(buf);
|
2020-05-13 22:44:17 +00:00
|
|
|
#endif
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
|
|
|
|
pbwidth_t width)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-10-06 20:50:37 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called, vfo=%s\n", __func__, rig_strvfo(vfo));
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "M%s %s %li\n",
|
2022-02-05 21:27:43 +00:00
|
|
|
vfostr, rig_strrmode(mode), width);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
|
|
|
|
pbwidth_t *width)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-10-06 20:50:37 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called, vfo=%s\n", __func__, rig_strvfo(vfo));
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "m%s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-07-03 21:59:52 +00:00
|
|
|
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*mode = rig_parse_mode(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*width = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_vfo(RIG *rig, vfo_t vfo)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-02-20 20:54:50 +00:00
|
|
|
char vfostr[16] = "";
|
2021-01-08 22:37:53 +00:00
|
|
|
struct netrigctl_priv_data *priv;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-01-08 22:37:53 +00:00
|
|
|
priv = (struct netrigctl_priv_data *)rig->state.priv;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "V%s %s\n", vfostr, rig_strvfo(vfo));
|
2020-05-15 19:17:59 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd='%s'\n", __func__, cmd);
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2021-01-08 22:37:53 +00:00
|
|
|
|
|
|
|
priv->vfo_curr = vfo; // remember our vfo
|
2021-06-14 03:53:18 +00:00
|
|
|
rig->state.current_vfo = vfo;
|
2021-01-08 22:37:53 +00:00
|
|
|
return ret;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_vfo(RIG *rig, vfo_t *vfo)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2019-12-09 23:12:13 +00:00
|
|
|
struct netrigctl_priv_data *priv;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
priv = (struct netrigctl_priv_data *)rig->state.priv;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "v\n");
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-01-09 16:13:17 +00:00
|
|
|
if (ret == -RIG_ENAVAIL || ret == -RIG_ENIMPL)
|
|
|
|
{
|
2021-01-08 22:37:53 +00:00
|
|
|
// for rigs without get_vfo we'll use our saved vfo
|
|
|
|
*vfo = priv->vfo_curr;
|
2021-01-09 16:13:17 +00:00
|
|
|
return RIG_OK;
|
2021-01-08 22:37:53 +00:00
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-07-03 21:59:52 +00:00
|
|
|
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*vfo = rig_parse_vfo(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
priv->vfo_curr = *vfo;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-26 19:26:56 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, ptt=%d\n", __func__,
|
|
|
|
rig_strvfo(vfo), ptt);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "T%s %d\n", vfostr, ptt);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-03-26 19:25:32 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: cmd=%s", __func__, cmd);
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "t%s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*ptt = atoi(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\get_dcd%s\n", vfostr); /* FIXME */
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-10-27 22:23:36 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*dcd = atoi(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_rptr_shift(RIG *rig, vfo_t vfo,
|
|
|
|
rptr_shift_t rptr_shift)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "R%s %s\n", vfostr, rig_strptrshift(rptr_shift));
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_rptr_shift(RIG *rig, vfo_t vfo,
|
|
|
|
rptr_shift_t *rptr_shift)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "r%s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-07-03 21:59:52 +00:00
|
|
|
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*rptr_shift = rig_parse_rptr_shift(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "O%s %ld\n", vfostr, rptr_offs);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "o%s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*rptr_offs = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "C%s %u\n", vfostr, tone);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "c%s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*tone = atoi(buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "D%s %u\n", vfostr, code);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
static int netrigctl_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
2019-02-05 18:05:51 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "d%s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*code = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\set_ctcss_sql%s %u\n", vfostr, tone);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\get_ctcss_sql%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*tone = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_dcs_sql(RIG *rig, vfo_t vfo, unsigned int code)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\set_dcs_sql%s %u\n", vfostr, code);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_get_dcs_sql(RIG *rig, vfo_t vfo, unsigned int *code)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\get_dcs_sql%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*code = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "I%s %"FREQFMT"\n", vfostr, tx_freq);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "i%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
CHKSCN1ARG(num_sscanf(buf, "%"SCNfreq, tx_freq));
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
|
|
|
|
pbwidth_t tx_width)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "X%s %s %li\n",
|
2022-02-05 21:27:43 +00:00
|
|
|
vfostr, rig_strrmode(tx_mode), tx_width);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
|
|
|
|
pbwidth_t *tx_width)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "x%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
2020-07-03 21:59:52 +00:00
|
|
|
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
*tx_mode = rig_parse_mode(buf);
|
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*tx_width = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
|
|
|
|
vfo_t tx_vfo)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, vfotx=%s, split=%d\n", __func__,
|
|
|
|
rig_strvfo(vfo), rig_strvfo(tx_vfo), split);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "S%s %d %s\n", vfostr, split, rig_strvfo(tx_vfo));
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
|
|
|
|
vfo_t *tx_vfo)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "s%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*split = atoi(buf);
|
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-03 21:59:52 +00:00
|
|
|
if (buf[ret - 1] == '\n') { buf[ret - 1] = '\0'; } /* chomp */
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
*tx_vfo = rig_parse_vfo(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "J%s %ld\n", vfostr, rit);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "j%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*rit = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "Z%s %ld\n", vfostr, xit);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "z%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*xit = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "N%s %ld\n", vfostr, ts);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "n%s\n", vfostr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ts = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "U%s %s %i\n", vfostr, rig_strfunc(func), status);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "u%s %s\n", vfostr, rig_strfunc(func));
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*status = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_level(RIG *rig, vfo_t vfo, setting_t level,
|
|
|
|
value_t val)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
char lstr[32];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
{
|
2022-01-17 22:59:31 +00:00
|
|
|
SNPRINTF(lstr, sizeof(lstr), "%f", val.f);
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-17 22:59:31 +00:00
|
|
|
SNPRINTF(lstr, sizeof(lstr), "%d", val.i);
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-19 05:16:45 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "L%s %s %s\n", vfostr, rig_strlevel(level),
|
2022-02-05 21:27:43 +00:00
|
|
|
lstr);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_level(RIG *rig, vfo_t vfo, setting_t level,
|
|
|
|
value_t *val)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "l%s %s\n", vfostr, rig_strlevel(level));
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RIG_LEVEL_IS_FLOAT(level))
|
|
|
|
{
|
|
|
|
val->f = atof(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val->i = atoi(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_powerstat(RIG *rig, powerstat_t status)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\set_powerstat %d\n", status);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_powerstat(RIG *rig, powerstat_t *status)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\get_powerstat\n");
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*status = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_parm(RIG *rig, setting_t parm, value_t val)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
char pstr[32];
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (RIG_PARM_IS_FLOAT(parm))
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(pstr, sizeof(pstr), "%f", val.f);
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(pstr, sizeof(pstr), "%d", val.i);
|
2019-03-01 13:32:05 +00:00
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-19 05:16:45 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "P %s %s\n", rig_strparm(parm), pstr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_parm(RIG *rig, setting_t parm, value_t *val)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "p %s\n", rig_strparm(parm));
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RIG_PARM_IS_FLOAT(parm))
|
|
|
|
{
|
|
|
|
val->f = atoi(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
val->i = atoi(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-21 23:53:12 +00:00
|
|
|
static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2020-01-30 18:12:13 +00:00
|
|
|
int i_ant = 0;
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x, option=%d\n", __func__,
|
|
|
|
ant, option.i);
|
2020-01-30 18:12:13 +00:00
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
switch (ant)
|
|
|
|
{
|
|
|
|
case RIG_ANT_1: i_ant = 0; break;
|
|
|
|
|
|
|
|
case RIG_ANT_2: i_ant = 1; break;
|
|
|
|
|
|
|
|
case RIG_ANT_3: i_ant = 2; break;
|
|
|
|
|
|
|
|
case RIG_ANT_4: i_ant = 3; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: more than 4 antennas? ant=0x%02x\n", __func__,
|
|
|
|
ant);
|
2020-01-30 18:12:13 +00:00
|
|
|
}
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "Y%s %d %d\n", vfostr, i_ant, option.i);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
|
|
|
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
if (ant == RIG_ANT_CURR)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "y%s\n", vfostr);
|
2020-02-02 14:38:10 +00:00
|
|
|
}
|
2020-02-23 17:26:09 +00:00
|
|
|
else
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "y%s %u\n", vfostr, ant);
|
2020-02-02 14:38:10 +00:00
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
2020-01-21 23:53:12 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: buf='%s'\n", __func__, buf);
|
2020-03-19 17:10:20 +00:00
|
|
|
ret = sscanf(buf, "%u\n", ant_curr);
|
2020-01-21 23:53:12 +00:00
|
|
|
|
|
|
|
if (ret != 1)
|
|
|
|
{
|
2020-02-23 17:26:09 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: expected 1 ant integer in '%s', got %d\n",
|
|
|
|
__func__, buf,
|
2020-01-21 23:53:12 +00:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
if (ant != RIG_ANT_CURR)
|
|
|
|
{
|
2020-02-02 14:38:10 +00:00
|
|
|
ret = sscanf(buf, "%d\n", &option->i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret != 1)
|
|
|
|
{
|
2020-02-23 17:26:09 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: expected 1 option integer in '%s', got %d\n",
|
|
|
|
__func__, buf,
|
2020-02-02 14:38:10 +00:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
ret = read_string(&rig->state.rigport, (unsigned char *) buf, BUF_MAX, "\n", 1,
|
|
|
|
0, 1);
|
2020-01-21 23:53:12 +00:00
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
ret = sscanf(buf, "%d\n", &(option->i));
|
2020-01-21 23:53:12 +00:00
|
|
|
|
|
|
|
if (ret != 1)
|
|
|
|
{
|
2020-02-23 17:26:09 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: expected 1 option integer in '%s', got %d\n",
|
|
|
|
__func__, buf,
|
2020-01-21 23:53:12 +00:00
|
|
|
ret);
|
|
|
|
}
|
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_bank(RIG *rig, vfo_t vfo, int bank)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "B %d\n", bank);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_set_mem(RIG *rig, vfo_t vfo, int ch)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "E%s %d\n", vfostr, ch);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2020-10-06 20:50:37 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret != RIG_OK) { return ret; }
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "e %s\n", vfostr);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
*ch = atoi(buf);
|
|
|
|
|
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "g %s %d\n", rig_strscan(scan), ch);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
2021-11-20 22:26:47 +00:00
|
|
|
char vfostr[16] = "";
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-11-20 22:26:47 +00:00
|
|
|
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
|
|
|
|
|
|
|
|
if (ret != RIG_OK) { return ret; }
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "G%s %s\n", vfostr, rig_strvfop(op));
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 05:32:14 +00:00
|
|
|
static int netrigctl_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2019-03-01 13:32:05 +00:00
|
|
|
return -RIG_ENIMPL;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-30 20:53:55 +00:00
|
|
|
static int netrigctl_get_channel(RIG *rig, vfo_t vfo, channel_t *chan,
|
|
|
|
int read_only)
|
2008-09-21 19:34:16 +00:00
|
|
|
{
|
2019-03-01 13:32:05 +00:00
|
|
|
return -RIG_ENIMPL;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char *netrigctl_get_info(RIG *rig)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
static char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "_\n");
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
buf [ret] = '\0';
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return buf;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_send_dtmf(RIG *rig, vfo_t vfo, const char *digits)
|
|
|
|
{
|
2019-03-01 13:32:05 +00:00
|
|
|
int ret, len;
|
|
|
|
char *cmdp, cmd[] = "\\send_dtmf ";
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
// allocate memory for size of (cmd + digits + \n + \0)
|
2022-01-11 18:17:34 +00:00
|
|
|
len = strlen(cmd) + strlen(digits) + 2;
|
|
|
|
cmdp = malloc(len);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (cmdp == NULL)
|
|
|
|
{
|
|
|
|
return -RIG_ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmdp, len, "%s%s\n", cmd, digits);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmdp, strlen(cmdp), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
free(cmdp);
|
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int netrigctl_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2019-03-01 13:32:05 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
static char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\recv_dtmf\n");
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return (ret < 0) ? ret : -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret > *length)
|
|
|
|
{
|
|
|
|
ret = *length;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
strncpy(digits, buf, ret);
|
|
|
|
*length = ret;
|
|
|
|
digits [ret] = '\0';
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2019-03-01 13:32:05 +00:00
|
|
|
return RIG_OK;
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
2021-12-20 15:50:13 +00:00
|
|
|
static int netrigctl_send_voice_mem(RIG *rig, vfo_t vfo, int ch)
|
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2021-12-20 15:50:13 +00:00
|
|
|
char cmd[CMD_MAX];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmd, sizeof(cmd), "\\send_voice_mem %d\n", ch);
|
2021-12-20 15:50:13 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2021-12-20 15:50:13 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-21 19:34:16 +00:00
|
|
|
static int netrigctl_send_morse(RIG *rig, vfo_t vfo, const char *msg)
|
|
|
|
{
|
2019-03-01 13:32:05 +00:00
|
|
|
int ret, len;
|
|
|
|
char *cmdp, cmd[] = "\\send_morse ";
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
2019-11-30 16:16:28 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
// allocate memory for size of (cmd + msg + \n + \0)
|
2022-01-11 18:17:34 +00:00
|
|
|
len = strlen(cmd) + strlen(msg) + 2;
|
|
|
|
cmdp = malloc(len);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
|
|
|
if (cmdp == NULL)
|
|
|
|
{
|
|
|
|
return -RIG_ENOMEM;
|
|
|
|
}
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmdp, len, "%s%s\n", cmd, msg);
|
2019-03-01 13:32:05 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmdp, strlen(cmdp), buf);
|
2019-03-01 13:32:05 +00:00
|
|
|
free(cmdp);
|
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
}
|
|
|
|
|
2021-10-30 21:42:18 +00:00
|
|
|
static int netrigctl_stop_morse(RIG *rig, vfo_t vfo)
|
2021-10-28 20:21:04 +00:00
|
|
|
{
|
2022-01-11 18:17:34 +00:00
|
|
|
int ret;
|
2021-10-28 20:21:04 +00:00
|
|
|
char cmd[] = "\\stop_morse\n";
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmd, strlen(cmd), buf);
|
2021-10-28 20:21:04 +00:00
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-27 17:21:41 +00:00
|
|
|
static int netrigctl_set_vfo_opt(RIG *rig, int status)
|
|
|
|
{
|
|
|
|
char cmdbuf[32];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
int ret;
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\set_vfo_opt %d\n", status);
|
2020-05-27 17:21:41 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
2020-05-27 17:23:08 +00:00
|
|
|
|
2020-05-27 17:21:41 +00:00
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2020-05-27 17:23:08 +00:00
|
|
|
|
2020-05-27 17:21:41 +00:00
|
|
|
rig->state.vfo_opt = status;
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
2008-09-21 19:34:16 +00:00
|
|
|
|
2021-04-28 22:39:08 +00:00
|
|
|
#if 0 // for the futurem -- would have to poll to get the pushed data
|
|
|
|
static int netrigctl_set_trn(RIG *rig, int trn)
|
|
|
|
{
|
|
|
|
char cmdbuf[32];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
int ret;
|
|
|
|
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\set_trn %s\n", trn ? "ON" : "OFF");
|
2021-04-28 22:39:08 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
|
|
|
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_get_trn(RIG *rig, int *trn)
|
|
|
|
{
|
|
|
|
char cmdbuf[32];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ENTERFUNC;
|
2022-01-11 18:17:34 +00:00
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\get_trn\n");
|
2021-04-28 22:39:08 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2021-04-29 22:23:37 +00:00
|
|
|
|
|
|
|
if (strstr(buf, "OFF")) { *trn = RIG_TRN_OFF; }
|
|
|
|
else if (strstr(buf, "RIG")) { *trn = RIG_TRN_RIG; }
|
|
|
|
else if (strstr(buf, "POLL")) { *trn = RIG_TRN_POLL; }
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Expected OFF, RIG, or POLL, got '%s'\n", __func__,
|
|
|
|
buf);
|
2021-04-28 22:39:08 +00:00
|
|
|
ret = -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURNFUNC(ret);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int netrigctl_mW2power(RIG *rig, float *power, unsigned int mwpower,
|
2021-04-29 22:23:37 +00:00
|
|
|
freq_t freq, rmode_t mode)
|
2021-04-28 22:39:08 +00:00
|
|
|
{
|
|
|
|
char cmdbuf[32];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ENTERFUNC;
|
|
|
|
|
2022-02-05 21:27:43 +00:00
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\mW2power %u %.0f %s\n", mwpower, freq,
|
|
|
|
rig_strrmode(mode));
|
2021-04-28 22:39:08 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*power = atof(buf);
|
|
|
|
|
|
|
|
RETURNFUNC(RIG_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int netrigctl_power2mW(RIG *rig, unsigned int *mwpower, float power,
|
2021-04-29 22:23:37 +00:00
|
|
|
freq_t freq, rmode_t mode)
|
2021-04-28 22:39:08 +00:00
|
|
|
{
|
2021-11-07 12:52:40 +00:00
|
|
|
char cmdbuf[64];
|
2021-04-28 22:39:08 +00:00
|
|
|
char buf[BUF_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ENTERFUNC;
|
|
|
|
|
2021-11-07 12:52:40 +00:00
|
|
|
// we shouldn't need any precision than microwatts
|
2022-01-19 05:16:45 +00:00
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\power2mW %.3f %.0f %s\n", power, freq,
|
2021-11-28 18:41:10 +00:00
|
|
|
rig_strrmode(mode));
|
2021-04-28 22:39:08 +00:00
|
|
|
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
|
|
|
|
|
|
|
if (ret <= 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
|
|
|
*mwpower = atof(buf);
|
|
|
|
|
|
|
|
RETURNFUNC(RIG_OK);
|
|
|
|
}
|
|
|
|
|
2022-04-15 18:21:35 +00:00
|
|
|
int netrigctl_password(RIG *rig, const char *key1)
|
2022-02-24 23:13:18 +00:00
|
|
|
{
|
|
|
|
char cmdbuf[256];
|
2022-03-01 17:39:11 +00:00
|
|
|
char buf[BUF_MAX];
|
2022-02-24 23:13:18 +00:00
|
|
|
int retval;
|
2021-04-28 22:39:08 +00:00
|
|
|
|
2022-02-24 23:13:18 +00:00
|
|
|
ENTERFUNC;
|
2022-04-15 18:21:35 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: key1=%s\n", __func__, key1);
|
2022-02-24 23:13:18 +00:00
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\password %s\n", key1);
|
|
|
|
retval = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
2022-05-13 21:50:13 +00:00
|
|
|
|
|
|
|
if (retval != RIG_OK) { retval = -RIG_EPROTO; }
|
|
|
|
|
2022-02-24 23:13:18 +00:00
|
|
|
RETURNFUNC(retval);
|
|
|
|
}
|
2021-04-28 22:39:08 +00:00
|
|
|
|
2022-06-07 03:54:10 +00:00
|
|
|
int netrigctl_set_lock_mode(RIG *rig, int lock)
|
2022-06-02 20:55:56 +00:00
|
|
|
{
|
2022-06-07 03:54:10 +00:00
|
|
|
char cmdbuf[256];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\set_lock_mode %d\n", lock);
|
|
|
|
|
|
|
|
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
|
|
|
|
|
|
|
if (ret > 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
2022-06-02 20:55:56 +00:00
|
|
|
return (RIG_OK);
|
|
|
|
}
|
|
|
|
|
2022-06-07 03:54:10 +00:00
|
|
|
int netrigctl_get_lock_mode(RIG *rig, int *lock)
|
2022-06-02 20:55:56 +00:00
|
|
|
{
|
2022-06-07 03:54:10 +00:00
|
|
|
char cmdbuf[256];
|
|
|
|
char buf[BUF_MAX];
|
|
|
|
int ret;
|
|
|
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "\\get_lock_mode\n");
|
|
|
|
ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf);
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
sscanf(buf,"%d", lock);
|
2022-06-02 20:55:56 +00:00
|
|
|
return (RIG_OK);
|
|
|
|
}
|
|
|
|
|
2008-09-21 19:34:16 +00:00
|
|
|
/*
|
|
|
|
* Netrigctl rig capabilities.
|
|
|
|
*/
|
|
|
|
|
2020-04-04 14:38:50 +00:00
|
|
|
struct rig_caps netrigctl_caps =
|
2019-03-01 13:32:05 +00:00
|
|
|
{
|
2020-03-05 14:44:18 +00:00
|
|
|
RIG_MODEL(RIG_MODEL_NETRIGCTL),
|
2019-03-01 13:32:05 +00:00
|
|
|
.model_name = "NET rigctl",
|
|
|
|
.mfg_name = "Hamlib",
|
2022-06-07 03:54:10 +00:00
|
|
|
.version = "20220606.0",
|
2019-03-01 13:32:05 +00:00
|
|
|
.copyright = "LGPL",
|
|
|
|
.status = RIG_STATUS_STABLE,
|
|
|
|
.rig_type = RIG_TYPE_OTHER,
|
|
|
|
.targetable_vfo = 0,
|
|
|
|
.ptt_type = RIG_PTT_RIG_MICDATA,
|
|
|
|
.dcd_type = RIG_DCD_RIG,
|
|
|
|
.port_type = RIG_PORT_NETWORK,
|
2021-07-12 16:22:26 +00:00
|
|
|
.timeout = 10000, /* enough for the worst rig we have */
|
2021-08-25 20:13:21 +00:00
|
|
|
.retry = 5,
|
2019-03-01 13:32:05 +00:00
|
|
|
|
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
|
|
|
/* following fields updated in rig_state at opening time */
|
2019-03-01 13:32:05 +00:00
|
|
|
.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,
|
|
|
|
|
|
|
|
.level_gran = { },
|
|
|
|
.ctcss_list = NULL,
|
|
|
|
.dcs_list = NULL,
|
|
|
|
.chan_list = { },
|
|
|
|
.transceive = RIG_TRN_OFF,
|
|
|
|
.attenuator = { },
|
|
|
|
.preamp = { },
|
|
|
|
.rx_range_list2 = { RIG_FRNG_END, },
|
|
|
|
.tx_range_list2 = { RIG_FRNG_END, },
|
|
|
|
.tuning_steps = { },
|
|
|
|
.filters = { RIG_FLT_END, },
|
|
|
|
.max_rit = 0,
|
|
|
|
.max_xit = 0,
|
|
|
|
.max_ifshift = 0,
|
|
|
|
.priv = NULL,
|
|
|
|
|
|
|
|
.rig_init = netrigctl_init,
|
|
|
|
.rig_cleanup = netrigctl_cleanup,
|
|
|
|
.rig_open = netrigctl_open,
|
|
|
|
.rig_close = netrigctl_close,
|
|
|
|
|
|
|
|
.set_freq = netrigctl_set_freq,
|
|
|
|
.get_freq = netrigctl_get_freq,
|
|
|
|
.set_mode = netrigctl_set_mode,
|
|
|
|
.get_mode = netrigctl_get_mode,
|
|
|
|
.set_vfo = netrigctl_set_vfo,
|
|
|
|
.get_vfo = netrigctl_get_vfo,
|
|
|
|
|
|
|
|
.set_powerstat = netrigctl_set_powerstat,
|
|
|
|
.get_powerstat = netrigctl_get_powerstat,
|
|
|
|
.set_level = netrigctl_set_level,
|
|
|
|
.get_level = netrigctl_get_level,
|
|
|
|
.set_func = netrigctl_set_func,
|
|
|
|
.get_func = netrigctl_get_func,
|
|
|
|
.set_parm = netrigctl_set_parm,
|
|
|
|
.get_parm = netrigctl_get_parm,
|
|
|
|
|
|
|
|
.get_info = netrigctl_get_info,
|
|
|
|
|
|
|
|
|
|
|
|
.set_ptt = netrigctl_set_ptt,
|
|
|
|
.get_ptt = netrigctl_get_ptt,
|
|
|
|
.get_dcd = netrigctl_get_dcd,
|
|
|
|
.set_rptr_shift = netrigctl_set_rptr_shift,
|
|
|
|
.get_rptr_shift = netrigctl_get_rptr_shift,
|
|
|
|
.set_rptr_offs = netrigctl_set_rptr_offs,
|
|
|
|
.get_rptr_offs = netrigctl_get_rptr_offs,
|
|
|
|
.set_ctcss_tone = netrigctl_set_ctcss_tone,
|
|
|
|
.get_ctcss_tone = netrigctl_get_ctcss_tone,
|
|
|
|
.set_dcs_code = netrigctl_set_dcs_code,
|
|
|
|
.get_dcs_code = netrigctl_get_dcs_code,
|
|
|
|
.set_ctcss_sql = netrigctl_set_ctcss_sql,
|
|
|
|
.get_ctcss_sql = netrigctl_get_ctcss_sql,
|
|
|
|
.set_dcs_sql = netrigctl_set_dcs_sql,
|
|
|
|
.get_dcs_sql = netrigctl_get_dcs_sql,
|
|
|
|
.set_split_freq = netrigctl_set_split_freq,
|
|
|
|
.get_split_freq = netrigctl_get_split_freq,
|
|
|
|
.set_split_mode = netrigctl_set_split_mode,
|
|
|
|
.get_split_mode = netrigctl_get_split_mode,
|
|
|
|
.set_split_vfo = netrigctl_set_split_vfo,
|
|
|
|
.get_split_vfo = netrigctl_get_split_vfo,
|
|
|
|
.set_rit = netrigctl_set_rit,
|
|
|
|
.get_rit = netrigctl_get_rit,
|
|
|
|
.set_xit = netrigctl_set_xit,
|
|
|
|
.get_xit = netrigctl_get_xit,
|
|
|
|
.set_ts = netrigctl_set_ts,
|
|
|
|
.get_ts = netrigctl_get_ts,
|
|
|
|
.set_ant = netrigctl_set_ant,
|
|
|
|
.get_ant = netrigctl_get_ant,
|
|
|
|
.set_bank = netrigctl_set_bank,
|
|
|
|
.set_mem = netrigctl_set_mem,
|
|
|
|
.get_mem = netrigctl_get_mem,
|
|
|
|
.vfo_op = netrigctl_vfo_op,
|
|
|
|
.scan = netrigctl_scan,
|
|
|
|
.send_dtmf = netrigctl_send_dtmf,
|
|
|
|
.recv_dtmf = netrigctl_recv_dtmf,
|
|
|
|
.send_morse = netrigctl_send_morse,
|
2021-12-20 15:50:13 +00:00
|
|
|
.send_voice_mem = netrigctl_send_voice_mem,
|
2021-10-28 20:21:04 +00:00
|
|
|
.stop_morse = netrigctl_stop_morse,
|
2019-03-01 13:32:05 +00:00
|
|
|
.set_channel = netrigctl_set_channel,
|
|
|
|
.get_channel = netrigctl_get_channel,
|
2020-05-27 17:21:41 +00:00
|
|
|
.set_vfo_opt = netrigctl_set_vfo_opt,
|
2021-04-28 22:39:08 +00:00
|
|
|
//.set_trn = netrigctl_set_trn,
|
|
|
|
//.get_trn = netrigctl_get_trn,
|
|
|
|
.power2mW = netrigctl_power2mW,
|
|
|
|
.mW2power = netrigctl_mW2power,
|
2022-02-24 23:13:18 +00:00
|
|
|
.password = netrigctl_password,
|
2022-06-02 20:55:56 +00:00
|
|
|
.set_lock_mode = netrigctl_set_lock_mode,
|
|
|
|
.get_lock_mode = netrigctl_get_lock_mode,
|
2021-04-28 22:39:08 +00:00
|
|
|
|
2022-02-11 17:21:49 +00:00
|
|
|
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
|
2008-09-21 19:34:16 +00:00
|
|
|
};
|