2004-03-20 10:23:43 +00:00
|
|
|
/*
|
|
|
|
* Hamlib Kenwood backend - TM-V7 description
|
2010-04-26 21:35:37 +00:00
|
|
|
* Copyright (c) 2004-2010 by Stephane Fillod
|
2004-03-20 10:23:43 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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 <stdio.h>
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
|
|
|
|
#include <hamlib/rig.h>
|
|
|
|
#include "kenwood.h"
|
|
|
|
#include "th.h"
|
2005-01-25 00:22:14 +00:00
|
|
|
#include "misc.h"
|
2004-03-20 10:23:43 +00:00
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define TMV7_FUNC_ALL (\
|
|
|
|
RIG_FUNC_TBURST \
|
|
|
|
)
|
|
|
|
|
|
|
|
#define TMV7_LEVEL_ALL (\
|
|
|
|
RIG_LEVEL_RAWSTR| \
|
|
|
|
RIG_LEVEL_SQL| \
|
2004-03-21 16:58:07 +00:00
|
|
|
RIG_LEVEL_AF| \
|
2004-03-20 10:23:43 +00:00
|
|
|
RIG_LEVEL_RFPOWER\
|
|
|
|
)
|
|
|
|
|
2004-12-28 11:08:00 +00:00
|
|
|
#define TMV7_CHANNEL_CAPS \
|
|
|
|
.freq=1,\
|
|
|
|
.tx_freq=1,\
|
|
|
|
.mode=1,\
|
|
|
|
.tuning_step=1,\
|
|
|
|
.rptr_shift=1,\
|
|
|
|
.ctcss_tone=1,\
|
|
|
|
.ctcss_sql=1,\
|
|
|
|
.channel_desc=1
|
|
|
|
|
2004-03-20 10:23:43 +00:00
|
|
|
#ifndef RIG_TONEMAX
|
|
|
|
#define RIG_TONEMAX 38
|
|
|
|
#endif
|
|
|
|
|
2004-03-21 18:26:46 +00:00
|
|
|
#define RIG_VFO_A_OP (RIG_OP_UP|RIG_OP_DOWN|RIG_OP_TO_VFO)
|
2004-03-20 10:23:43 +00:00
|
|
|
|
|
|
|
#define ACKBUF_LEN 128
|
|
|
|
|
2010-09-07 21:11:13 +00:00
|
|
|
static rmode_t tmv7_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 tmv7_priv_caps = {
|
2004-03-20 10:23:43 +00:00
|
|
|
.cmdtrm = EOM_TH, /* Command termination character */
|
2010-09-07 21:11:13 +00:00
|
|
|
.mode_table = tmv7_mode_table,
|
2004-03-20 10:23:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* tmv7 procs */
|
2005-02-24 22:35:24 +00:00
|
|
|
static int tmv7_decode_event (RIG *rig);
|
|
|
|
static int tmv7_set_vfo (RIG *rig, vfo_t vfo);
|
|
|
|
static int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
|
|
|
static int tmv7_get_powerstat (RIG *rig, powerstat_t *status);
|
|
|
|
static int tmv7_get_channel(RIG *rig, channel_t *chan);
|
|
|
|
static int tmv7_set_channel(RIG *rig, const channel_t *chan);
|
2004-03-20 10:23:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* tm-v7 rig capabilities.
|
|
|
|
*/
|
|
|
|
const struct rig_caps tmv7_caps = {
|
|
|
|
.rig_model = RIG_MODEL_TMV7,
|
|
|
|
.model_name = "TM-V7",
|
|
|
|
.mfg_name = "Kenwood",
|
2005-04-03 20:23:19 +00:00
|
|
|
.version = TH_VER,
|
2004-03-20 10:23:43 +00:00
|
|
|
.copyright = "LGPL",
|
2004-03-21 16:58:07 +00:00
|
|
|
.status = RIG_STATUS_BETA,
|
|
|
|
.rig_type = RIG_TYPE_MOBILE,
|
2004-03-20 10:23:43 +00:00
|
|
|
.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,
|
|
|
|
.write_delay = 1,
|
|
|
|
.post_write_delay = 0,
|
|
|
|
.timeout = 500,
|
|
|
|
.retry = 3,
|
|
|
|
|
|
|
|
.has_set_func = TMV7_FUNC_ALL,
|
|
|
|
.has_get_level = TMV7_LEVEL_ALL,
|
|
|
|
.has_set_level = RIG_LEVEL_SET(TMV7_LEVEL_ALL),
|
|
|
|
.level_gran = {
|
2004-03-21 18:26:46 +00:00
|
|
|
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 7 } },
|
|
|
|
[LVL_SQL] = { .min = { .i = 0 }, .max = { .i = 32 } },
|
|
|
|
[LVL_AF] = { .min = { .i = 0 }, .max = { .i = 32 } },
|
2004-11-11 17:53:38 +00:00
|
|
|
[LVL_RFPOWER] = { .min = { .i = 0 }, .max = { .i = 2 } },
|
2004-03-20 10:23:43 +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),
|
|
|
|
.vfo_ops = RIG_VFO_A_OP,
|
|
|
|
.targetable_vfo = RIG_TARGETABLE_NONE,
|
|
|
|
.transceive = RIG_TRN_RIG,
|
|
|
|
.bank_qty = 0,
|
|
|
|
.chan_desc_sz = 6,
|
|
|
|
|
|
|
|
|
|
|
|
.chan_list = {
|
2004-12-28 12:59:41 +00:00
|
|
|
{ 1, 90 , RIG_MTYPE_MEM , {TMV7_CHANNEL_CAPS}}, /* normal MEM VHF */
|
|
|
|
{ 101, 190, RIG_MTYPE_MEM , {TMV7_CHANNEL_CAPS}}, /* normal MEM UHF */
|
2004-12-28 11:08:00 +00:00
|
|
|
{ 201,206, RIG_MTYPE_EDGE , {TMV7_CHANNEL_CAPS}}, /* L MEM */
|
|
|
|
{ 211,216, RIG_MTYPE_EDGE , {TMV7_CHANNEL_CAPS}}, /* U MEM */
|
2008-05-04 21:23:26 +00:00
|
|
|
{ 221,222, RIG_MTYPE_CALL , {TMV7_CHANNEL_CAPS}}, /* Call V/U */
|
2004-03-21 16:58:07 +00:00
|
|
|
RIG_CHAN_END,
|
2004-03-20 10:23:43 +00:00
|
|
|
},
|
|
|
|
|
2004-11-11 17:53:38 +00:00
|
|
|
.rx_range_list1 = {
|
|
|
|
{MHz(118),MHz(174),RIG_MODE_AM | RIG_MODE_FM,-1,-1,RIG_VFO_A},
|
|
|
|
{MHz(300),MHz(470),RIG_MODE_FM,-1,-1,RIG_VFO_B},
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* rx range */
|
|
|
|
|
|
|
|
.tx_range_list1 = {
|
|
|
|
{MHz(118),MHz(174), RIG_MODE_FM,W(5),W(50),RIG_VFO_A},
|
|
|
|
{MHz(300),MHz(470),RIG_MODE_FM,W(5),W(35),RIG_VFO_B},
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* tx range */
|
|
|
|
|
|
|
|
.rx_range_list2 = {
|
|
|
|
{MHz(118),MHz(174),RIG_MODE_AM | RIG_MODE_FM,-1,-1,RIG_VFO_A},
|
|
|
|
{MHz(300),MHz(470),RIG_MODE_FM,-1,-1,RIG_VFO_B},
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* rx range */
|
|
|
|
|
|
|
|
.tx_range_list2 = {
|
|
|
|
{MHz(118),MHz(174), RIG_MODE_FM,W(5),W(50),RIG_VFO_A},
|
|
|
|
{MHz(300),MHz(470),RIG_MODE_FM,W(5),W(35),RIG_VFO_B},
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* tx range */
|
2004-03-20 10:23:43 +00:00
|
|
|
|
|
|
|
.tuning_steps = {
|
|
|
|
{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(25)},
|
|
|
|
{RIG_MODE_FM,kHz(50)},
|
|
|
|
RIG_TS_END,
|
|
|
|
},
|
|
|
|
/* mode/filter list, remember: order matters! */
|
|
|
|
.filters = {
|
|
|
|
RIG_FLT_END,
|
|
|
|
},
|
|
|
|
|
2004-11-11 17:53:38 +00:00
|
|
|
.str_cal ={ 4, { {0, -60 }, {1, -30,}, {5,0}, {7,20}}}, /* rought guess */
|
|
|
|
|
2004-03-20 10:23:43 +00:00
|
|
|
.priv = (void *)&tmv7_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,
|
2009-02-03 22:42:44 +00:00
|
|
|
.rig_open = kenwood_open,
|
2004-03-20 10:23:43 +00:00
|
|
|
.rig_close = NULL,
|
|
|
|
|
|
|
|
.set_freq = th_set_freq,
|
|
|
|
.get_freq = th_get_freq,
|
|
|
|
.get_mode = tmv7_get_mode,
|
|
|
|
.set_vfo = tmv7_set_vfo,
|
2004-03-21 16:58:07 +00:00
|
|
|
.get_vfo = th_get_vfo,
|
2004-03-20 10:23:43 +00:00
|
|
|
.set_mem = th_set_mem,
|
|
|
|
.get_mem = th_get_mem,
|
2004-12-28 11:08:00 +00:00
|
|
|
.set_channel = tmv7_set_channel,
|
|
|
|
.get_channel = tmv7_get_channel,
|
2004-03-20 10:23:43 +00:00
|
|
|
.set_trn = th_set_trn,
|
|
|
|
.get_trn = th_get_trn,
|
|
|
|
|
2004-03-21 16:58:07 +00:00
|
|
|
.set_func = th_set_func,
|
|
|
|
.get_func = th_get_func,
|
2004-03-20 10:23:43 +00:00
|
|
|
.get_level = th_get_level,
|
|
|
|
.set_level = th_set_level,
|
|
|
|
.get_info = th_get_info,
|
2004-11-11 17:53:38 +00:00
|
|
|
.get_powerstat = tmv7_get_powerstat,
|
2004-03-20 10:23:43 +00:00
|
|
|
.vfo_op = th_vfo_op,
|
|
|
|
.set_ptt = th_set_ptt,
|
|
|
|
.get_dcd=th_get_dcd,
|
|
|
|
.decode_event = tmv7_decode_event,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int tmv7_decode_event (RIG *rig)
|
|
|
|
{
|
|
|
|
char asyncbuf[ACKBUF_LEN];
|
2006-03-12 09:02:38 +00:00
|
|
|
int retval;
|
|
|
|
size_t asyncbuf_len = ACKBUF_LEN;
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
2004-03-20 10:23:43 +00:00
|
|
|
|
|
|
|
retval = kenwood_transaction(rig, NULL, 0, asyncbuf, &asyncbuf_len);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Decoding message\n", __func__);
|
2004-03-20 10:23:43 +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,
|
2004-03-20 10:23:43 +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);
|
2004-03-20 10:23:43 +00:00
|
|
|
return -RIG_ERJCTED;
|
|
|
|
}
|
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Buffer (freq %"PRIfreq" Hz, mode %d)\n", __func__, freq);
|
2004-03-20 10:23:43 +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);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
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);
|
2004-03-20 10:23:43 +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));
|
2004-03-20 10:23:43 +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);
|
2004-03-20 10:23:43 +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" );
|
2004-03-20 10:23:43 +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);
|
2004-03-20 10:23:43 +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; */
|
|
|
|
default: bandmode = RIG_VFO_CURR; break;
|
|
|
|
}
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: Mode of Band event - %d\n", __func__, bandmode);
|
2004-03-20 10:23:43 +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);
|
2004-03-20 10:23:43 +00:00
|
|
|
return -RIG_ENIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int tmv7_set_vfo (RIG *rig, vfo_t vfo)
|
|
|
|
{
|
|
|
|
char vfobuf[16], ackbuf[ACKBUF_LEN];
|
2006-03-12 09:02:38 +00:00
|
|
|
int retval;
|
|
|
|
size_t ack_len;
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called %d\n", __func__,vfo);
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2004-03-21 16:58:07 +00:00
|
|
|
switch (vfo) {
|
2004-03-20 10:23:43 +00:00
|
|
|
case RIG_VFO_A:
|
|
|
|
case RIG_VFO_VFO:
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(vfobuf, "VMC 0,0");
|
2004-03-21 16:58:07 +00:00
|
|
|
break;
|
|
|
|
case RIG_VFO_B:
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(vfobuf, "VMC 1,0");
|
2004-03-20 10:23:43 +00:00
|
|
|
break;
|
|
|
|
case RIG_VFO_MEM:
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(vfobuf, "BC");
|
2004-03-21 16:58:07 +00:00
|
|
|
ack_len=ACKBUF_LEN;
|
|
|
|
retval = kenwood_transaction(rig, vfobuf, strlen(vfobuf), ackbuf, &ack_len);
|
|
|
|
if (retval != RIG_OK) return retval;
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(vfobuf, "VMC %c,2",ackbuf[3]);
|
2004-03-20 10:23:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __func__, vfo);
|
2004-03-20 10:23:43 +00:00
|
|
|
return -RIG_EVFO;
|
2004-03-21 16:58:07 +00:00
|
|
|
}
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2006-03-14 20:06:46 +00:00
|
|
|
ack_len=0;
|
2004-03-20 10:23:43 +00:00
|
|
|
retval = kenwood_transaction(rig, vfobuf, strlen(vfobuf), ackbuf, &ack_len);
|
2004-11-11 17:53:38 +00:00
|
|
|
if (retval != RIG_OK) {
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: bad return \n", __func__);
|
2004-03-20 10:23:43 +00:00
|
|
|
return retval;
|
2004-11-11 17:53:38 +00:00
|
|
|
}
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: next %d\n", __func__,vfo);
|
2004-03-21 16:58:07 +00:00
|
|
|
switch (vfo) {
|
|
|
|
case RIG_VFO_A:
|
2004-11-11 17:53:38 +00:00
|
|
|
case RIG_VFO_VFO:
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(vfobuf, "BC 0,0");
|
2004-03-21 16:58:07 +00:00
|
|
|
break;
|
|
|
|
case RIG_VFO_B:
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(vfobuf, "BC 1,1");
|
2004-03-21 16:58:07 +00:00
|
|
|
break;
|
|
|
|
case RIG_VFO_MEM:
|
|
|
|
return RIG_OK;
|
|
|
|
default:
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: next2\n", __func__);
|
2006-03-14 20:06:46 +00:00
|
|
|
ack_len=0;
|
2004-03-21 16:58:07 +00:00
|
|
|
retval = kenwood_transaction(rig, vfobuf, strlen(vfobuf), ackbuf, &ack_len);
|
|
|
|
if (retval != RIG_OK)
|
2004-03-20 10:23:43 +00:00
|
|
|
return retval;
|
|
|
|
|
2004-03-21 16:58:07 +00:00
|
|
|
return RIG_OK;
|
2004-03-20 10:23:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
2004-03-21 16:58:07 +00:00
|
|
|
int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
2004-03-20 10:23:43 +00:00
|
|
|
{
|
|
|
|
char ackbuf[ACKBUF_LEN];
|
2006-03-12 09:02:38 +00:00
|
|
|
int retval;
|
|
|
|
size_t ack_len=ACKBUF_LEN;
|
2004-03-21 16:58:07 +00:00
|
|
|
int step;
|
|
|
|
freq_t freq;
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2004-03-21 16:58:07 +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);
|
2004-03-21 16:58:07 +00:00
|
|
|
return -RIG_EVFO;
|
2004-03-20 10:23:43 +00:00
|
|
|
}
|
|
|
|
|
2004-03-21 16:58:07 +00:00
|
|
|
/* try to guess from frequency */
|
2010-04-24 13:52:14 +00:00
|
|
|
retval = kenwood_transaction(rig, "FQ", 3, ackbuf, &ack_len);
|
2004-03-20 10:23:43 +00:00
|
|
|
if (retval != RIG_OK)
|
2004-03-21 16:58:07 +00:00
|
|
|
return retval;
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2005-01-24 23:04:35 +00:00
|
|
|
sscanf(ackbuf,"FQ %"SCNfreq",%d",&freq,&step);
|
2004-03-20 10:23:43 +00:00
|
|
|
|
2004-03-21 16:58:07 +00:00
|
|
|
if(freq <MHz(137) ) {
|
|
|
|
*mode=RIG_MODE_AM;
|
|
|
|
*width=kHz(9);
|
|
|
|
} else {
|
|
|
|
*mode=RIG_MODE_FM;
|
|
|
|
*width=kHz(12);
|
2004-03-20 10:23:43 +00:00
|
|
|
}
|
|
|
|
|
2004-03-21 16:58:07 +00:00
|
|
|
return RIG_OK;
|
2004-03-20 10:23:43 +00:00
|
|
|
}
|
|
|
|
|
2004-11-11 17:53:38 +00:00
|
|
|
int tmv7_get_powerstat (RIG *rig, powerstat_t *status)
|
|
|
|
{
|
|
|
|
/* dummy func to make sgcontrol happy */
|
|
|
|
|
|
|
|
*status=RIG_POWER_ON;
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2004-12-28 11:08:00 +00:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int tmv7_get_channel(RIG *rig, channel_t *chan)
|
|
|
|
{
|
|
|
|
char membuf[64],ackbuf[ACKBUF_LEN];
|
2006-03-12 09:02:38 +00:00
|
|
|
int retval;
|
|
|
|
size_t ack_len;
|
2004-12-28 11:08:00 +00:00
|
|
|
freq_t freq;
|
|
|
|
char req[16],scf[128];
|
|
|
|
int step, shift, rev, tone, ctcss, tonefq, ctcssfq;
|
|
|
|
|
|
|
|
if(chan->channel_num<100)
|
|
|
|
sprintf(req,"MR 0,0,%03d",chan->channel_num);
|
|
|
|
else
|
|
|
|
if(chan->channel_num<200)
|
|
|
|
sprintf(req,"MR 1,0,%03d",chan->channel_num-100);
|
|
|
|
else
|
|
|
|
if(chan->channel_num<204) {
|
|
|
|
sprintf(req,"MR 0,0,L%01d",chan->channel_num-200);
|
|
|
|
sprintf(chan->channel_desc,"L%01d/V",chan->channel_num-200);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<211) {
|
|
|
|
sprintf(req,"MR 1,0,L%01d",chan->channel_num-203);
|
|
|
|
sprintf(chan->channel_desc,"L%01d/U",chan->channel_num-203);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<214) {
|
|
|
|
sprintf(req,"MR 0,0,U%01d",chan->channel_num-210);
|
|
|
|
sprintf(chan->channel_desc,"U%01d/V",chan->channel_num-210);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<220) {
|
|
|
|
sprintf(req,"MR 1,0,U%01d",chan->channel_num-213);
|
|
|
|
sprintf(chan->channel_desc,"U%01d/U",chan->channel_num-213);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<223) {
|
|
|
|
if(chan->channel_num==221) {
|
|
|
|
sprintf(req,"CR 0,0");
|
|
|
|
sprintf(chan->channel_desc,"Call V");
|
|
|
|
}
|
|
|
|
if(chan->channel_num==222) {
|
|
|
|
sprintf(req,"CR 1,0");
|
|
|
|
sprintf(chan->channel_desc,"Call U");
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf,"%s",req);
|
2004-12-28 11:08:00 +00:00
|
|
|
ack_len=ACKBUF_LEN;
|
|
|
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
strcpy(scf,req);
|
2005-01-24 23:04:35 +00:00
|
|
|
strcat(scf,",%"SCNfreq",%d,%d,%d,%d,0,%d,%d,000,%d,,0");
|
2004-12-28 11:08:00 +00:00
|
|
|
retval = sscanf(ackbuf, scf,
|
|
|
|
&freq, &step, &shift, &rev, &tone,
|
|
|
|
&ctcss, &tonefq, &ctcssfq);
|
|
|
|
|
|
|
|
chan->freq=freq;
|
|
|
|
chan->vfo=RIG_VFO_MEM;
|
|
|
|
chan->tuning_step=rig->state.tuning_steps[step].ts;
|
|
|
|
if(freq <MHz(138) ) {
|
|
|
|
chan->mode=RIG_MODE_AM;
|
|
|
|
} else {
|
|
|
|
chan->mode=RIG_MODE_FM;
|
|
|
|
}
|
|
|
|
switch(shift) {
|
|
|
|
case 0 :
|
|
|
|
chan->rptr_shift=RIG_RPT_SHIFT_NONE;
|
|
|
|
break;
|
|
|
|
case 1 :
|
|
|
|
chan->rptr_shift=RIG_RPT_SHIFT_PLUS;
|
|
|
|
break;
|
|
|
|
case 2 :
|
|
|
|
chan->rptr_shift=RIG_RPT_SHIFT_MINUS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tone)
|
|
|
|
chan->ctcss_tone=rig->caps->ctcss_list[tonefq==1?0:tonefq-2];
|
|
|
|
else
|
|
|
|
chan->ctcss_tone=0;
|
|
|
|
if(ctcss)
|
|
|
|
chan->ctcss_sql=rig->caps->ctcss_list[ctcssfq==1?0:ctcssfq-2];
|
|
|
|
else
|
|
|
|
chan->ctcss_sql=0;
|
|
|
|
|
|
|
|
chan->tx_freq=RIG_FREQ_NONE;
|
|
|
|
if(chan->channel_num<223 && shift==0) {
|
|
|
|
req[5]='1';
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf,"%s",req);
|
2004-12-28 11:08:00 +00:00
|
|
|
ack_len=ACKBUF_LEN;
|
|
|
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
|
|
if (retval == RIG_OK) {
|
|
|
|
strcpy(scf,req);
|
2005-01-24 23:04:35 +00:00
|
|
|
strcat(scf,",%"SCNfreq",%d");
|
2004-12-28 11:08:00 +00:00
|
|
|
retval = sscanf(ackbuf, scf, &freq, &step);
|
|
|
|
chan->tx_freq=freq;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(chan->channel_num<200) {
|
|
|
|
if(chan->channel_num<100)
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf,"MNA 0,%03d",chan->channel_num);
|
2004-12-28 11:08:00 +00:00
|
|
|
else
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf,"MNA 1,%03d",chan->channel_num-100);
|
2004-12-28 11:08:00 +00:00
|
|
|
ack_len=ACKBUF_LEN;
|
|
|
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
memcpy(chan->channel_desc,&ackbuf[10],7);
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int tmv7_set_channel(RIG *rig, const channel_t *chan)
|
|
|
|
{
|
|
|
|
char membuf[ACKBUF_LEN],ackbuf[ACKBUF_LEN];
|
2006-03-12 09:02:38 +00:00
|
|
|
int retval;
|
|
|
|
size_t ack_len;
|
2004-12-28 11:08:00 +00:00
|
|
|
char req[64];
|
2006-04-13 19:43:49 +00:00
|
|
|
long freq;
|
2004-12-28 11:08:00 +00:00
|
|
|
int chn, step, shift, tone, ctcss, tonefq, ctcssfq;
|
|
|
|
|
|
|
|
chn=chan->channel_num;
|
2010-04-26 21:35:37 +00:00
|
|
|
freq=(long)chan->freq;
|
2004-12-28 11:08:00 +00:00
|
|
|
|
|
|
|
for(step=0; rig->state.tuning_steps[step].ts!=0;step++)
|
|
|
|
if(chan->tuning_step==rig->state.tuning_steps[step].ts) break;
|
|
|
|
|
|
|
|
switch(chan->rptr_shift) {
|
|
|
|
case RIG_RPT_SHIFT_NONE :
|
|
|
|
shift=0;
|
|
|
|
break;
|
|
|
|
case RIG_RPT_SHIFT_PLUS:
|
|
|
|
shift=1;
|
|
|
|
break;
|
|
|
|
case RIG_RPT_SHIFT_MINUS:
|
|
|
|
shift=2;
|
|
|
|
break;
|
|
|
|
default:
|
2009-02-03 23:22:58 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: not supported shift\n", __func__);
|
2004-12-28 11:08:00 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(chan->ctcss_tone==0) {
|
|
|
|
tone=0;tonefq=9;
|
|
|
|
} else {
|
|
|
|
tone=1;
|
|
|
|
for (tonefq = 0; rig->caps->ctcss_list[tonefq] != 0 && tonefq < RIG_TONEMAX; tonefq++) {
|
|
|
|
if (rig->caps->ctcss_list[tonefq] == chan->ctcss_tone)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tonefq=tonefq==0?1:tonefq+2;
|
|
|
|
}
|
|
|
|
if(chan->ctcss_sql==0) {
|
|
|
|
ctcss=0;ctcssfq=9;
|
|
|
|
} else {
|
|
|
|
ctcss=1;
|
|
|
|
for (ctcssfq = 0; rig->caps->ctcss_list[ctcssfq] != 0 && ctcssfq < RIG_TONEMAX; ctcssfq++) {
|
|
|
|
if (rig->caps->ctcss_list[ctcssfq] == chan->ctcss_sql)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ctcssfq=ctcssfq==0?1:ctcssfq+2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(chan->channel_num<100)
|
|
|
|
sprintf(req,"MW 0,0,%03d",chan->channel_num);
|
|
|
|
else
|
|
|
|
if(chan->channel_num<200)
|
|
|
|
sprintf(req,"MW 1,0,%03d",chan->channel_num-100);
|
|
|
|
else
|
|
|
|
if(chan->channel_num<204) {
|
|
|
|
sprintf(req,"MW 0,0,L%01d",chan->channel_num-200);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<211) {
|
|
|
|
sprintf(req,"MW 1,0,L%01d",chan->channel_num-203);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<214) {
|
|
|
|
sprintf(req,"MW 0,0,U%01d",chan->channel_num-210);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<220) {
|
|
|
|
sprintf(req,"MW 1,0,U%01d",chan->channel_num-213);
|
|
|
|
} else
|
|
|
|
if(chan->channel_num<223) {
|
|
|
|
if(chan->channel_num==221) {
|
|
|
|
sprintf(req,"CW 0,0");
|
|
|
|
}
|
|
|
|
if(chan->channel_num==222) {
|
|
|
|
sprintf(req,"CW 1,0");
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
|
|
|
|
if(chan->channel_num<221)
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf, "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,0,0",
|
2006-04-13 19:43:49 +00:00
|
|
|
req,(long)freq, step, shift, tone,
|
2004-12-28 11:08:00 +00:00
|
|
|
ctcss, tonefq, ctcssfq);
|
|
|
|
else
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf, "%s,%011ld,%01d,%01d,0,%01d,%01d,0,%02d,000,%02d,",
|
2006-04-13 19:43:49 +00:00
|
|
|
req, (long)freq, step, shift, tone,
|
2004-12-28 11:08:00 +00:00
|
|
|
ctcss, tonefq, ctcssfq);
|
|
|
|
|
2006-03-14 20:06:46 +00:00
|
|
|
ack_len=0;
|
2004-12-28 11:08:00 +00:00
|
|
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
if(chan->tx_freq!=RIG_FREQ_NONE) {
|
2010-04-26 21:35:37 +00:00
|
|
|
req[5]='1';
|
|
|
|
sprintf(membuf, "%s,%011"PRIll",%01d", req, (int64_t)chan->tx_freq, step);
|
2006-03-14 20:06:46 +00:00
|
|
|
ack_len=0;
|
2004-12-28 11:08:00 +00:00
|
|
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(chan->channel_num<200) {
|
|
|
|
if(chan->channel_num<100)
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf,"MNA 0,%03d,%s",chan->channel_num,chan->channel_desc);
|
2004-12-28 11:08:00 +00:00
|
|
|
else
|
2010-04-24 13:52:14 +00:00
|
|
|
sprintf(membuf,"MNA 1,%03d,%s",chan->channel_num-100,chan->channel_desc);
|
2006-03-14 20:06:46 +00:00
|
|
|
ack_len=0;
|
2004-12-28 11:08:00 +00:00
|
|
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|