kopia lustrzana https://github.com/Hamlib/Hamlib
added support for RA3702
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2849 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.11
rodzic
a90f9e84cd
commit
bd866ad27e
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Hamlib Interface - list of known rigs
|
||||
* Copyright (c) 2000-2003 by Frank Singleton
|
||||
* Copyright (c) 2000-2009 by Stephane Fillod
|
||||
* Copyright (c) 2000-2010 by Stephane Fillod
|
||||
*
|
||||
* $Id: riglist.h,v 1.76 2009-01-29 22:54:40 fillods Exp $
|
||||
*
|
||||
|
@ -311,6 +311,7 @@
|
|||
#define RIG_MODEL_RA3720 RIG_MAKE_MODEL(RIG_RACAL, 2)
|
||||
#define RIG_MODEL_RA6790 RIG_MAKE_MODEL(RIG_RACAL, 3)
|
||||
#define RIG_MODEL_RA3710 RIG_MAKE_MODEL(RIG_RACAL, 4)
|
||||
#define RIG_MODEL_RA3702 RIG_MAKE_MODEL(RIG_RACAL, 5)
|
||||
|
||||
/*
|
||||
* Watkins-Johnson
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
RACALSRCLIST = ra6790.c
|
||||
RACALSRCLIST = ra6790.c ra3702.c
|
||||
|
||||
lib_LTLIBRARIES = hamlib-racal.la
|
||||
hamlib_racal_la_SOURCES = $(RACALSRCLIST) racal.c
|
||||
hamlib_racal_la_SOURCES = $(RACALSRCLIST) racal.c ra37xx.c
|
||||
hamlib_racal_la_LDFLAGS = -no-undefined -module -avoid-version
|
||||
hamlib_racal_la_LIBADD = $(top_builddir)/src/libhamlib.la
|
||||
|
||||
noinst_HEADERS = racal.h
|
||||
noinst_HEADERS = racal.h ra37xx.h
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
/*
|
||||
* Hamlib Racal backend - RA3702 description
|
||||
* Copyright (c) 2010 by Stephane Fillod
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "idx_builtin.h"
|
||||
#include "ra37xx.h"
|
||||
|
||||
|
||||
/* TODO: ISB */
|
||||
#define RA3702_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY)
|
||||
|
||||
#define RA3702_FUNC (RIG_FUNC_MUTE)
|
||||
|
||||
#define RA3702_LEVEL_ALL (RIG_LEVEL_RF|RIG_LEVEL_AF|RIG_LEVEL_AGC|\
|
||||
RIG_LEVEL_CWPITCH|RIG_LEVEL_PREAMP|RIG_LEVEL_SQL|RIG_LEVEL_RAWSTR)
|
||||
|
||||
#define RA3702_PARM_ALL (RIG_PARM_NONE)
|
||||
|
||||
#define RA3702_VFO (RIG_VFO_A)
|
||||
|
||||
#define RA3702_VFO_OPS (RIG_OP_FROM_VFO|RIG_OP_TO_VFO)
|
||||
#define RA3702_SCAN_OPS (RIG_SCAN_STOP|RIG_SCAN_VFO|RIG_SCAN_MEM)
|
||||
|
||||
/*
|
||||
* ra3702 rig capabilities.
|
||||
*
|
||||
* Required A6A1 serial asynchronous interface
|
||||
*
|
||||
*/
|
||||
const struct rig_caps ra3702_caps = {
|
||||
.rig_model = RIG_MODEL_RA3702,
|
||||
.model_name = "RA3702",
|
||||
.mfg_name = "Racal",
|
||||
.version = "0.1",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_UNTESTED,
|
||||
.rig_type = RIG_TYPE_RECEIVER,
|
||||
.ptt_type = RIG_PTT_NONE,
|
||||
.dcd_type = RIG_DCD_NONE,
|
||||
.port_type = RIG_PORT_SERIAL,
|
||||
.serial_rate_min = 50,
|
||||
.serial_rate_max = 9600,
|
||||
.serial_data_bits = 7,
|
||||
.serial_stop_bits = 1,
|
||||
.serial_parity = RIG_PARITY_EVEN,
|
||||
.serial_handshake = RIG_HANDSHAKE_XONXOFF,
|
||||
.write_delay = 0,
|
||||
.post_write_delay = 0,
|
||||
.timeout = RA37XX_TIMEOUT,
|
||||
.retry = 0,
|
||||
|
||||
.has_get_func = RA3702_FUNC,
|
||||
.has_set_func = RA3702_FUNC,
|
||||
.has_get_level = RA3702_LEVEL_ALL,
|
||||
.has_set_level = RIG_LEVEL_SET(RA3702_LEVEL_ALL),
|
||||
.has_get_parm = RA3702_PARM_ALL,
|
||||
.has_set_parm = RIG_PARM_SET(RA3702_PARM_ALL),
|
||||
.level_gran = {
|
||||
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
|
||||
},
|
||||
.vfo_ops = RA3702_VFO_OPS,
|
||||
.scan_ops = RA3702_SCAN_OPS,
|
||||
.preamp = { 20, RIG_DBLST_END }, /* FIXME */
|
||||
.attenuator = { 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,
|
||||
.str_cal = RA37XX_STR_CAL,
|
||||
|
||||
.chan_list = {
|
||||
{ 0, 99, RIG_MTYPE_MEM, RA37XX_MEM_CAP },
|
||||
RIG_CHAN_END,
|
||||
},
|
||||
|
||||
.rx_range_list1 = {
|
||||
{kHz(15),MHz(30)-1,RA3702_MODES,-1,-1,RA3702_VFO},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list1 = { RIG_FRNG_END, },
|
||||
.rx_range_list2 = {
|
||||
{kHz(15),MHz(30)-1,RA3702_MODES,-1,-1,RA3702_VFO},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list2 = { RIG_FRNG_END, },
|
||||
.tuning_steps = {
|
||||
{RA3702_MODES,1},
|
||||
{RA3702_MODES,10},
|
||||
RIG_TS_END,
|
||||
},
|
||||
/* mode/filter list, remember: order matters! */
|
||||
.filters = {
|
||||
/* at -3dB */
|
||||
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_RTTY, kHz(2.7)},
|
||||
{RA3702_MODES, kHz(12)},
|
||||
{RA3702_MODES, kHz(6)},
|
||||
{RA3702_MODES, Hz(300)},
|
||||
{RA3702_MODES, kHz(1)},
|
||||
{RA3702_MODES, kHz(2.7)},
|
||||
//{RA3702_MODES, 0}, /* accept any BW */
|
||||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.cfgparams = ra37xx_cfg_params,
|
||||
|
||||
.rig_init = ra37xx_init,
|
||||
.rig_cleanup = ra37xx_cleanup,
|
||||
.rig_open = ra37xx_open,
|
||||
.rig_close = ra37xx_close,
|
||||
.set_conf = ra37xx_set_conf,
|
||||
.get_conf = ra37xx_get_conf,
|
||||
|
||||
.set_freq = ra37xx_set_freq,
|
||||
.get_freq = ra37xx_get_freq,
|
||||
.set_mode = ra37xx_set_mode,
|
||||
.get_mode = ra37xx_get_mode,
|
||||
.set_func = ra37xx_set_func,
|
||||
.get_func = ra37xx_get_func,
|
||||
.set_level = ra37xx_set_level,
|
||||
.get_level = ra37xx_get_level,
|
||||
|
||||
.set_ant = ra37xx_set_ant,
|
||||
.get_ant = ra37xx_get_ant,
|
||||
.set_mem = ra37xx_set_mem,
|
||||
.get_mem = ra37xx_get_mem,
|
||||
|
||||
.scan = ra37xx_scan,
|
||||
.vfo_op = ra37xx_vfo_op,
|
||||
.get_info = ra37xx_get_info,
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
|
@ -0,0 +1,659 @@
|
|||
/*
|
||||
* Hamlib Racal backend - RA37XX main file
|
||||
* Copyright (c) 2004-2010 by Stephane Fillod
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <math.h>
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "serial.h"
|
||||
#include "misc.h"
|
||||
#include "cal.h"
|
||||
#include "register.h"
|
||||
#include "token.h"
|
||||
|
||||
#include "ra37xx.h"
|
||||
|
||||
|
||||
const struct confparams ra37xx_cfg_params[] = {
|
||||
{ TOK_RIGID, "receiver_id", "receiver ID", "receiver ID, -1 to disable addressing",
|
||||
"-1", RIG_CONF_NUMERIC, { .n = { -1, 9, 1 } }
|
||||
},
|
||||
{ RIG_CONF_END, NULL, }
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* packet framing, 5-8 */
|
||||
#define BUFSZ 256
|
||||
|
||||
#define SOM "\x0a" /* LF */
|
||||
#define EOM "\x0d" /* CR */
|
||||
|
||||
/*
|
||||
* modes
|
||||
*/
|
||||
#define MD_USB 1
|
||||
#define MD_LSB 2
|
||||
#define MD_AM 3
|
||||
#define MD_FM 4
|
||||
#define MD_CW 5
|
||||
#define MD_FSK 6 /* option */
|
||||
#define MD_ISB_USB 7
|
||||
#define MD_ISB_LSB 8
|
||||
#define MD_FSK_NAR 13 /* option */
|
||||
#define MD_FSK_MED 14 /* option */
|
||||
#define MD_FSK_WID 15 /* option */
|
||||
|
||||
|
||||
/*
|
||||
* ra37xx_transaction
|
||||
* We assume that rig!=NULL, rig->state!= NULL
|
||||
*
|
||||
*/
|
||||
static int ra37xx_transaction(RIG *rig, const char *cmd, char *data, int *data_len)
|
||||
{
|
||||
struct ra37xx_priv_data *priv = (struct ra37xx_priv_data*)rig->state.priv;
|
||||
struct rig_state *rs = &rig->state;
|
||||
char cmdbuf[BUFSZ];
|
||||
char respbuf[BUFSZ];
|
||||
int cmd_len;
|
||||
int retval;
|
||||
int pkt_header_len;
|
||||
|
||||
/* Packet Framing:
|
||||
- no Link Control Character
|
||||
- (optional) 1 Address Character
|
||||
- no Check Character
|
||||
*/
|
||||
if (priv->receiver_id != -1) {
|
||||
pkt_header_len = 2;
|
||||
cmd_len = sprintf(cmdbuf, SOM "%d%s" EOM, priv->receiver_id, cmd);
|
||||
} else {
|
||||
pkt_header_len = 1;
|
||||
cmd_len = sprintf(cmdbuf, SOM "%s" EOM, cmd);
|
||||
}
|
||||
|
||||
serial_flush(&rs->rigport);
|
||||
|
||||
retval = write_block(&rs->rigport, cmdbuf, cmd_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
||||
/* forward COMMAND frame? no data expected */
|
||||
if (!data || !data_len) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = read_string(&rs->rigport, respbuf, BUFSZ, EOM, strlen(EOM));
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
|
||||
if (retval < pkt_header_len+1 || respbuf[0] != '\x0a')
|
||||
return -RIG_EPROTO;
|
||||
|
||||
if (retval >= pkt_header_len+3 && !memcmp(respbuf+pkt_header_len, "ERR", 3))
|
||||
return -RIG_ERJCTED;
|
||||
|
||||
if (retval >= pkt_header_len+5 && !memcmp(respbuf+pkt_header_len, "FAULT", 5))
|
||||
return -RIG_ERJCTED;
|
||||
|
||||
if (cmd[0] == 'Q' && (retval+pkt_header_len+1 < strlen(cmd) ||
|
||||
cmd[1] != respbuf[pkt_header_len])) {
|
||||
rig_debug(RIG_DEBUG_WARN, "%s: unexpected revertive frame\n",
|
||||
__func__);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
/* Strip starting LF and ending CR */
|
||||
memcpy(data, respbuf+pkt_header_len, retval-pkt_header_len-1);
|
||||
|
||||
*data_len = retval;
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
int ra37xx_init(RIG *rig)
|
||||
{
|
||||
struct ra37xx_priv_data *priv;
|
||||
|
||||
if (!rig || !rig->caps)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
priv = (struct ra37xx_priv_data*)malloc(sizeof(struct ra37xx_priv_data));
|
||||
if (!priv) {
|
||||
/* whoops! memory shortage! */
|
||||
return -RIG_ENOMEM;
|
||||
}
|
||||
|
||||
rig->state.priv = (void*)priv;
|
||||
|
||||
priv->receiver_id = -1;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
int ra37xx_cleanup(RIG *rig)
|
||||
{
|
||||
if (!rig)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (rig->state.priv)
|
||||
free(rig->state.priv);
|
||||
rig->state.priv = NULL;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
*/
|
||||
int ra37xx_set_conf(RIG *rig, token_t token, const char *val)
|
||||
{
|
||||
struct ra37xx_priv_data *priv = (struct ra37xx_priv_data*)rig->state.priv;
|
||||
int receiver_id;
|
||||
|
||||
switch (token) {
|
||||
case TOK_RIGID:
|
||||
receiver_id = atoi(val);
|
||||
if (receiver_id < -1 || receiver_id > 9)
|
||||
return -RIG_EINVAL;
|
||||
priv->receiver_id = receiver_id;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* assumes rig!=NULL,
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
* and val points to a buffer big enough to hold the conf value.
|
||||
*/
|
||||
int ra37xx_get_conf(RIG *rig, token_t token, char *val)
|
||||
{
|
||||
struct ra37xx_priv_data *priv = (struct ra37xx_priv_data*)rig->state.priv;
|
||||
|
||||
switch(token) {
|
||||
case TOK_RIGID:
|
||||
sprintf(val, "%d", priv->receiver_id);
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* ra37xx_open
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int ra37xx_open(RIG *rig)
|
||||
{
|
||||
/* Set Receiver to remote control
|
||||
*/
|
||||
return ra37xx_transaction (rig, "REM1", NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ra37xx_close
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int ra37xx_close(RIG *rig)
|
||||
{
|
||||
/* Set Receiver to local control */
|
||||
return ra37xx_transaction (rig, "REM0", NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* ra37xx_set_freq
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int ra37xx_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
char freqbuf[BUFSZ];
|
||||
int freq_len;
|
||||
|
||||
freq_len = sprintf(freqbuf, "F%ld", (unsigned long)freq);
|
||||
|
||||
return ra37xx_transaction (rig, freqbuf, NULL, NULL);
|
||||
}
|
||||
|
||||
int ra37xx_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
{
|
||||
char freqbuf[BUFSZ];
|
||||
int retval, len;
|
||||
double f;
|
||||
|
||||
retval = ra37xx_transaction (rig, "QF", freqbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(freqbuf+1, "%lf", &f);
|
||||
*freq = (freq_t)f;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* ra37xx_set_mode
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int ra37xx_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
//struct ra37xx_priv_data *priv = (struct ra37xx_priv_data*)rig->state.priv;
|
||||
int ra_mode, widthtype, widthnum;
|
||||
char buf[BUFSZ];
|
||||
|
||||
switch (mode) {
|
||||
case RIG_MODE_CW: widthtype = 1; ra_mode = MD_CW; break;
|
||||
case RIG_MODE_CWR: widthtype = 2; ra_mode = MD_CW; break;
|
||||
case RIG_MODE_USB: widthtype = 1; ra_mode = MD_USB; break;
|
||||
case RIG_MODE_LSB: widthtype = 2; ra_mode = MD_LSB; break;
|
||||
case RIG_MODE_AM: widthtype = 3; ra_mode = MD_AM; break;
|
||||
case RIG_MODE_FM: widthtype = 3; ra_mode = MD_FM; break;
|
||||
case RIG_MODE_RTTY: widthtype = 3; ra_mode = MD_FSK; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode %d\n",
|
||||
__FUNCTION__, mode);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
if (width == RIG_PASSBAND_NORMAL)
|
||||
width = rig_passband_normal(rig, mode);
|
||||
|
||||
widthtype = 0; /* FIXME: no bandwidth for now */
|
||||
widthnum = 0;
|
||||
/* width set using 'B', QBCON must be queried firsthand */
|
||||
|
||||
#if 0
|
||||
sprintf(buf, "M%d;B%d,%d", ra_mode, widthtype, widthnum);
|
||||
#else
|
||||
sprintf(buf, "M%d", ra_mode);
|
||||
#endif
|
||||
|
||||
return ra37xx_transaction (rig, buf, NULL, NULL);
|
||||
}
|
||||
|
||||
int ra37xx_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||
{
|
||||
char resbuf[BUFSZ];
|
||||
int retval, len, ra_mode;
|
||||
|
||||
retval = ra37xx_transaction (rig, "QM", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+1, "%d", &ra_mode);
|
||||
switch (ra_mode) {
|
||||
case MD_CW: *mode = RIG_MODE_CW; break;
|
||||
case MD_ISB_LSB:
|
||||
case MD_LSB: *mode = RIG_MODE_LSB; break;
|
||||
case MD_ISB_USB:
|
||||
case MD_USB: *mode = RIG_MODE_USB; break;
|
||||
case MD_FSK_NAR:
|
||||
case MD_FSK_MED:
|
||||
case MD_FSK_WID:
|
||||
case MD_FSK: *mode = RIG_MODE_RTTY; break;
|
||||
case MD_FM: *mode = RIG_MODE_FM; break;
|
||||
case MD_AM: *mode = RIG_MODE_AM; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unsupported mode %d\n",
|
||||
__FUNCTION__, mode);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
retval = ra37xx_transaction (rig, "QB", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
/* TODO: width */
|
||||
*width = 0;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int ra37xx_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
||||
{
|
||||
char cmdbuf[BUFSZ];
|
||||
|
||||
switch (func) {
|
||||
case RIG_FUNC_MUTE:
|
||||
sprintf(cmdbuf, "MUTE%d", status ? 1 : 0);
|
||||
break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"%s: unsupported %d\n",
|
||||
__FUNCTION__, func);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return ra37xx_transaction (rig, cmdbuf, NULL, NULL);
|
||||
}
|
||||
|
||||
int ra37xx_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
||||
{
|
||||
char resbuf[BUFSZ];
|
||||
int retval, len, i;
|
||||
|
||||
switch (func) {
|
||||
case RIG_FUNC_MUTE:
|
||||
retval = ra37xx_transaction (rig, "QMUTE", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+4, "%d", &i);
|
||||
*status = i == 0 ? 0 : 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"%s: Unsupported %d\n", __FUNCTION__, func);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ra37xx_set_level
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int ra37xx_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
{
|
||||
char cmdbuf[BUFSZ];
|
||||
int agc;
|
||||
|
||||
switch (level) {
|
||||
case RIG_LEVEL_AF:
|
||||
sprintf(cmdbuf, "AFL%d", (int)(val.f*255));
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_PREAMP:
|
||||
sprintf(cmdbuf, "RFAMP%d", val.i ? 1 : 0);
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_CWPITCH: /* BFO */
|
||||
sprintf(cmdbuf, "BFO%d", val.i);
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_SQL:
|
||||
sprintf(cmdbuf, "CORL%d", (int)(val.f*255));
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_RF:
|
||||
sprintf(cmdbuf, "G%d", (int)(val.f*255));
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_AGC:
|
||||
switch (val.i) {
|
||||
case RIG_AGC_FAST: agc = 0; break;
|
||||
case RIG_AGC_MEDIUM: agc = 1; break;
|
||||
case RIG_AGC_SLOW: agc = 2; break;
|
||||
case RIG_AGC_USER: agc = 0; break;
|
||||
default: return -RIG_EINVAL;
|
||||
}
|
||||
sprintf(cmdbuf, "AGC%d,%d", val.i==RIG_AGC_USER ? 1:0, agc);
|
||||
break;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"%s: unsupported %d\n",
|
||||
__FUNCTION__, level);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return ra37xx_transaction (rig, cmdbuf, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ra37xx_get_level
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int ra37xx_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
{
|
||||
char resbuf[BUFSZ];
|
||||
int retval, len, i;
|
||||
|
||||
switch (level) {
|
||||
case RIG_LEVEL_AF:
|
||||
retval = ra37xx_transaction (rig, "QAFL", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+3, "%d", &i);
|
||||
val->f = ((float)i)/255;
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_CWPITCH:
|
||||
retval = ra37xx_transaction (rig, "QBFO", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+3, "%d", &val->i);
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_PREAMP:
|
||||
retval = ra37xx_transaction (rig, "QRFAMP", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+5, "%d", &i);
|
||||
val->i = i ? rig->state.preamp[0] : 0;
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_RAWSTR:
|
||||
retval = ra37xx_transaction (rig, "QRFL", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+3, "%d", &val->i);
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_SQL:
|
||||
retval = ra37xx_transaction (rig, "QCORL", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+4, "%d", &i);
|
||||
val->f = ((float)i)/255;
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_RF:
|
||||
retval = ra37xx_transaction (rig, "QG", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(resbuf+1, "%d", &i);
|
||||
val->f = ((float)i)/255;
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_AGC:
|
||||
retval = ra37xx_transaction (rig, "QAGC", resbuf, &len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (resbuf[3] != '0') {
|
||||
val->i = RIG_AGC_USER;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (resbuf[5]) {
|
||||
case '0': val->i = RIG_AGC_FAST; break;
|
||||
case '1': val->i = RIG_AGC_MEDIUM; break;
|
||||
case '2': val->i = RIG_AGC_SLOW; break;
|
||||
default: return -RIG_EPROTO;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"%s: Unsupported %d\n", __FUNCTION__, level);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
const char* ra37xx_get_info(RIG *rig)
|
||||
{
|
||||
static char infobuf[BUFSZ];
|
||||
int res_len, retval;
|
||||
|
||||
retval = ra37xx_transaction (rig, "QID", infobuf, &res_len);
|
||||
if (retval != RIG_OK || res_len < 2 || res_len >= BUFSZ)
|
||||
return NULL;
|
||||
|
||||
infobuf[res_len] = '\0';
|
||||
|
||||
/* TODO: "QSW"? c.f. 5-43 */
|
||||
|
||||
/* skip "ID" */
|
||||
return infobuf+2;
|
||||
}
|
||||
|
||||
int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
int i_ant;
|
||||
|
||||
switch (ant)
|
||||
{
|
||||
case RIG_ANT_1: i_ant = 1<<0; break;
|
||||
case RIG_ANT_2: i_ant = 1<<1; break;
|
||||
case RIG_ANT_3: i_ant = 1<<2; break;
|
||||
case RIG_ANT_4: i_ant = 1<<3; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"Unsupported ant %#x", ant);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
sprintf(buf, "ANT%d", i_ant);
|
||||
|
||||
return ra37xx_transaction (rig, buf, NULL, NULL);
|
||||
}
|
||||
|
||||
int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t *ant)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
int retval, buflen, ra_ant;
|
||||
|
||||
retval = ra37xx_transaction (rig, "QANT", buf, &buflen);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
sscanf(buf+3, "%d", &ra_ant);
|
||||
|
||||
if (ra_ant < 0 || ra_ant > 15)
|
||||
return -RIG_EPROTO;
|
||||
|
||||
*ant = ((ra_ant & (1<<0)) ? RIG_ANT_1 : 0) |
|
||||
((ra_ant & (1<<1)) ? RIG_ANT_2 : 0) |
|
||||
((ra_ant & (1<<2)) ? RIG_ANT_3 : 0) |
|
||||
((ra_ant & (1<<3)) ? RIG_ANT_4 : 0);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int ra37xx_set_mem(RIG *rig, vfo_t vfo, int ch)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
|
||||
/* NB: does a RIG_OP_TO_VFO!*/
|
||||
|
||||
sprintf(buf, "CHAN%d", ch);
|
||||
|
||||
return ra37xx_transaction (rig, buf, NULL, NULL);
|
||||
}
|
||||
|
||||
int ra37xx_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
int retval, buflen;
|
||||
|
||||
retval = ra37xx_transaction (rig, "QCHAN", buf, &buflen);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
*ch = atoi(buf+4);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int ra37xx_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
int scantype;
|
||||
|
||||
switch (scan)
|
||||
{
|
||||
case RIG_SCAN_STOP: scantype = 0; break;
|
||||
case RIG_SCAN_VFO: scantype = 1; break;
|
||||
case RIG_SCAN_MEM: scantype = 2; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"Unsupported scan %#x", scan);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
sprintf(buf, "SCAN%d,0", scantype);
|
||||
|
||||
return ra37xx_transaction (rig, buf, NULL, NULL);
|
||||
}
|
||||
|
||||
int ra37xx_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
int ret, ch;
|
||||
|
||||
switch (op)
|
||||
{
|
||||
case RIG_OP_FROM_VFO:
|
||||
ret = rig_get_mem(rig, vfo, &ch);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sprintf(buf, "STRE%d", ch);
|
||||
return ra37xx_transaction (rig, buf, NULL, NULL);
|
||||
|
||||
case RIG_OP_TO_VFO:
|
||||
ret = rig_get_mem(rig, vfo, &ch);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sprintf(buf, "CHAN%d", ch);
|
||||
return ra37xx_transaction (rig, buf, NULL, NULL);
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"Unsupported op %#x", op);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Hamlib Racal backend - RA37XX header
|
||||
* Copyright (c) 2004-2010 by Stephane Fillod
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _RA37XX_H
|
||||
#define _RA37XX_H 1
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "racal.h"
|
||||
|
||||
extern const struct confparams ra37xx_cfg_params[];
|
||||
|
||||
/* Packet timeout at Master port, 5-9 */
|
||||
#define RA37XX_TIMEOUT 1000 /* ms */
|
||||
|
||||
|
||||
#define RA37XX_STR_CAL { 13, \
|
||||
{ \
|
||||
{ 97, 86 }, /* 120 dBuV */ \
|
||||
{ 109, 76 }, /* 110 dBuV */ \
|
||||
{ 120, 66 }, /* 100 dBuV */ \
|
||||
{ 132, 56 }, /* 90 dBuV */ \
|
||||
{ 144, 46 }, /* 80 dBuV */ \
|
||||
{ 155, 36 }, /* 70 dBuV */ \
|
||||
{ 167, 26 }, /* 60 dBuV */ \
|
||||
{ 179, 16 }, /* 50 dBuV */ \
|
||||
{ 190, 6 }, /* 40 dBuV */ \
|
||||
{ 202, -4 }, /* 30 dBuV */ \
|
||||
{ 214, -14 }, /* 20 dBuV */ \
|
||||
{ 225, -24 }, /* 10 dBuV */ \
|
||||
{ 255, -34 }, /* 0 dBuV */ \
|
||||
} }
|
||||
|
||||
#define RA37XX_MEM_CAP { \
|
||||
.freq = 1, \
|
||||
.mode = 1, \
|
||||
.width = 1, \
|
||||
.levels = RIG_LEVEL_AGC|RIG_LEVEL_CWPITCH, \
|
||||
/* .flags = 1, */ \
|
||||
}
|
||||
|
||||
|
||||
struct ra37xx_priv_data {
|
||||
int receiver_id;
|
||||
};
|
||||
|
||||
int ra37xx_set_conf(RIG *rig, token_t token, const char *val);
|
||||
int ra37xx_get_conf(RIG *rig, token_t token, char *val);
|
||||
int ra37xx_init(RIG *rig);
|
||||
int ra37xx_cleanup(RIG *rig);
|
||||
int ra37xx_open(RIG *rig);
|
||||
int ra37xx_close(RIG *rig);
|
||||
|
||||
int ra37xx_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
int ra37xx_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
||||
int ra37xx_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
||||
int ra37xx_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
||||
int ra37xx_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
||||
int ra37xx_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status);
|
||||
int ra37xx_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
|
||||
int ra37xx_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
||||
const char* ra37xx_get_info(RIG *rig);
|
||||
int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant);
|
||||
int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t *ant);
|
||||
int ra37xx_set_mem(RIG *rig, vfo_t vfo, int ch);
|
||||
int ra37xx_get_mem(RIG *rig, vfo_t vfo, int *ch);
|
||||
int ra37xx_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch);
|
||||
int ra37xx_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
||||
|
||||
|
||||
#endif /* _RA37XX_H */
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Hamlib Racal backend - main file
|
||||
* Copyright (c) 2004-2009 by Stephane Fillod
|
||||
* Copyright (c) 2004-2010 by Stephane Fillod
|
||||
*
|
||||
* $Id: racal.c,v 1.2 2009-02-23 21:53:51 fillods Exp $
|
||||
*
|
||||
|
@ -468,6 +468,7 @@ DECLARE_INITRIG_BACKEND(racal)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "racal: _init called\n");
|
||||
|
||||
rig_register(&ra6790_caps);
|
||||
rig_register(&ra3702_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Hamlib Racal backend - main header
|
||||
* Copyright (c) 2004 by Stephane Fillod
|
||||
* Copyright (c) 2004-2010 by Stephane Fillod
|
||||
*
|
||||
* $Id: racal.h,v 1.1 2004-09-12 21:28:26 fillods Exp $
|
||||
*
|
||||
|
@ -52,6 +52,7 @@ int racal_reset(RIG *rig, reset_t reset);
|
|||
const char* racal_get_info(RIG *rig);
|
||||
|
||||
extern const struct rig_caps ra6790_caps;
|
||||
extern const struct rig_caps ra3702_caps;
|
||||
|
||||
|
||||
#endif /* _RACAL_H */
|
||||
|
|
Ładowanie…
Reference in New Issue