kopia lustrzana https://github.com/Hamlib/Hamlib
add Skanti TRP 8255 S R
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2944 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.12
rodzic
197f5a347c
commit
31bb15fb01
|
@ -192,7 +192,8 @@
|
|||
#define RIG_MODEL_IC7200 RIG_MAKE_MODEL(RIG_ICOM, 61)
|
||||
#define RIG_MODEL_IC7700 RIG_MAKE_MODEL(RIG_ICOM, 62)
|
||||
#define RIG_MODEL_IC7600 RIG_MAKE_MODEL(RIG_ICOM, 63)
|
||||
/* next one is 65 */
|
||||
#define RIG_MODEL_IC92D RIG_MAKE_MODEL(RIG_ICOM, 65)
|
||||
/* next one is 66 */
|
||||
|
||||
/*
|
||||
* Optoelectronics (CI-V)
|
||||
|
@ -344,6 +345,7 @@
|
|||
#define RIG_MODEL_TRP7000 RIG_MAKE_MODEL(RIG_SKANTI, 1)
|
||||
#define RIG_MODEL_TRP8000 RIG_MAKE_MODEL(RIG_SKANTI, 2)
|
||||
#define RIG_MODEL_TRP9000 RIG_MAKE_MODEL(RIG_SKANTI, 3)
|
||||
#define RIG_MODEL_TRP8255 RIG_MAKE_MODEL(RIG_SKANTI, 4)
|
||||
|
||||
/*
|
||||
* WiNRADiO/LinRADiO
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SKANTISRCLIST = trp8000.c
|
||||
SKANTISRCLIST = trp8000.c trp8255.c
|
||||
|
||||
lib_LTLIBRARIES = hamlib-skanti.la
|
||||
hamlib_skanti_la_SOURCES = $(SKANTISRCLIST) skanti.c
|
||||
|
|
|
@ -292,6 +292,7 @@ DECLARE_INITRIG_BACKEND(skanti)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "skanti: _init called\n");
|
||||
|
||||
rig_register(&trp8000_caps);
|
||||
rig_register(&trp8255_caps);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/*
|
||||
* Hamlib Skanti backend - main header
|
||||
* Copyright (c) 2004 by Stephane Fillod
|
||||
* Copyright (c) 2004-2010 by Stephane Fillod
|
||||
*
|
||||
* $Id: skanti.h,v 1.1 2004-08-18 18:51:24 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -34,5 +33,6 @@ int skanti_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
|||
int skanti_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
||||
|
||||
extern const struct rig_caps trp8000_caps;
|
||||
extern const struct rig_caps trp8255_caps;
|
||||
|
||||
#endif /* _SKANTI_H */
|
||||
|
|
|
@ -0,0 +1,395 @@
|
|||
/*
|
||||
* Hamlib Skanti backend - TRP8255 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 <string.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "idx_builtin.h"
|
||||
#include "skanti.h"
|
||||
#include "iofunc.h"
|
||||
|
||||
|
||||
#define TRP8255_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_RTTY)
|
||||
#define TRP8255_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_RTTY)
|
||||
#define TRP8255_AM_TX_MODES RIG_MODE_AM
|
||||
|
||||
#define TRP8255_FUNC (RIG_FUNC_MUTE)
|
||||
|
||||
#define TRP8255_LEVEL_ALL (RIG_LEVEL_RFPOWER|RIG_LEVEL_AGC|\
|
||||
RIG_LEVEL_ATT|RIG_LEVEL_PREAMP|RIG_LEVEL_SQL)
|
||||
|
||||
#define TRP8255_PARM_ALL (RIG_PARM_TIME|RIG_PARM_BACKLIGHT)
|
||||
|
||||
#define TRP8255_VFO_OPS (RIG_OP_TUNE|RIG_OP_TO_VFO|RIG_OP_FROM_VFO|RIG_OP_CPY)
|
||||
|
||||
#define TRP8255_VFO (RIG_VFO_A)
|
||||
|
||||
/*
|
||||
* Private data
|
||||
*/
|
||||
struct cu_priv_data {
|
||||
split_t split; /* current emulated split state */
|
||||
int ch; /* current memorized memory channel */
|
||||
};
|
||||
|
||||
static int cu_transaction(RIG *rig, const char *cmd, int cmd_len);
|
||||
static int cu_open(RIG *rig);
|
||||
static int cu_close(RIG *rig);
|
||||
static int cu_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
static int cu_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
||||
static int cu_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq);
|
||||
static int cu_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo);
|
||||
static int cu_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
|
||||
static int cu_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
||||
static int cu_set_mem(RIG *rig, vfo_t vfo, int ch);
|
||||
static int cu_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
||||
|
||||
/*
|
||||
* TRP 8255 rig capabilities.
|
||||
* The protocol is different than TRP8000,
|
||||
* because the TRP8255 has the "CU" (Control Unit).
|
||||
*
|
||||
*/
|
||||
const struct rig_caps trp8255_caps = {
|
||||
.rig_model = RIG_MODEL_TRP8255,
|
||||
.model_name = "TRP 8255 S R",
|
||||
.mfg_name = "Skanti",
|
||||
.version = "0.1",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_UNTESTED,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.dcd_type = RIG_DCD_NONE,
|
||||
.port_type = RIG_PORT_SERIAL,
|
||||
.serial_rate_min = 300,
|
||||
.serial_rate_max = 2400,
|
||||
.serial_data_bits = 7,
|
||||
.serial_stop_bits = 1,
|
||||
.serial_parity = RIG_PARITY_ODD,
|
||||
.serial_handshake = RIG_HANDSHAKE_NONE,
|
||||
.write_delay = 0,
|
||||
.post_write_delay = 0,
|
||||
.timeout = 2000,
|
||||
.retry = 3,
|
||||
|
||||
.has_get_func = RIG_FUNC_NONE,
|
||||
.has_set_func = TRP8255_FUNC,
|
||||
.has_get_level = RIG_LEVEL_NONE,
|
||||
.has_set_level = RIG_LEVEL_SET(TRP8255_LEVEL_ALL),
|
||||
.has_get_parm = RIG_PARM_NONE,
|
||||
.has_set_parm = RIG_PARM_SET(TRP8255_PARM_ALL),
|
||||
.vfo_ops = TRP8255_VFO_OPS,
|
||||
.preamp = { 10, RIG_DBLST_END }, /* TBC */
|
||||
.attenuator = { 20, RIG_DBLST_END }, /* TBC */
|
||||
.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,
|
||||
|
||||
.chan_list = { RIG_CHAN_END, }, // 76 ?
|
||||
|
||||
.rx_range_list1 = { RIG_FRNG_END, }, /* FIXME: enter region 1 setting */
|
||||
.tx_range_list1 = { RIG_FRNG_END, },
|
||||
.rx_range_list2 = {
|
||||
{kHz(500),MHz(30),TRP8255_ALL_MODES,-1,-1,TRP8255_VFO},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tx_range_list2 = {
|
||||
{MHz(2),MHz(30),TRP8255_AM_TX_MODES,W(4),W(40),TRP8255_VFO},
|
||||
{MHz(2),MHz(30),TRP8255_OTHER_TX_MODES,W(10),W(100),TRP8255_VFO},
|
||||
RIG_FRNG_END,
|
||||
},
|
||||
.tuning_steps = {
|
||||
{TRP8255_ALL_MODES,10},
|
||||
{TRP8255_ALL_MODES,100},
|
||||
{TRP8255_ALL_MODES,kHz(1)},
|
||||
RIG_TS_END,
|
||||
},
|
||||
/* mode/filter list, remember: order matters! */
|
||||
.filters = {
|
||||
/* rough guesses */
|
||||
{TRP8255_ALL_MODES, kHz(2.7)}, /* intermit */
|
||||
{TRP8255_ALL_MODES, kHz(2.1)}, /* narrow */
|
||||
{TRP8255_ALL_MODES, kHz(6)}, /* wide */
|
||||
{TRP8255_ALL_MODES, Hz(500)}, /* very narrow */
|
||||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.rig_open = cu_open,
|
||||
.rig_close = cu_close,
|
||||
.set_freq = cu_set_freq,
|
||||
.set_mode = cu_set_mode,
|
||||
.set_split_freq = cu_set_split_freq,
|
||||
.set_split_vfo = cu_set_split_vfo,
|
||||
.set_ptt = cu_set_ptt,
|
||||
.set_mem = cu_set_mem,
|
||||
.vfo_op = cu_vfo_op,
|
||||
.set_level = cu_set_level,
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
||||
#define ACK 0x06
|
||||
#define NACK 0x15
|
||||
#define CR "\x0d"
|
||||
|
||||
static int cu_transaction(RIG *rig, const char *cmd, int cmd_len)
|
||||
{
|
||||
int i, ret;
|
||||
char retchar;
|
||||
|
||||
for (i = 0; i < cmd_len; i++) {
|
||||
|
||||
ret = write_block(&rig->state.rigport, &cmd[i], 1);
|
||||
if (ret != RIG_OK)
|
||||
return ret;
|
||||
|
||||
ret = read_block(&rig->state.rigport, &retchar, 1);
|
||||
switch(retchar) {
|
||||
case ACK: continue;
|
||||
case NACK:
|
||||
default: return -RIG_EPROTO;
|
||||
}
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
static int cu_open(RIG *rig)
|
||||
{
|
||||
char cmd[] = { 0x01, 0x02 }; /* SOH, STX */
|
||||
struct cu_priv_data *priv;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s called\n",__func__);
|
||||
|
||||
rig->state.priv = malloc(sizeof (struct cu_priv_data));
|
||||
if (!rig->state.priv)
|
||||
return -RIG_ENOMEM;
|
||||
|
||||
priv = (struct cu_priv_data *)rig->state.priv;
|
||||
|
||||
memset(priv, 0, sizeof(struct cu_priv_data));
|
||||
priv->split = RIG_SPLIT_OFF;
|
||||
priv->ch = 0;
|
||||
|
||||
return cu_transaction(rig, cmd, 2);
|
||||
}
|
||||
|
||||
static int cu_close(RIG *rig)
|
||||
{
|
||||
char cmd[] = { 0x16 }; /* DLE */
|
||||
struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv;
|
||||
|
||||
free(priv);
|
||||
|
||||
return cu_transaction(rig, cmd, 1);
|
||||
}
|
||||
|
||||
int cu_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv;
|
||||
char cmdbuf[16];
|
||||
int cmd_len;
|
||||
int ret;
|
||||
|
||||
if (freq >= MHz(100))
|
||||
return -RIG_EINVAL;
|
||||
|
||||
/* RX freq */
|
||||
cmd_len = sprintf(cmdbuf, ":%06u"CR, (unsigned)(freq/Hz(100)));
|
||||
|
||||
ret = cu_transaction(rig, cmdbuf, cmd_len);
|
||||
if (ret != RIG_OK)
|
||||
return ret;
|
||||
|
||||
if (priv->split != RIG_SPLIT_ON)
|
||||
return cu_vfo_op(rig, vfo, RIG_OP_CPY);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
static int cu_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
||||
{
|
||||
struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv;
|
||||
|
||||
priv->split = split;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int cu_set_split_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
char cmdbuf[16];
|
||||
int cmd_len;
|
||||
|
||||
if (freq >= MHz(100))
|
||||
return -RIG_EINVAL;
|
||||
|
||||
/* TX freq */
|
||||
cmd_len = sprintf(cmdbuf, ";%06u"CR, (unsigned)(freq/Hz(100)));
|
||||
|
||||
return cu_transaction(rig, cmdbuf, cmd_len);
|
||||
}
|
||||
|
||||
int cu_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
char cmd;
|
||||
int ret;
|
||||
|
||||
switch (mode) {
|
||||
case RIG_MODE_USB: cmd = 'X'; break;
|
||||
case RIG_MODE_LSB: cmd = 'Y'; break;
|
||||
case RIG_MODE_AM: cmd = 'Z'; break;
|
||||
case RIG_MODE_RTTY: cmd = '['; break;
|
||||
/* case RIG_MODE_R3E: cmd = '\\'; break; */
|
||||
case RIG_MODE_CW: cmd = ']'; break;
|
||||
/* case RIG_MODE_MCW: cmd = '^'; break; */
|
||||
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
ret = cu_transaction(rig, &cmd, 1);
|
||||
if (ret != RIG_OK)
|
||||
return ret;
|
||||
|
||||
if (width == RIG_PASSBAND_NORMAL)
|
||||
width = rig_passband_normal(rig, mode);
|
||||
|
||||
if (width < rig_passband_normal(rig, mode))
|
||||
cmd = 'D';
|
||||
else if (width > rig_passband_normal(rig, mode))
|
||||
cmd = 'B';
|
||||
else
|
||||
cmd = 'C';
|
||||
|
||||
return cu_transaction(rig, &cmd, 1);
|
||||
}
|
||||
|
||||
int cu_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
{
|
||||
char cmdbuf[16];
|
||||
int cmd_len;
|
||||
|
||||
cmd_len = 1;
|
||||
|
||||
switch (level) {
|
||||
case RIG_LEVEL_PREAMP:
|
||||
cmdbuf[0] = val.i ? 'm' : 'n';
|
||||
break;
|
||||
case RIG_LEVEL_ATT:
|
||||
cmdbuf[0] = val.i ? 'o' : 'p';
|
||||
break;
|
||||
case RIG_LEVEL_AGC:
|
||||
switch (val.i) {
|
||||
case RIG_AGC_AUTO: cmdbuf[0] = 'J'; break;
|
||||
case RIG_AGC_FAST: cmdbuf[0] = 'K'; break;
|
||||
case RIG_AGC_SLOW: cmdbuf[0] = 'L'; break;
|
||||
case RIG_AGC_OFF: cmdbuf[0] = 'M'; break;
|
||||
default: return -RIG_EINVAL;
|
||||
}
|
||||
break;
|
||||
case RIG_LEVEL_SQL:
|
||||
cmdbuf[0] = val.i ? 'o' : 'p';
|
||||
break;
|
||||
case RIG_LEVEL_RFPOWER:
|
||||
if (val.f < 0.4)
|
||||
cmdbuf[0] = 'S'; /* low */
|
||||
if (val.f < 0.6)
|
||||
cmdbuf[0] = 'U'; /* medium */
|
||||
else
|
||||
cmdbuf[0] = 'W'; /* high */
|
||||
break;
|
||||
case RIG_LEVEL_AF:
|
||||
cmd_len = sprintf(cmdbuf, "y%02u"CR, (unsigned)(99-val.f*99));
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return cu_transaction(rig, cmdbuf, cmd_len);
|
||||
}
|
||||
|
||||
/* cu_set_func: TODO: MUTE, */
|
||||
/* cu_set_parm: TODO: TIME, BACKLIGHT */
|
||||
/* cu_set_ts: */
|
||||
|
||||
int cu_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||
{
|
||||
char cmd;
|
||||
|
||||
cmd = ptt == RIG_PTT_ON ? 'u' : 'v';
|
||||
|
||||
return cu_transaction(rig, &cmd, 1);
|
||||
}
|
||||
|
||||
static int cu_set_mem(RIG *rig, vfo_t vfo, int ch)
|
||||
{
|
||||
struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv;
|
||||
|
||||
priv->ch = ch;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
int cu_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
||||
{
|
||||
struct cu_priv_data *priv = (struct cu_priv_data *)rig->state.priv;
|
||||
char cmdbuf[16];
|
||||
int cmd_len;
|
||||
|
||||
switch (op) {
|
||||
case RIG_OP_TUNE:
|
||||
cmdbuf[0] = 'R';
|
||||
cmd_len = 1;
|
||||
break;
|
||||
case RIG_OP_CPY:
|
||||
cmdbuf[0] = ':';
|
||||
cmdbuf[1] = ';';
|
||||
cmdbuf[2] = 0x0d;
|
||||
cmd_len = 3;
|
||||
break;
|
||||
case RIG_OP_TO_VFO:
|
||||
cmd_len = sprintf(cmdbuf, "<%02u"CR, (unsigned)priv->ch);
|
||||
break;
|
||||
case RIG_OP_FROM_VFO:
|
||||
cmd_len = sprintf(cmdbuf, "d%02u"CR, (unsigned)priv->ch);
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
return cu_transaction(rig, cmdbuf, cmd_len);
|
||||
}
|
||||
|
||||
|
||||
|
Ładowanie…
Reference in New Issue