2003-09-28 16:14:00 +00:00
|
|
|
/*
|
|
|
|
* Hamlib Kenwood backend - TH-G71 description
|
2010-09-07 21:11:13 +00:00
|
|
|
* Copyright (c) 2003-2010 by Stephane Fillod
|
2003-09-28 16:14:00 +00:00
|
|
|
*
|
|
|
|
*
|
2011-08-21 02:20:21 +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.
|
2003-09-28 16:14:00 +00:00
|
|
|
*
|
2011-08-21 02:20:21 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2003-09-28 16:14:00 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-08-21 02:20:21 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2003-09-28 16:14:00 +00:00
|
|
|
*
|
2011-08-21 02:20:21 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2003-09-28 16:14:00 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2011-08-21 02:20:21 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-09-28 16:14:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2003-10-01 19:32:04 +00:00
|
|
|
#include <stdlib.h>
|
2003-11-29 13:36:30 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
2003-10-01 19:32:04 +00:00
|
|
|
|
2003-09-28 16:14:00 +00:00
|
|
|
#include <hamlib/rig.h>
|
|
|
|
#include "kenwood.h"
|
|
|
|
#include "th.h"
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
#define RIG_ASSERT(x) if (!(x)) { rig_debug(RIG_DEBUG_ERR, "Assertion failed on line %i\n",__LINE__); abort(); }
|
|
|
|
#else
|
|
|
|
#define RIG_ASSERT(x)
|
|
|
|
#endif
|
|
|
|
|
2003-11-29 13:36:30 +00:00
|
|
|
#define THG71_FUNC_ALL (\
|
|
|
|
RIG_FUNC_TBURST \
|
|
|
|
)
|
2003-09-28 16:14:00 +00:00
|
|
|
|
2003-11-29 13:36:30 +00:00
|
|
|
#define THG71_LEVEL_ALL (\
|
2003-12-02 22:47:56 +00:00
|
|
|
RIG_LEVEL_RAWSTR| \
|
2003-09-28 16:14:00 +00:00
|
|
|
RIG_LEVEL_SQL| \
|
2003-11-29 13:36:30 +00:00
|
|
|
RIG_LEVEL_RFPOWER\
|
|
|
|
)
|
2003-09-28 16:14:00 +00:00
|
|
|
|
2003-12-02 22:47:56 +00:00
|
|
|
#ifndef RIG_TONEMAX
|
|
|
|
#define RIG_TONEMAX 38
|
|
|
|
#endif
|
|
|
|
|
2003-11-29 13:36:30 +00:00
|
|
|
#define RIG_VFO_A_OP (RIG_OP_UP|RIG_OP_DOWN)
|
|
|
|
|
|
|
|
#define ACKBUF_LEN 128
|
2003-09-28 16:14:00 +00:00
|
|
|
|
2010-09-07 21:11:13 +00:00
|
|
|
static rmode_t thg71_mode_table[KENWOOD_MODE_TABLE_MAX] = {
|
|
|
|
[0] = RIG_MODE_FM,
|
|
|
|
[1] = RIG_MODE_AM,
|
|
|
|
};
|
|
|
|
|
2009-01-28 23:30:59 +00:00
|
|
|
static struct kenwood_priv_caps thg71_priv_caps = {
|
2003-09-28 16:14:00 +00:00
|
|
|
.cmdtrm = EOM_TH, /* Command termination character */
|
2010-09-07 21:11:13 +00:00
|
|
|
.mode_table = thg71_mode_table,
|
2003-09-28 16:14:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-11-29 13:36:30 +00:00
|
|
|
/* thg71 procs */
|
2005-02-24 22:35:24 +00:00
|
|
|
static int thg71_open(RIG *rig);
|
|
|
|
static int thg71_decode_event (RIG *rig);
|
|
|
|
static int thg71_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
|
|
|
static int thg71_set_vfo (RIG *rig, vfo_t vfo);
|
|
|
|
static int thg71_get_vfo (RIG *rig, vfo_t *vfo);
|
|
|
|
static int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
2003-09-28 16:14:00 +00:00
|
|
|
/*
|
|
|
|
* th-g71 rig capabilities.
|
2011-09-10 14:31:11 +00:00
|
|
|
*
|
|
|
|
* http://www.iw5edi.com/ham-radio/files/TH-G71_Serial_Protocol.pdf
|
2003-09-28 16:14:00 +00:00
|
|
|
*/
|
|
|
|
const struct rig_caps thg71_caps = {
|
|
|
|
.rig_model = RIG_MODEL_THG71,
|
|
|
|
.model_name = "TH-G71",
|
|
|
|
.mfg_name = "Kenwood",
|
2005-04-03 20:23:19 +00:00
|
|
|
.version = TH_VER,
|
2003-09-28 16:14:00 +00:00
|
|
|
.copyright = "LGPL",
|
2003-11-29 13:36:30 +00:00
|
|
|
.status = RIG_STATUS_BETA,
|
2003-09-28 16:14:00 +00:00
|
|
|
.rig_type = RIG_TYPE_HANDHELD,
|
|
|
|
.ptt_type = RIG_PTT_RIG,
|
|
|
|
.dcd_type = RIG_DCD_RIG,
|
|
|
|
.port_type = RIG_PORT_SERIAL,
|
|
|
|
.serial_rate_min = 9600,
|
|
|
|
.serial_rate_max = 9600,
|
|
|
|
.serial_data_bits = 8,
|
|
|
|
.serial_stop_bits = 1,
|
|
|
|
.serial_parity = RIG_PARITY_NONE,
|
|
|
|
.serial_handshake = RIG_HANDSHAKE_NONE,
|
2003-11-29 13:36:30 +00:00
|
|
|
.write_delay = 1,
|
2003-09-28 16:14:00 +00:00
|
|
|
.post_write_delay = 0,
|
2003-11-29 13:36:30 +00:00
|
|
|
.timeout = 500,
|
2003-09-28 16:14:00 +00:00
|
|
|
.retry = 3,
|
|
|
|
|
|
|
|
.has_set_func = THG71_FUNC_ALL,
|
|
|
|
.has_get_level = THG71_LEVEL_ALL,
|
|
|
|
.has_set_level = RIG_LEVEL_SET(THG71_LEVEL_ALL),
|
2003-12-02 22:47:56 +00:00
|
|
|
.level_gran = {
|
2003-12-08 08:46:11 +00:00
|
|
|
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 5 } },
|
|
|
|
[LVL_SQL] = { .min = { .i = 0 }, .max = { .i = 5 } },
|
2004-03-21 18:25:54 +00:00
|
|
|
[LVL_RFPOWER] = { .min = { .i = 3 }, .max = { .i = 0 } },
|
2003-12-02 22:47:56 +00:00
|
|
|
},
|
2003-09-28 16:14:00 +00:00
|
|
|
.parm_gran = {},
|
|
|
|
.ctcss_list = kenwood38_ctcss_list,
|
|
|
|
.dcs_list = NULL,
|
|
|
|
.preamp = { RIG_DBLST_END, },
|
|
|
|
.attenuator = { RIG_DBLST_END, },
|
|
|
|
.max_rit = Hz(0),
|
|
|
|
.max_xit = Hz(0),
|
|
|
|
.max_ifshift = Hz(0),
|
2003-11-29 13:36:30 +00:00
|
|
|
.vfo_ops = RIG_VFO_A_OP,
|
|
|
|
.targetable_vfo = RIG_TARGETABLE_NONE,
|
2003-09-28 16:14:00 +00:00
|
|
|
.transceive = RIG_TRN_RIG,
|
|
|
|
.bank_qty = 0,
|
2003-11-29 13:36:30 +00:00
|
|
|
.chan_desc_sz = 6,
|
2003-09-28 16:14:00 +00:00
|
|
|
|
|
|
|
|
2011-08-21 02:20:21 +00:00
|
|
|
.chan_list = {
|
2004-03-20 16:48:34 +00:00
|
|
|
{ 1, 199, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* normal MEM */
|
2008-04-27 09:53:40 +00:00
|
|
|
{ 200,209, RIG_MTYPE_EDGE , {TH_CHANNEL_CAPS}}, /* L MEM */
|
|
|
|
{ 210,219, RIG_MTYPE_EDGE , {TH_CHANNEL_CAPS}}, /* U MEM */
|
|
|
|
{ 220,220, RIG_MTYPE_PRIO , {TH_CHANNEL_CAPS}}, /* Priority */
|
|
|
|
{ 221,222, RIG_MTYPE_CALL , {TH_CHANNEL_CAPS}}, /* Call 0/1 */
|
2008-05-04 21:15:17 +00:00
|
|
|
{ 223,231, RIG_MTYPE_BAND , {TH_CHANNEL_CAPS}}, /* Band VFO */
|
2003-09-28 16:14:00 +00:00
|
|
|
RIG_CHAN_END,
|
2003-11-29 13:36:30 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/* no rx/tx_range_list */
|
|
|
|
/* computed in thg71_open */
|
2003-09-28 16:14:00 +00:00
|
|
|
|
|
|
|
.tuning_steps = {
|
2003-11-29 13:36:30 +00:00
|
|
|
{RIG_MODE_FM,kHz(5)},
|
|
|
|
{RIG_MODE_FM,kHz(6.25)},
|
|
|
|
{RIG_MODE_FM,kHz(10)},
|
|
|
|
{RIG_MODE_FM,kHz(12.5)},
|
|
|
|
{RIG_MODE_FM,kHz(15)},
|
|
|
|
{RIG_MODE_FM,kHz(20)},
|
|
|
|
{RIG_MODE_FM,kHz(25)},
|
|
|
|
{RIG_MODE_FM,kHz(30)},
|
|
|
|
{RIG_MODE_FM,kHz(50)},
|
|
|
|
{RIG_MODE_FM,kHz(100)},
|
2003-09-28 16:14:00 +00:00
|
|
|
RIG_TS_END,
|
|
|
|
},
|
|
|
|
/* mode/filter list, remember: order matters! */
|
|
|
|
.filters = {
|
2003-11-29 13:36:30 +00:00
|
|
|
{RIG_MODE_FM, kHz(12)},
|
|
|
|
{RIG_MODE_AM, kHz(9)},
|
|
|
|
RIG_FLT_END,
|
2003-09-28 16:14:00 +00:00
|
|
|
},
|
2003-12-02 22:47:56 +00:00
|
|
|
|
2004-12-06 22:16:55 +00:00
|
|
|
.str_cal ={ 3, { { 0, -60 }, {1, -30 }, {5,-13}}}, /* guessed from technical manual */
|
2003-12-02 22:47:56 +00:00
|
|
|
|
2003-09-28 16:14:00 +00:00
|
|
|
.priv = (void *)&thg71_priv_caps,
|
Several Kenwood patches from Alessandro Zummo, azummo-lists@towertech.it
Among the changes:
I finally had the time to build the CAT interface for my TS450 and
discovered a couple of new commands.
MX; MX0; MX1; is used to activate the AIP function
FL; FLXXXYYY; is used to set the filters.
I made a perl script to try every possible two-letters command. If
amyone is interested, at their own risk, just ask.
I've then modified and optimized the kenwood driver:
- moved MD_ defined to .h
- added init/cleanup
- ts450_get_mode -> kenwood_get_mode_if
- support reading memory channel freq within kenwood_get_freq
- added kenwood_safe_transaction as an helper with result len check
- added kenwood_get_if
- added get_level for RIG_LEVEL_CWPITCH
- set/get for RIG_FUNC_AIP
- replaced ts140/680 get_mode and get_freq
- removed the delay on the ts450. it works just fine without it.
=============================
the attached patch requires the first one I sent and
addresses a few remaining issues
- converted 8 spaces to tabs
- added kenwood_mode_table
- added kenwood_simple_transaction helper func
- use kenwood2rmode and rmode2kenwood where possible
- some code cleanup
- use kenwood_safe/simple_transaction where possible
- added kenwood_get_mem_if (ts140,ts450,ts680,ts690,ts850)
- added kenwood_get_channel (ts450,ts850)
- added FUNC_FINE_STEP (commented out, we have no more func slots)
- added LEVEL_CWPITCH (set)
- no reason to have ts850_set_func, ts850_set_level
- ... ts480_get/set_ant, ts480_set_func
- ... ts570_set/get_ant, ts570_get_channel, ts570_get_rit
- ... ts680_set_func
- ... ts790_get_mode, ts790_get_vfo
this patch is a bit more extensive and tested only on the TS450.
feedback will be appreciated.
where I removed code I took care to verify that the generic
code in kenwood.c worked in the same way.
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2591 7ae35d74-ebe9-4afe-98af-79ac388436b8
2009-01-23 03:24:42 +00:00
|
|
|
.rig_init = kenwood_init,
|
|
|
|
.rig_cleanup = kenwood_cleanup,
|
2003-11-29 13:36:30 +00:00
|
|
|
.rig_open = thg71_open,
|
2015-11-29 18:26:39 +00:00
|
|
|
.rig_close = kenwood_close,
|
2003-09-28 16:14:00 +00:00
|
|
|
|
|
|
|
.set_freq = th_set_freq,
|
|
|
|
.get_freq = th_get_freq,
|
2003-11-29 13:36:30 +00:00
|
|
|
.get_mode = thg71_get_mode,
|
|
|
|
.set_vfo = thg71_set_vfo,
|
|
|
|
.get_vfo = thg71_get_vfo,
|
2003-09-28 16:14:00 +00:00
|
|
|
.set_mem = th_set_mem,
|
|
|
|
.get_mem = th_get_mem,
|
2004-03-20 16:48:34 +00:00
|
|
|
.set_channel = th_set_channel,
|
|
|
|
.get_channel = th_get_channel,
|
2003-09-28 16:14:00 +00:00
|
|
|
.set_trn = th_set_trn,
|
|
|
|
.get_trn = th_get_trn,
|
|
|
|
|
2003-11-29 13:36:30 +00:00
|
|
|
.set_func = thg71_set_func,
|
|
|
|
.get_level = th_get_level,
|
|
|
|
.set_level = th_set_level,
|
2003-09-28 16:14:00 +00:00
|
|
|
.get_info = th_get_info,
|
2003-11-29 13:36:30 +00:00
|
|
|
.vfo_op = th_vfo_op,
|
|
|
|
.set_ptt = th_set_ptt,
|
|
|
|
.get_dcd=th_get_dcd,
|
|
|
|
.decode_event = thg71_decode_event,
|
2003-09-28 16:14:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-11-29 13:36:30 +00:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int thg71_decode_event (RIG *rig)
|
|
|
|
{
|
|
|
|
char asyncbuf[ACKBUF_LEN];
|
2006-03-09 19:51:17 +00:00
|
|
|
int retval;
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
2015-02-16 12:46:35 +00:00
|
|
|
retval = kenwood_transaction(rig, NULL, asyncbuf, sizeof (asyncbuf));
|
2003-11-29 13:36:30 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Decoding message\n", __func__);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
if (asyncbuf[0] == 'B' && asyncbuf[1] == 'U' && asyncbuf[2] == 'F') {
|
|
|
|
|
|
|
|
freq_t freq, offset;
|
|
|
|
int step, shift, rev, tone, ctcss, tonefq, ctcssfq;
|
|
|
|
|
2005-01-24 23:04:35 +00:00
|
|
|
retval = sscanf(asyncbuf, "BUF 0,%"SCNfreq",%d,%d,%d,%d,%d,,%d,,%d,%"SCNfreq,
|
2003-11-29 13:36:30 +00:00
|
|
|
&freq, &step, &shift, &rev, &tone,
|
|
|
|
&ctcss, &tonefq, &ctcssfq, &offset);
|
|
|
|
if (retval != 11) {
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected BUF message '%s'\n", __func__, asyncbuf);
|
2003-11-29 13:36:30 +00:00
|
|
|
return -RIG_ERJCTED;
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:04:31 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Buffer (freq %"PRIfreq" Hz)\n", __func__, freq);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
/* Callback execution */
|
|
|
|
if (rig->callbacks.vfo_event) {
|
|
|
|
rig->callbacks.vfo_event(rig, RIG_VFO_A, rig->callbacks.vfo_arg);
|
|
|
|
}
|
|
|
|
if (rig->callbacks.freq_event) {
|
|
|
|
rig->callbacks.freq_event(rig, RIG_VFO_A, freq, rig->callbacks.freq_arg);
|
|
|
|
}
|
2011-08-21 02:20:21 +00:00
|
|
|
/*
|
2003-11-29 13:36:30 +00:00
|
|
|
if (rig->callbacks.mode_event) {
|
|
|
|
rig->callbacks.mode_event(rig, RIG_VFO_A, mode, RIG_PASSBAND_NORMAL,
|
|
|
|
rig->callbacks.mode_arg);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
} else if (asyncbuf[0] == 'S' && asyncbuf[1] == 'M') {
|
|
|
|
|
|
|
|
int lev;
|
|
|
|
retval = sscanf(asyncbuf, "SM 0,%d", &lev);
|
|
|
|
if (retval != 2) {
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected SM message '%s'\n", __func__, asyncbuf);
|
2003-11-29 13:36:30 +00:00
|
|
|
return -RIG_ERJCTED;
|
|
|
|
}
|
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Signal strength event - signal = %.3f\n", __func__, (float)(lev / 5.0));
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
/* Callback execution */
|
|
|
|
#if STILLHAVETOADDCALLBACK
|
|
|
|
if (rig->callbacks.strength_event)
|
|
|
|
rig->callbacks.strength_event(rig, RIG_VFO_0,(float)(lev / 5.0),
|
|
|
|
rig->callbacks.strength_arg);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
} else if (asyncbuf[0] == 'B' && asyncbuf[1] == 'Y') {
|
|
|
|
|
|
|
|
int busy;
|
|
|
|
|
|
|
|
retval = sscanf(asyncbuf, "BY 0,%d", &busy);
|
|
|
|
if (retval != 2) {
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected BY message '%s'\n", __func__, asyncbuf);
|
2003-11-29 13:36:30 +00:00
|
|
|
return -RIG_ERJCTED;
|
|
|
|
}
|
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Busy event - status = '%s'\n",
|
2009-02-03 23:22:58 +00:00
|
|
|
__func__, (busy == 0) ? "OFF" : "ON" );
|
2003-11-29 13:36:30 +00:00
|
|
|
return -RIG_ENIMPL;
|
|
|
|
/* This event does not have a callback. */
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
} else if (asyncbuf[0] == 'V' && asyncbuf[1] == 'M' && asyncbuf[2] == 'C') {
|
|
|
|
|
|
|
|
vfo_t bandmode;
|
|
|
|
|
|
|
|
retval = sscanf(asyncbuf, "VMC 0,%d", &bandmode);
|
|
|
|
if (retval != 1) {
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected VMC message '%s'\n", __func__, asyncbuf);
|
2003-11-29 13:36:30 +00:00
|
|
|
return -RIG_ERJCTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (bandmode) {
|
|
|
|
case 0: bandmode = RIG_VFO_VFO; break;
|
|
|
|
case 2: bandmode = RIG_VFO_MEM; break;
|
|
|
|
/* case 3: bandmode = RIG_VFO_CALL; break; */
|
2011-08-21 02:20:21 +00:00
|
|
|
default: bandmode = RIG_VFO_CURR; break;
|
2003-11-29 13:36:30 +00:00
|
|
|
}
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Mode of Band event - %d\n", __func__, bandmode);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
/* TODO: This event does not have a callback! */
|
|
|
|
return -RIG_ENIMPL;
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
} else {
|
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported transceive cmd '%s'\n", __func__, asyncbuf);
|
2003-11-29 13:36:30 +00:00
|
|
|
return -RIG_ENIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int thg71_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|
|
|
{
|
|
|
|
char ackbuf[ACKBUF_LEN];
|
2006-03-09 19:51:17 +00:00
|
|
|
int retval;
|
2003-11-29 13:36:30 +00:00
|
|
|
int step;
|
2004-01-15 22:43:59 +00:00
|
|
|
freq_t freq;
|
2003-11-29 13:36:30 +00:00
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
switch (vfo) {
|
|
|
|
case RIG_VFO_CURR: break;
|
|
|
|
case RIG_VFO_A: break;
|
|
|
|
default:
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __func__, vfo);
|
2003-11-30 20:27:01 +00:00
|
|
|
return -RIG_EVFO;
|
2003-11-29 13:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* try to guess from frequency */
|
2015-02-16 12:46:35 +00:00
|
|
|
retval = kenwood_transaction(rig, "FQ", ackbuf, sizeof (ackbuf));
|
2003-11-29 13:36:30 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
2005-01-24 23:04:35 +00:00
|
|
|
sscanf(ackbuf,"FQ %"SCNfreq",%d",&freq,&step);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
if(freq <MHz(136) ) {
|
|
|
|
*mode=RIG_MODE_AM;
|
|
|
|
*width=kHz(9);
|
|
|
|
} else {
|
|
|
|
*mode=RIG_MODE_FM;
|
|
|
|
*width=kHz(12);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int thg71_set_vfo (RIG *rig, vfo_t vfo)
|
|
|
|
{
|
2015-02-16 12:46:35 +00:00
|
|
|
char vfobuf[16];
|
2006-03-09 19:51:17 +00:00
|
|
|
int retval;
|
2003-11-29 13:36:30 +00:00
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
switch (vfo) {
|
|
|
|
case RIG_VFO_A:
|
|
|
|
case RIG_VFO_VFO:
|
2010-04-24 13:52:42 +00:00
|
|
|
sprintf(vfobuf, "VMC 0,0");
|
2003-11-29 13:36:30 +00:00
|
|
|
break;
|
|
|
|
case RIG_VFO_MEM:
|
2010-04-24 13:52:42 +00:00
|
|
|
sprintf(vfobuf, "VMC 0,2");
|
2003-11-29 13:36:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __func__, vfo);
|
2003-11-30 20:27:01 +00:00
|
|
|
return -RIG_EVFO;
|
2003-11-29 13:36:30 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 12:46:35 +00:00
|
|
|
retval = kenwood_transaction(rig, vfobuf, NULL, 0);
|
2003-11-29 13:36:30 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int thg71_get_vfo (RIG *rig, vfo_t *vfo)
|
|
|
|
{
|
|
|
|
char ackbuf[ACKBUF_LEN];
|
2006-03-09 19:51:17 +00:00
|
|
|
int retval;
|
2003-11-29 13:36:30 +00:00
|
|
|
int vch;
|
|
|
|
|
2015-02-16 12:46:35 +00:00
|
|
|
retval = kenwood_transaction(rig, "VMC 0" , ackbuf, sizeof (ackbuf));
|
2003-11-29 13:36:30 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
2010-04-24 13:52:42 +00:00
|
|
|
sscanf(ackbuf,"VMC 0,%d",&vch);
|
2003-11-29 13:36:30 +00:00
|
|
|
switch(vch) {
|
|
|
|
case 0:
|
|
|
|
*vfo=RIG_VFO_A;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
*vfo=RIG_VFO_MEM;
|
|
|
|
break;
|
|
|
|
default:
|
2019-11-30 16:04:31 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %s\n", __func__, rig_strvfo(*vfo));
|
2003-11-30 20:27:01 +00:00
|
|
|
return -RIG_EVFO;
|
2003-11-29 13:36:30 +00:00
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|
|
|
{
|
2006-03-09 19:51:17 +00:00
|
|
|
int retval;
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
if(func != RIG_FUNC_TBURST)
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
|
|
|
|
if(status==1) {
|
2015-02-16 12:46:35 +00:00
|
|
|
retval = kenwood_transaction(rig, "TT", NULL, 0);
|
2003-11-29 13:36:30 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
if(status==0) {
|
|
|
|
return rig_set_ptt(rig,vfo,RIG_PTT_OFF);
|
|
|
|
}
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int thg71_open(RIG *rig)
|
|
|
|
{
|
|
|
|
char ackbuf[ACKBUF_LEN],*strl,*stru;
|
2006-03-09 19:51:17 +00:00
|
|
|
int retval,i;
|
2003-11-29 13:36:30 +00:00
|
|
|
const freq_range_t frend=RIG_FRNG_END;
|
|
|
|
|
2009-02-03 22:42:44 +00:00
|
|
|
/* this will check the model id */
|
|
|
|
retval = kenwood_open(rig);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
/* fill state.rx/tx range_list */
|
2015-02-16 12:46:35 +00:00
|
|
|
retval = kenwood_transaction(rig, "FL", ackbuf, sizeof (ackbuf));
|
2003-11-29 13:36:30 +00:00
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
strl=strtok(ackbuf," ");
|
|
|
|
for(i=0;i<FRQRANGESIZ;i++) {
|
|
|
|
freq_range_t frng;
|
|
|
|
|
|
|
|
strl=strtok(NULL,",");
|
|
|
|
stru=strtok(NULL,",");
|
|
|
|
if(strl==NULL && stru==NULL)
|
|
|
|
break;
|
2019-08-18 04:20:48 +00:00
|
|
|
frng.startf=MHz(atoi(strl));
|
|
|
|
frng.endf=MHz(atoi(stru));
|
2003-11-29 13:36:30 +00:00
|
|
|
frng.vfo=RIG_VFO_A;
|
|
|
|
frng.ant=0;
|
2019-08-18 04:20:48 +00:00
|
|
|
if(frng.endf<=MHz(135))
|
2003-11-29 13:36:30 +00:00
|
|
|
frng.modes=RIG_MODE_AM;
|
|
|
|
else
|
|
|
|
frng.modes=RIG_MODE_FM;
|
|
|
|
|
|
|
|
frng.high_power=-1;
|
|
|
|
frng.low_power=-1;
|
|
|
|
rig->state.rx_range_list[i]=frng;
|
2019-08-18 04:20:48 +00:00
|
|
|
if(frng.startf> MHz(200))
|
2017-07-10 07:55:45 +00:00
|
|
|
frng.high_power=mW(5500);
|
2003-11-29 13:36:30 +00:00
|
|
|
else
|
2017-07-10 07:55:45 +00:00
|
|
|
frng.high_power=mW(6000);
|
2003-11-29 13:36:30 +00:00
|
|
|
frng.low_power=mW(50);
|
|
|
|
rig->state.tx_range_list[i]=frng;
|
|
|
|
}
|
|
|
|
rig->state.rx_range_list[i]= frend;
|
|
|
|
rig->state.tx_range_list[i]= frend;
|
2004-12-06 22:16:55 +00:00
|
|
|
rig->state.vfo_list=RIG_VFO_A | RIG_VFO_MEM ;
|
2003-11-29 13:36:30 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
2003-09-28 16:14:00 +00:00
|
|
|
|