2004-08-10 21:10:36 +00:00
|
|
|
/*
|
2010-03-05 19:15:30 +00:00
|
|
|
* ft736.c - (C) Stephane Fillod 2004-2010
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
|
|
|
* This shared library provides an API for communicating
|
|
|
|
* via serial interface to an FT-736R using the "CAT" interface
|
|
|
|
*
|
|
|
|
*
|
2011-08-23 02:26:44 +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.
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
2011-08-23 02:26:44 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2004-08-10 21:10:36 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-08-23 02:26:44 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
2011-08-23 02:26:44 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2004-08-10 21:10:36 +00:00
|
|
|
* License along with this library; if not, write to the Free Software
|
2011-08-23 02:26:44 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2004-08-10 21:10:36 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
|
|
|
|
#include "hamlib/rig.h"
|
|
|
|
#include "serial.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "yaesu.h"
|
2010-03-05 19:15:30 +00:00
|
|
|
#include "tones.h"
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define FT736_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_FM)
|
|
|
|
|
2010-05-27 19:22:16 +00:00
|
|
|
#define FT736_VFOS (RIG_VFO_A)
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2010-05-28 10:23:25 +00:00
|
|
|
/* Measurement by Ron W6FM using a signal generator.
|
|
|
|
* Raw values supposed to be between 0x30 and 0xad according to manual.
|
|
|
|
*/
|
|
|
|
#define FT736_STR_CAL { 3, { \
|
2019-11-30 16:19:08 +00:00
|
|
|
{ 0x1d, -54 }, /* S0 */ \
|
|
|
|
{ 0x54, 0 }, /* S9 */ \
|
|
|
|
{ 0x9d, 60 } /* +60 */ \
|
|
|
|
} }
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft736_priv_data
|
|
|
|
{
|
2010-05-27 19:22:16 +00:00
|
|
|
split_t split;
|
|
|
|
};
|
|
|
|
|
2004-08-10 21:10:36 +00:00
|
|
|
/* Private helper function prototypes */
|
|
|
|
|
|
|
|
static int ft736_open(RIG *rig);
|
|
|
|
static int ft736_close(RIG *rig);
|
|
|
|
|
|
|
|
static int ft736_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
|
|
|
static int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
2019-11-30 16:19:08 +00:00
|
|
|
static int ft736_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
|
|
|
|
vfo_t tx_vfo);
|
2004-08-10 21:10:36 +00:00
|
|
|
static int ft736_set_split_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
2019-11-30 16:19:08 +00:00
|
|
|
static int ft736_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
|
|
|
|
pbwidth_t width);
|
2004-08-10 21:10:36 +00:00
|
|
|
static int ft736_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
|
|
|
static int ft736_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd);
|
|
|
|
static int ft736_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
|
|
|
static int ft736_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift);
|
|
|
|
static int ft736_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs);
|
2010-03-05 19:15:30 +00:00
|
|
|
static int ft736_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
2019-11-30 16:19:08 +00:00
|
|
|
static int ft736_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone);
|
|
|
|
static int ft736_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone);
|
2010-03-05 19:15:30 +00:00
|
|
|
|
2010-05-28 10:23:25 +00:00
|
|
|
/* Some tones are present twice, the second value is
|
|
|
|
* higher Q (80), according to manual.
|
|
|
|
*/
|
2019-11-30 16:19:08 +00:00
|
|
|
static const tone_t ft736_ctcss_list[] =
|
|
|
|
{
|
|
|
|
670, 719, 770, 825, 885, 948, 1000, 1035, 1072, 1109,
|
|
|
|
1148, 1188, 1230, 1273, 1318, 1365, 1413, 1462, 1514, 1567,
|
|
|
|
1622, 1679, 1738, 1799, 1862, 1928, 2035, 2107, 2181, 2257,
|
|
|
|
2336, 2418, 2503, 670, 719, 744, 770, 797, 825, 854,
|
|
|
|
885, 915, 0
|
2010-03-05 19:15:30 +00:00
|
|
|
};
|
2010-05-28 10:23:25 +00:00
|
|
|
#define FT736_CTCSS_NB 42
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ft736 rigs capabilities.
|
|
|
|
*
|
|
|
|
* TODO:
|
2019-11-30 16:19:08 +00:00
|
|
|
* - AQS
|
2004-08-10 21:10:36 +00:00
|
|
|
*/
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
const struct rig_caps ft736_caps =
|
|
|
|
{
|
|
|
|
.rig_model = RIG_MODEL_FT736R,
|
|
|
|
.model_name = "FT-736R",
|
|
|
|
.mfg_name = "Yaesu",
|
|
|
|
.version = "0.3",
|
|
|
|
.copyright = "LGPL",
|
|
|
|
.status = RIG_STATUS_STABLE,
|
|
|
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
|
|
|
.ptt_type = RIG_PTT_RIG,
|
|
|
|
.dcd_type = RIG_DCD_RIG,
|
|
|
|
.port_type = RIG_PORT_SERIAL,
|
|
|
|
.serial_rate_min = 4800,
|
|
|
|
.serial_rate_max = 4800,
|
|
|
|
.serial_data_bits = 8,
|
|
|
|
.serial_stop_bits = 2,
|
|
|
|
.serial_parity = RIG_PARITY_NONE,
|
|
|
|
.serial_handshake = RIG_HANDSHAKE_NONE, /* RTS low, DTR high, and CTS low. */
|
|
|
|
.write_delay = 30, /* 50ms to be real safe */
|
|
|
|
.post_write_delay = 0,
|
|
|
|
.timeout = 2000,
|
|
|
|
.retry = 0,
|
|
|
|
.has_get_func = RIG_FUNC_NONE,
|
|
|
|
.has_set_func = RIG_FUNC_TONE | RIG_FUNC_TSQL,
|
|
|
|
.has_get_level = RIG_LEVEL_RAWSTR,
|
|
|
|
.has_set_level = RIG_LEVEL_NONE,
|
|
|
|
.has_get_parm = RIG_PARM_NONE,
|
|
|
|
.has_set_parm = RIG_PARM_NONE,
|
|
|
|
.vfo_ops = RIG_OP_NONE,
|
|
|
|
.ctcss_list = ft736_ctcss_list,
|
|
|
|
.preamp = { RIG_DBLST_END, },
|
|
|
|
.attenuator = { RIG_DBLST_END, },
|
|
|
|
.max_rit = Hz(0),
|
|
|
|
.max_xit = Hz(0),
|
|
|
|
.max_ifshift = Hz(0),
|
|
|
|
.targetable_vfo = RIG_TARGETABLE_FREQ,
|
|
|
|
.transceive = RIG_TRN_OFF,
|
|
|
|
.bank_qty = 0,
|
|
|
|
.chan_desc_sz = 0,
|
|
|
|
.chan_list = {
|
|
|
|
RIG_CHAN_END,
|
|
|
|
},
|
|
|
|
.rx_range_list1 = {
|
|
|
|
{MHz(50), MHz(53.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
{MHz(144), MHz(145.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
{MHz(430), MHz(439.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
{MHz(1240), MHz(1299.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* Region 1 rx ranges */
|
|
|
|
|
|
|
|
.tx_range_list1 = {
|
|
|
|
{MHz(50), MHz(53.99999), FT736_MODES, W(5), W(30), FT736_VFOS },
|
|
|
|
{MHz(144), MHz(145.99999), FT736_MODES, W(5), W(60), FT736_VFOS },
|
|
|
|
{MHz(430), MHz(439.99999), FT736_MODES, W(5), W(60), FT736_VFOS },
|
|
|
|
{MHz(1240), MHz(1299.99999), FT736_MODES, W(5), W(45), FT736_VFOS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* region 1 TX ranges */
|
|
|
|
|
|
|
|
.rx_range_list2 = {
|
|
|
|
{MHz(50), MHz(53.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
{MHz(144), MHz(147.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
{MHz(220), MHz(224.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
{MHz(430), MHz(449.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
{MHz(1240), MHz(1299.99999), FT736_MODES, -1, -1, FT736_VFOS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* Region 2 rx ranges */
|
|
|
|
|
|
|
|
.tx_range_list2 = {
|
|
|
|
{MHz(50), MHz(53.99999), FT736_MODES, W(5), W(30), FT736_VFOS },
|
|
|
|
{MHz(144), MHz(147.99999), FT736_MODES, W(5), W(60), FT736_VFOS },
|
|
|
|
{MHz(220), MHz(224.99999), FT736_MODES, W(5), W(60), FT736_VFOS },
|
|
|
|
{MHz(430), MHz(449.99999), FT736_MODES, W(5), W(60), FT736_VFOS },
|
|
|
|
{MHz(1240), MHz(1299.99999), FT736_MODES, W(5), W(45), FT736_VFOS },
|
|
|
|
RIG_FRNG_END,
|
|
|
|
}, /* region 2 TX ranges */
|
|
|
|
|
|
|
|
|
|
|
|
.tuning_steps = {
|
|
|
|
{FT736_MODES, Hz(10)},
|
|
|
|
RIG_TS_END,
|
|
|
|
},
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
/* mode/filter list, remember: order matters! */
|
2019-11-30 16:19:08 +00:00
|
|
|
.filters = {
|
|
|
|
{RIG_MODE_SSB | RIG_MODE_CW | RIG_MODE_CWR, kHz(2.2)},
|
|
|
|
{RIG_MODE_CW | RIG_MODE_CWR, Hz(600)},
|
|
|
|
{RIG_MODE_FM, kHz(12)},
|
|
|
|
{RIG_MODE_FM, kHz(8)},
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
RIG_FLT_END,
|
|
|
|
},
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
.str_cal = FT736_STR_CAL,
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
.rig_open = ft736_open,
|
|
|
|
.rig_close = ft736_close,
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_freq = ft736_set_freq,
|
|
|
|
.set_mode = ft736_set_mode,
|
|
|
|
.set_ptt = ft736_set_ptt,
|
|
|
|
.get_dcd = ft736_get_dcd,
|
|
|
|
.get_level = ft736_get_level,
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_split_vfo = ft736_set_split_vfo,
|
|
|
|
.set_split_freq = ft736_set_split_freq,
|
|
|
|
.set_split_mode = ft736_set_split_mode,
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_rptr_shift = ft736_set_rptr_shift,
|
|
|
|
.set_rptr_offs = ft736_set_rptr_offs,
|
2010-03-05 19:15:30 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_func = ft736_set_func,
|
|
|
|
.set_ctcss_tone = ft736_set_ctcss_tone,
|
|
|
|
.set_ctcss_sql = ft736_set_ctcss_sql,
|
2004-08-10 21:10:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ft736_open routine
|
2011-08-23 02:26:44 +00:00
|
|
|
*
|
2004-08-10 21:10:36 +00:00
|
|
|
*/
|
|
|
|
int ft736_open(RIG *rig)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
struct ft736_priv_data *priv;
|
|
|
|
int ret;
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
rig->state.priv = (struct ft736_priv_data *) calloc(1,
|
|
|
|
sizeof(struct ft736_priv_data));
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2020-01-13 18:48:30 +00:00
|
|
|
if (!rig->state.priv)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
return -RIG_ENOMEM;
|
|
|
|
}
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2020-01-13 18:48:30 +00:00
|
|
|
priv = rig->state.priv;
|
2010-05-27 19:22:16 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
priv->split = RIG_SPLIT_OFF;
|
2010-05-27 19:22:16 +00:00
|
|
|
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* send Ext Cntl ON: Activate CAT */
|
|
|
|
ret = write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (ret != RIG_OK)
|
|
|
|
{
|
|
|
|
free(priv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ft736_close(RIG *rig)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x80, 0x80, 0x80, 0x80, 0x80};
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
free(rig->state.priv);
|
2010-05-27 19:22:16 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* send Ext Cntl OFF: Deactivate CAT */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ft736_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x01};
|
|
|
|
struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv;
|
2010-05-27 19:22:16 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (priv->split == RIG_SPLIT_ON)
|
|
|
|
{
|
|
|
|
cmd[4] = 0x1e;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* store bcd format in cmd (MSB) */
|
|
|
|
to_bcd_be(cmd, freq / 10, 8);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* special case for 1.2GHz band */
|
|
|
|
if (freq > GHz(1.2))
|
|
|
|
{
|
|
|
|
cmd[0] = (cmd[0] & 0x0f) | 0xc0;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* Frequency set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MD_LSB 0x00
|
|
|
|
#define MD_USB 0x01
|
|
|
|
#define MD_CW 0x02
|
|
|
|
#define MD_CWR 0x03
|
|
|
|
#define MD_AM 0x04
|
|
|
|
#define MD_FM 0x08
|
|
|
|
|
|
|
|
int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x07};
|
|
|
|
unsigned char md;
|
|
|
|
struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv;
|
|
|
|
|
|
|
|
if (priv->split == RIG_SPLIT_ON)
|
|
|
|
{
|
|
|
|
cmd[4] = 0x17;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* translate mode from generic to ft736 specific
|
|
|
|
*/
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case RIG_MODE_CW: md = MD_CW; break;
|
|
|
|
|
|
|
|
case RIG_MODE_CWR: md = MD_CWR; break;
|
|
|
|
|
|
|
|
case RIG_MODE_USB: md = MD_USB; break;
|
|
|
|
|
|
|
|
case RIG_MODE_LSB: md = MD_LSB; break;
|
|
|
|
|
|
|
|
case RIG_MODE_FM: md = MD_FM; break;
|
|
|
|
|
|
|
|
case RIG_MODE_AM: md = MD_AM; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL; /* sorry, wrong MODE */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (width != RIG_PASSBAND_NOCHANGE
|
|
|
|
&& width != RIG_PASSBAND_NORMAL
|
|
|
|
&& width < rig_passband_normal(rig, mode))
|
|
|
|
{
|
|
|
|
md |= 0x80;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd[0] = md;
|
|
|
|
|
|
|
|
/* Mode set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ft736_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x8e};
|
|
|
|
struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* this can be misleading as Yaesu call it "Full duplex"
|
|
|
|
* or "sat mode", and split Yaesu terms is repeater shift.
|
|
|
|
*/
|
|
|
|
cmd[4] = split == RIG_SPLIT_ON ? 0x0e : 0x8e;
|
|
|
|
|
|
|
|
ret = write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
|
|
|
|
|
|
|
if (ret == RIG_OK)
|
|
|
|
{
|
|
|
|
priv->split = split;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ft736_set_split_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x2e};
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* store bcd format in cmd (MSB) */
|
|
|
|
to_bcd_be(cmd, freq / 10, 8);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* special case for 1.2GHz band */
|
|
|
|
if (freq > GHz(1.2))
|
|
|
|
{
|
|
|
|
cmd[0] = (cmd[0] & 0x0f) | 0xc0;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* Frequency set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ft736_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x27};
|
|
|
|
unsigned char md;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* translate mode from generic to ft736 specific
|
|
|
|
*/
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case RIG_MODE_CW: md = MD_CW; break;
|
|
|
|
|
|
|
|
case RIG_MODE_CWR: md = MD_CWR; break;
|
|
|
|
|
|
|
|
case RIG_MODE_USB: md = MD_USB; break;
|
|
|
|
|
|
|
|
case RIG_MODE_LSB: md = MD_LSB; break;
|
|
|
|
|
|
|
|
case RIG_MODE_FM: md = MD_FM; break;
|
|
|
|
|
|
|
|
case RIG_MODE_AM: md = MD_AM; break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL; /* sorry, wrong MODE */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RIG_PASSBAND_NOCHANGE != width
|
|
|
|
&& width != RIG_PASSBAND_NORMAL
|
|
|
|
&& width < rig_passband_normal(rig, mode))
|
|
|
|
{
|
|
|
|
md |= 0x80;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd[0] = md;
|
|
|
|
|
|
|
|
/* Mode set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ft736_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x88};
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
cmd[4] = ptt == RIG_PTT_ON ? 0x08 : 0x88;
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* Tx/Rx set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ft736_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0xe7};
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
serial_flush(&rig->state.rigport);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
retval = write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retval < 0)
|
|
|
|
{
|
|
|
|
return retval;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* read back the 1 byte */
|
|
|
|
retval = read_block(&rig->state.rigport, (char *) cmd, 5);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retval < 1)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: read squelch failed %d\n",
|
|
|
|
__func__, retval);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return retval < 0 ? retval : -RIG_EIO;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
*dcd = cmd[0] == 0x00 ? RIG_DCD_OFF : RIG_DCD_ON;
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ft736_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0xf7};
|
|
|
|
int retval;
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (level != RIG_LEVEL_RAWSTR)
|
|
|
|
{
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
serial_flush(&rig->state.rigport);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* send Test S-meter cmd to rig */
|
|
|
|
retval = write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retval < 0)
|
|
|
|
{
|
|
|
|
return retval;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* read back the 1 byte */
|
|
|
|
retval = read_block(&rig->state.rigport, (char *) cmd, 5);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retval < 1)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: read meter failed %d\n",
|
|
|
|
__func__, retval);
|
|
|
|
|
|
|
|
return retval < 0 ? retval : -RIG_EIO;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
val->i = cmd[0];
|
|
|
|
|
|
|
|
return RIG_OK;
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ft736_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x89};
|
|
|
|
|
|
|
|
switch (shift)
|
|
|
|
{
|
|
|
|
case RIG_RPT_SHIFT_NONE:
|
|
|
|
/* There's a typo in the manual.
|
|
|
|
* "Split Dir. simplex" is in fact 0x89, and 0x88 is PTT off!
|
|
|
|
*/
|
|
|
|
cmd[4] = 0x89;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_RPT_SHIFT_MINUS:
|
|
|
|
cmd[4] = 0x09;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_RPT_SHIFT_PLUS:
|
|
|
|
cmd[4] = 0x49;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ft736_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0xf9};
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* store bcd format in cmd (MSB) */
|
|
|
|
to_bcd_be(cmd, offs / 10, 8);
|
2004-08-10 21:10:36 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* Offset set */
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
2004-08-10 21:10:36 +00:00
|
|
|
}
|
|
|
|
|
2010-03-05 19:15:30 +00:00
|
|
|
int ft736_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
|
|
|
{
|
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x8a};
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (func)
|
|
|
|
{
|
|
|
|
case RIG_FUNC_TONE:
|
|
|
|
cmd[4] = status ? 0x4a : 0x8a;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RIG_FUNC_TSQL:
|
|
|
|
cmd[4] = status ? 0x0a : 0x8a;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
2010-03-05 19:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
int ft736_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
|
2010-03-05 19:15:30 +00:00
|
|
|
{
|
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0xfa};
|
|
|
|
int i;
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
for (i = 0; i < FT736_CTCSS_NB; i++)
|
|
|
|
{
|
2010-03-05 19:15:30 +00:00
|
|
|
if (ft736_ctcss_list[i] == tone)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
2010-03-05 19:15:30 +00:00
|
|
|
break;
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
2010-03-05 19:15:30 +00:00
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2010-03-05 19:15:30 +00:00
|
|
|
if (i == FT736_CTCSS_NB)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
2010-03-05 19:15:30 +00:00
|
|
|
return -RIG_EINVAL;
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
2010-03-05 19:15:30 +00:00
|
|
|
|
|
|
|
cmd[0] = 0x3e - i;
|
|
|
|
|
|
|
|
return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH);
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
int ft736_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
|
2010-03-05 19:15:30 +00:00
|
|
|
{
|
|
|
|
/* same opcode as tone */
|
|
|
|
return ft736_set_ctcss_tone(rig, vfo, tone);
|
|
|
|
}
|
|
|
|
|