Hamlib/aor/ar3030.c

838 wiersze
18 KiB
C
Czysty Zwykły widok Historia

/*
* Hamlib AOR backend - AR3030 description
* Copyright (c) 2000-2005 by Stephane Fillod
*
*
* 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.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "hamlib/rig.h"
#include "serial.h"
#include "idx_builtin.h"
#include "misc.h"
#include "aor.h"
static int ar3030_set_vfo(RIG *rig, vfo_t vfo);
static int ar3030_get_vfo(RIG *rig, vfo_t *vfo);
static int ar3030_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
static int ar3030_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
static int ar3030_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
2019-11-30 16:19:08 +00:00
static int ar3030_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
pbwidth_t *width);
static int ar3030_set_mem(RIG *rig, vfo_t vfo, int ch);
static int ar3030_get_mem(RIG *rig, vfo_t vfo, int *ch);
static int ar3030_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
static int ar3030_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
static int ar3030_get_channel(RIG *rig, channel_t *chan);
static int ar3030_init(RIG *rig);
static int ar3030_cleanup(RIG *rig);
static int ar3030_close(RIG *rig);
static int ar3030_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
2019-11-30 16:19:08 +00:00
struct ar3030_priv_data
{
int curr_ch;
int curr_vfo;
};
/*
* TODO:
2019-11-30 16:19:08 +00:00
* set_channel(emulated?),rig_vfo_op
* rig_reset(RIG_RESET_MCALL)
* quit the remote control mode on close?
*/
#define AR3030_MODES (RIG_MODE_AM|RIG_MODE_AMS|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_FAX)
#define AR3030_FUNC_ALL (RIG_FUNC_NONE)
#define AR3030_LEVEL (RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_RAWSTR)
#define AR3030_PARM (RIG_PARM_NONE)
#define AR3030_VFO_OPS (RIG_OP_FROM_VFO|RIG_OP_MCL)
#define AR3030_VFO (RIG_VFO_A|RIG_VFO_MEM)
/*
* FIXME:
*/
#define AR3030_STR_CAL { 2, \
2019-11-30 16:19:08 +00:00
{ \
{ 0x00, -60 }, \
{ 0x3f, 60 } \
} }
#define AR3030_MEM_CAP { \
2019-11-30 16:19:08 +00:00
.freq = 1, \
.mode = 1, \
.width = 1, \
.levels = RIG_LEVEL_SET(AR3030_LEVEL), \
.flags = 1, \
}
/*
* Data was obtained from AR3030 pdf on http://www.aoruk.com
*
* ar3030 rig capabilities.
*/
2019-11-30 16:19:08 +00:00
const struct rig_caps ar3030_caps =
{
.rig_model = RIG_MODEL_AR3030,
.model_name = "AR3030",
.mfg_name = "AOR",
.version = "1.0",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_RECEIVER,
.ptt_type = RIG_PTT_NONE,
.dcd_type = RIG_DCD_NONE,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800,
.serial_rate_max = 9600,
.serial_data_bits = 8,
.serial_stop_bits = 2,
.serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_HARDWARE,
.write_delay = 0,
2019-11-30 16:19:08 +00:00
.post_write_delay = 50, /* ms */
.timeout = 500,
.retry = 0,
.has_get_func = AR3030_FUNC_ALL,
.has_set_func = AR3030_FUNC_ALL,
.has_get_level = AR3030_LEVEL,
.has_set_level = RIG_LEVEL_SET(AR3030_LEVEL),
.has_get_parm = AR3030_PARM,
.has_set_parm = RIG_PARM_NONE,
.level_gran = {}, /* FIXME: granularity */
.parm_gran = {},
.ctcss_list = NULL,
.dcs_list = NULL,
.preamp = { RIG_DBLST_END, },
.attenuator = { 10, 20, RIG_DBLST_END, },
.max_rit = Hz(0),
.max_xit = Hz(0),
.max_ifshift = Hz(0),
.targetable_vfo = 0,
.transceive = RIG_TRN_OFF,
.bank_qty = 0,
.chan_desc_sz = 0,
.vfo_ops = AR3030_VFO_OPS,
.str_cal = AR3030_STR_CAL,
.chan_list = {
{ 0, 99, RIG_MTYPE_MEM, AR3030_MEM_CAP },
RIG_CHAN_END,
},
.rx_range_list1 = {
2019-11-30 16:19:08 +00:00
{kHz(30), MHz(30), AR3030_MODES, -1, -1, AR3030_VFO},
RIG_FRNG_END,
},
.tx_range_list1 = { RIG_FRNG_END, },
.rx_range_list2 = {
2019-11-30 16:19:08 +00:00
{kHz(30), MHz(30), AR3030_MODES, -1, -1, AR3030_VFO},
RIG_FRNG_END,
}, /* rx range */
2019-11-30 16:19:08 +00:00
.tx_range_list2 = { RIG_FRNG_END, }, /* no tx range, this is a receiver! */
.tuning_steps = {
2019-11-30 16:19:08 +00:00
{AR3030_MODES, 10},
{AR3030_MODES, 100},
{AR3030_MODES, kHz(1)},
{AR3030_MODES, MHz(1)},
RIG_TS_END,
},
/* mode/filter list, .remember = order matters! */
.filters = {
{RIG_MODE_AM, kHz(6)},
2019-11-30 16:19:08 +00:00
{RIG_MODE_SSB | RIG_MODE_CW | RIG_MODE_AM, kHz(2.4)},
{RIG_MODE_CW, 500},
{RIG_MODE_FM, kHz(15)},
RIG_FLT_END,
},
.rig_init = ar3030_init,
.rig_cleanup = ar3030_cleanup,
.rig_close = ar3030_close,
.set_freq = ar3030_set_freq,
.get_freq = ar3030_get_freq,
.set_mode = ar3030_set_mode,
.get_mode = ar3030_get_mode,
.set_vfo = ar3030_set_vfo,
.get_vfo = ar3030_get_vfo,
.set_level = ar3030_set_level,
.get_level = ar3030_get_level,
.set_mem = ar3030_set_mem,
.get_mem = ar3030_get_mem,
.get_channel = ar3030_get_channel,
.vfo_op = ar3030_vfo_op,
};
/*
* Function definitions below
*/
/* is LF really needed? */
#define CR "\x0d"
#define EOM "\x0d\x0a"
#define BUFSZ 64
/*
* ar3030_transaction
* We assume that rig!=NULL, rig->state!= NULL
* Otherwise, you'll get a nice seg fault. You've been warned!
* return value: RIG_OK if everything's fine, negative value otherwise
*/
2019-11-30 16:19:08 +00:00
static int ar3030_transaction(RIG *rig, const char *cmd, int cmd_len,
char *data, int *data_len)
{
int retval;
struct rig_state *rs;
2019-11-30 16:19:08 +00:00
int retry = 3;
char tmpdata[BUFSZ];
rs = &rig->state;
2019-11-30 16:19:08 +00:00
if (data == NULL)
{
data = tmpdata;
}
2019-11-30 16:19:08 +00:00
serial_flush(&rs->rigport);
2019-11-30 16:19:08 +00:00
do
{
retval = write_block(&rs->rigport, cmd, cmd_len);
2019-11-30 16:19:08 +00:00
if (retval != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: write_block error=%d\n", __func__, retval);
return retval;
2019-11-30 16:19:08 +00:00
}
if (data)
{
/* expecting 0x0d0x0a on all commands so wait for the 0x0a */
retval = read_string(&rs->rigport, data, BUFSZ, "\x0a", 1);
2019-11-30 16:19:08 +00:00
if (retval == -RIG_ETIMEOUT)
{
rig_debug(RIG_DEBUG_ERR, "%s:timeout retry=%d\n", __func__, retry);
usleep(50000);
}
}
2019-11-30 16:19:08 +00:00
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d retry=%d\n", __func__, retval, retry);
}
while ((retval <= 0) && (--retry > 0));
usleep(1000); // 1ms sleep per manual
2019-11-30 16:19:08 +00:00
if (data_len != NULL && retval > 0)
{
*data_len = 0;
2019-11-30 16:19:08 +00:00
/* only set data_len non-zero if not a command response */
2019-11-30 16:19:08 +00:00
if (retval > 0 && data[0] != 0x00 && data[0] != 0x0d)
{
*data_len = retval;
}
}
2019-11-30 16:19:08 +00:00
rig_debug(RIG_DEBUG_TRACE, "%s: return data_len=%d retry=%d\n", __func__,
data_len ? *data_len : 0, retry);
return RIG_OK;
}
int ar3030_init(RIG *rig)
{
struct ar3030_priv_data *priv;
priv = malloc(sizeof(struct ar3030_priv_data));
if (!priv)
2019-11-30 16:19:08 +00:00
{
return -RIG_ENOMEM;
2019-11-30 16:19:08 +00:00
}
2019-11-30 16:19:08 +00:00
priv->curr_ch = 99; /* huh! FIXME: get_mem in open() ? */
priv->curr_vfo = RIG_VFO_A;
rig->state.priv = priv;
return RIG_OK;
}
int ar3030_cleanup(RIG *rig)
{
struct ar3030_priv_data *priv = rig->state.priv;
free(priv);
return RIG_OK;
}
int ar3030_close(RIG *rig)
{
int retval;
struct rig_state *rs;
2019-11-30 16:19:08 +00:00
rig_debug(RIG_DEBUG_TRACE, "%s:\n", __func__);
rs = &rig->state;
serial_flush(&rs->rigport);
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, "Q" CR, strlen("Q" CR), NULL, NULL);
rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval);
return retval;
}
int ar3030_set_vfo(RIG *rig, vfo_t vfo)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
char *cmd = "";
int retval;
2019-11-30 16:19:08 +00:00
switch (vfo)
{
case RIG_VFO_CURR:
return RIG_OK;
2019-11-30 16:19:08 +00:00
case RIG_VFO_VFO:
case RIG_VFO_A:
cmd = "D" CR;
break;
2019-11-30 16:19:08 +00:00
case RIG_VFO_MEM:
cmd = "M" CR;
break;
2019-11-30 16:19:08 +00:00
default:
return -RIG_EINVAL;
}
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, cmd, strlen(cmd), NULL, NULL);
if (retval == RIG_OK)
2019-11-30 16:19:08 +00:00
{
priv->curr_vfo = vfo;
2019-11-30 16:19:08 +00:00
}
return retval;
}
int ar3030_get_vfo(RIG *rig, vfo_t *vfo)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
*vfo = priv->curr_vfo;
return RIG_OK;
}
/*
* ar3030_set_freq
* Assumes rig!=NULL
*/
int ar3030_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
char freqbuf[BUFSZ];
int freq_len, retval;
2019-11-30 16:19:08 +00:00
freq_len = sprintf(freqbuf, "%03.6f" CR, ((double)freq) / MHz(1));
retval = ar3030_transaction(rig, freqbuf, freq_len, NULL, NULL);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
priv->curr_vfo = RIG_VFO_A;
return RIG_OK;
}
/*
* ar3030_get_freq
* Assumes rig!=NULL, freq!=NULL
*/
int ar3030_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
char *rfp;
int freq_len, retval;
char freqbuf[BUFSZ];
/*
* D Rn Gn Bn Tn Fnnnnnnnn C
* Note: spaces are transmitted.
*/
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, "D" CR, 2, freqbuf, &freq_len);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
priv->curr_vfo = RIG_VFO_A;
rfp = strchr(freqbuf, 'F');
2019-11-30 16:19:08 +00:00
if (!rfp)
2019-11-30 16:19:08 +00:00
{
return -RIG_EPROTO;
2019-11-30 16:19:08 +00:00
}
long lfreq;
2019-11-30 16:19:08 +00:00
sscanf(rfp + 1, "%ld", &lfreq);
*freq = lfreq;
2019-11-30 16:19:08 +00:00
rig_debug(RIG_DEBUG_ERR, "%s: read lfreq=%ld, freq=%.6f\n", __func__, lfreq,
*freq);
return RIG_OK;
}
/*
* ar3030_set_mode
* Assumes rig!=NULL
*/
int ar3030_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
char mdbuf[BUFSZ];
int mdbuf_len, aormode, retval;
2019-11-30 16:19:08 +00:00
switch (mode)
{
case RIG_MODE_AM:
aormode = 'A';
break;
2019-11-30 16:19:08 +00:00
case RIG_MODE_CW:
aormode = 'C';
break;
2019-11-30 16:19:08 +00:00
case RIG_MODE_USB:
aormode = 'U';
break;
2019-11-30 16:19:08 +00:00
case RIG_MODE_LSB:
aormode = 'L';
break;
2019-11-30 16:19:08 +00:00
case RIG_MODE_FM:
aormode = 'N';
break;
2019-11-30 16:19:08 +00:00
case RIG_MODE_AMS:
aormode = 'S';
break;
2019-11-30 16:19:08 +00:00
case RIG_MODE_FAX:
aormode = 'X';
break;
2019-11-30 16:19:08 +00:00
default:
2019-11-30 16:19:08 +00:00
rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode %s\n",
__func__, rig_strrmode(mode));
return -RIG_EINVAL;
}
2019-11-30 16:19:08 +00:00
if (width != RIG_PASSBAND_NOCHANGE)
{
mdbuf_len = sprintf(mdbuf, "%c" CR, aormode);
}
2019-11-30 16:19:08 +00:00
else
{
mdbuf_len = sprintf(mdbuf, "%dB%c" CR,
2019-11-30 16:19:08 +00:00
width < rig_passband_normal(rig, mode) ? 1 : 0,
aormode);
}
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, mdbuf, mdbuf_len, NULL, NULL);
return retval;
}
/*
* ar3030_get_mode
* Assumes rig!=NULL, mode!=NULL
*/
int ar3030_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
int buf_len, retval;
char buf[BUFSZ];
/*
* D Rn Gn Bn Tn Fnnnnnnnn C
* Note: spaces are transmitted
*/
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, "D" CR, 2, buf, &buf_len);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
priv->curr_vfo = RIG_VFO_A;
2019-11-30 16:19:08 +00:00
switch (buf[25])
{
case 'A':
*mode = RIG_MODE_AM;
break;
2019-11-30 16:19:08 +00:00
case 'L':
*mode = RIG_MODE_LSB;
break;
2019-11-30 16:19:08 +00:00
case 'U':
*mode = RIG_MODE_USB;
break;
2019-11-30 16:19:08 +00:00
case 'C':
*mode = RIG_MODE_CW;
break;
2019-11-30 16:19:08 +00:00
case 'S':
*mode = RIG_MODE_AMS;
break;
2019-11-30 16:19:08 +00:00
case 'N':
*mode = RIG_MODE_FM;
break;
2019-11-30 16:19:08 +00:00
case 'X':
*mode = RIG_MODE_FAX;
break;
2019-11-30 16:19:08 +00:00
default:
2019-11-30 16:19:08 +00:00
rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode '%c'\n",
__func__, buf[25]);
return -RIG_EPROTO;
}
*width = buf[9] == '1' ? rig_passband_narrow(rig, *mode) :
rig_passband_normal(rig, *mode);
return RIG_OK;
}
int ar3030_set_mem(RIG *rig, vfo_t vfo, int ch)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
2019-12-06 21:35:52 +00:00
int retval = RIG_OK;
2019-11-30 16:19:08 +00:00
if (priv->curr_vfo == RIG_VFO_MEM)
{
2019-12-06 21:35:52 +00:00
char cmdbuf[BUFSZ];
int cmd_len = sprintf(cmdbuf, "%02dM" CR, ch);
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, cmdbuf, cmd_len, NULL, NULL);
}
2019-11-30 16:19:08 +00:00
if (retval == RIG_OK)
{
priv->curr_ch = ch;
}
return retval;
}
int ar3030_get_mem(RIG *rig, vfo_t vfo, int *ch)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
char infobuf[BUFSZ];
int info_len, retval;
2019-11-30 16:19:08 +00:00
if (priv->curr_vfo != RIG_VFO_MEM)
{
*ch = priv->curr_ch;
}
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, "M" CR, 2, infobuf, &info_len);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
/*
* MnnPnRnGnBnTnFnnnnnnnnC
*/
2019-11-30 16:19:08 +00:00
if (infobuf[0] != 'M')
{
return -RIG_EPROTO;
}
/*
* Is it a blank mem channel ?
*/
2019-11-30 16:19:08 +00:00
if (infobuf[1] == '-' && infobuf[2] == '-')
{
*ch = -1; /* FIXME: return error instead? */
return RIG_OK;
}
2019-11-30 16:19:08 +00:00
*ch = priv->curr_ch = atoi(infobuf + 1);
return RIG_OK;
}
int ar3030_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
char *cmd;
int retval;
2019-11-30 16:19:08 +00:00
switch (level)
{
case RIG_LEVEL_AGC:
/* SLOW otherwise */
cmd = val.i == RIG_AGC_FAST ? "1G" CR : "0G" CR;
break;
2019-11-30 16:19:08 +00:00
case RIG_LEVEL_ATT:
cmd = val.i == 0 ? "0R" CR :
(val.i == 1 ? "1R" CR : "2R" CR);
break;
2019-11-30 16:19:08 +00:00
default:
return -RIG_EINVAL;
}
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, cmd, strlen(cmd), NULL, NULL);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
return RIG_OK;
}
int ar3030_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
int info_len, retval;
char infobuf[BUFSZ], *p;
2019-11-30 16:19:08 +00:00
switch (level)
{
case RIG_LEVEL_ATT:
/*
* DRnGnBnTnFnnnnnnnnC
*/
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, "D" CR, 2, infobuf, &info_len);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
priv->curr_vfo = RIG_VFO_A;
p = strchr(infobuf, 'R');
2019-11-30 16:19:08 +00:00
if (!p)
2019-11-30 16:19:08 +00:00
{
return -RIG_EPROTO;
2019-11-30 16:19:08 +00:00
}
val->i = p[1] == '0' ? 0 : rig->caps->attenuator[p[1] - '1'];
return RIG_OK;
case RIG_LEVEL_AGC:
/*
* DRnGnBnTnFnnnnnnnnC
*/
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, "D" CR, 2, infobuf, &info_len);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
priv->curr_vfo = RIG_VFO_A;
p = strchr(infobuf, 'G');
2019-11-30 16:19:08 +00:00
if (!p)
2019-11-30 16:19:08 +00:00
{
return -RIG_EPROTO;
2019-11-30 16:19:08 +00:00
}
val->i = p[1] == '0' ? RIG_AGC_SLOW : RIG_AGC_FAST;
return RIG_OK;
case RIG_LEVEL_RAWSTR:
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, "Y" CR, 2, infobuf, &info_len);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
infobuf[3] = '\0';
val->i = strtol(infobuf, (char **)NULL, 16);
return RIG_OK;
default:
return -RIG_EINVAL;
}
return RIG_OK;
}
int ar3030_get_channel(RIG *rig, channel_t *chan)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
char cmdbuf[BUFSZ], infobuf[BUFSZ];
int info_len, cmd_len, retval;
cmd_len = sprintf(cmdbuf, "%02dM" CR, chan->channel_num);
2019-11-30 16:19:08 +00:00
retval = ar3030_transaction(rig, cmdbuf, cmd_len, infobuf, &info_len);
if (retval != RIG_OK)
2019-11-30 16:19:08 +00:00
{
return retval;
2019-11-30 16:19:08 +00:00
}
priv->curr_vfo = RIG_VFO_A;
/*
* MnnPnRnGnBnTnFnnnnnnnnC
*/
2019-11-30 16:19:08 +00:00
if (infobuf[0] != 'M')
{
return -RIG_EPROTO;
}
/*
* Is it a blank mem channel ?
*/
2019-11-30 16:19:08 +00:00
if (infobuf[1] == '-' && infobuf[2] == '-')
{
chan->freq = RIG_FREQ_NONE;
return RIG_OK;
}
2019-11-30 16:19:08 +00:00
sscanf(infobuf + 14, "%"SCNfreq, &chan->freq);
chan->freq *= 10;
2019-11-30 16:19:08 +00:00
switch (infobuf[22])
{
case 'A':
chan->mode = RIG_MODE_AM;
break;
2019-11-30 16:19:08 +00:00
case 'L':
chan->mode = RIG_MODE_LSB;
break;
2019-11-30 16:19:08 +00:00
case 'U':
chan->mode = RIG_MODE_USB;
break;
2019-11-30 16:19:08 +00:00
case 'C':
chan->mode = RIG_MODE_CW;
break;
2019-11-30 16:19:08 +00:00
case 'S':
chan->mode = RIG_MODE_AMS;
break;
2019-11-30 16:19:08 +00:00
case 'N':
chan->mode = RIG_MODE_FM;
break;
2019-11-30 16:19:08 +00:00
case 'X':
chan->mode = RIG_MODE_FAX;
break;
2019-11-30 16:19:08 +00:00
default:
2019-11-30 16:19:08 +00:00
rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode '%c'\n",
__func__, infobuf[22]);
return -RIG_EPROTO;
}
chan->width = infobuf[10] == '1' ?
rig_passband_narrow(rig, chan->mode) :
rig_passband_normal(rig, chan->mode);
2019-11-30 16:19:08 +00:00
chan->levels[LVL_ATT].i = infobuf[6] == '0' ? 0 :
rig->caps->attenuator[infobuf[4] - '1'];
chan->levels[LVL_AGC].i = infobuf[8] == '0' ? RIG_AGC_SLOW : RIG_AGC_FAST;
chan->flags = infobuf[4] == '1' ? RIG_CHFLAG_SKIP : RIG_CHFLAG_NONE;
return RIG_OK;
}
int ar3030_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
{
struct ar3030_priv_data *priv = (struct ar3030_priv_data *)rig->state.priv;
char buf[16];
int len, retval;
2019-11-30 16:19:08 +00:00
switch (op)
{
case RIG_OP_MCL:
2019-11-30 16:19:08 +00:00
len = sprintf(buf, "%02d%%" CR, priv->curr_ch);
break;
2019-11-30 16:19:08 +00:00
case RIG_OP_FROM_VFO:
2019-11-30 16:19:08 +00:00
len = sprintf(buf, "%02dW" CR, priv->curr_ch);
priv->curr_vfo = RIG_VFO_MEM;
break;
2019-11-30 16:19:08 +00:00
default:
return -RIG_EINVAL;
}
retval = ar3030_transaction(rig, buf, len, NULL, NULL);
return retval;
}