2001-12-15 03:19:39 +00:00
|
|
|
/*
|
|
|
|
* hamlib - (C) Frank Singleton 2000,2001 (vk3fcs@ix.netcom.com)
|
2009-06-01 16:51:41 +00:00
|
|
|
* (C) Stephane Fillod 2000-2009
|
2001-12-15 03:19:39 +00:00
|
|
|
*
|
|
|
|
* ft817.c - (C) Chris Karpinsky 2001 (aa1vl@arrl.net)
|
|
|
|
* This shared library provides an API for communicating
|
|
|
|
* via serial interface to an FT-817 using the "CAT" interface.
|
|
|
|
* The starting point for this code was Frank's ft847 implementation.
|
|
|
|
*
|
2005-09-04 10:44:23 +00:00
|
|
|
* Then, Tommi OH2BNS improved the code a lot in the framework of the
|
|
|
|
* FT-857 backend. These improvements have now (August 2005) been
|
|
|
|
* copied back and adopted for the FT-817.
|
2001-12-15 03:19:39 +00:00
|
|
|
*
|
2005-09-04 10:44:23 +00:00
|
|
|
*
|
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.
|
2001-12-15 03:19:39 +00:00
|
|
|
*
|
2011-08-23 02:26:44 +00:00
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
2001-12-15 03:19:39 +00:00
|
|
|
*
|
2011-08-23 02:26:44 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-12-01 03:08:05 +00:00
|
|
|
*
|
2001-12-15 03:19:39 +00:00
|
|
|
*/
|
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
/*
|
|
|
|
* Unimplemented features supported by the FT-817:
|
|
|
|
*
|
|
|
|
* - RIT ON/OFF without touching the RIT offset. This would
|
|
|
|
* need frontend support (eg. a new RIG_FUNC_xxx)
|
|
|
|
*
|
|
|
|
* - RX status command returns info that is not used:
|
|
|
|
* - discriminator centered (yes/no flag)
|
|
|
|
* - received ctcss/dcs matched (yes/no flag) TBC
|
|
|
|
*
|
|
|
|
* - TX status command returns info that is not used:
|
|
|
|
* - high swr flag
|
|
|
|
*
|
|
|
|
* Todo / tocheck list (oz9aec):
|
|
|
|
* - test get_dcd; rigctl does not support it?
|
|
|
|
* - squelch
|
|
|
|
* - the many "fixme" stuff around
|
|
|
|
*/
|
|
|
|
|
2003-04-07 22:42:11 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-12-15 03:19:39 +00:00
|
|
|
#include <stdlib.h>
|
2019-11-30 16:19:08 +00:00
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
2021-09-04 20:56:06 +00:00
|
|
|
#include <stdbool.h>
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
|
2003-04-07 22:42:11 +00:00
|
|
|
#include "hamlib/rig.h"
|
2001-12-15 03:19:39 +00:00
|
|
|
#include "serial.h"
|
|
|
|
#include "yaesu.h"
|
|
|
|
#include "ft817.h"
|
|
|
|
#include "misc.h"
|
2005-09-04 10:44:23 +00:00
|
|
|
#include "tones.h"
|
|
|
|
#include "bandplan.h"
|
2020-10-09 21:21:15 +00:00
|
|
|
#include "cal.h"
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
enum ft817_native_cmd_e
|
|
|
|
{
|
|
|
|
FT817_NATIVE_CAT_LOCK_ON = 0,
|
|
|
|
FT817_NATIVE_CAT_LOCK_OFF,
|
|
|
|
FT817_NATIVE_CAT_PTT_ON,
|
|
|
|
FT817_NATIVE_CAT_PTT_OFF,
|
|
|
|
FT817_NATIVE_CAT_SET_FREQ,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_LSB,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_USB,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_CW,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_CWR,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_AM,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_FM,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_FM_N,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_DIG,
|
|
|
|
FT817_NATIVE_CAT_SET_MODE_PKT,
|
|
|
|
FT817_NATIVE_CAT_CLAR_ON,
|
|
|
|
FT817_NATIVE_CAT_CLAR_OFF,
|
|
|
|
FT817_NATIVE_CAT_SET_CLAR_FREQ,
|
|
|
|
FT817_NATIVE_CAT_SET_VFOAB,
|
|
|
|
FT817_NATIVE_CAT_SPLIT_ON,
|
|
|
|
FT817_NATIVE_CAT_SPLIT_OFF,
|
|
|
|
FT817_NATIVE_CAT_SET_RPT_SHIFT_MINUS,
|
|
|
|
FT817_NATIVE_CAT_SET_RPT_SHIFT_PLUS,
|
|
|
|
FT817_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX,
|
|
|
|
FT817_NATIVE_CAT_SET_RPT_OFFSET,
|
|
|
|
FT817_NATIVE_CAT_SET_DCS_ON,
|
|
|
|
FT817_NATIVE_CAT_SET_CTCSS_ON,
|
|
|
|
FT817_NATIVE_CAT_SET_CTCSS_ENC_ON,
|
|
|
|
FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF,
|
|
|
|
FT817_NATIVE_CAT_SET_CTCSS_FREQ,
|
|
|
|
FT817_NATIVE_CAT_SET_DCS_CODE,
|
|
|
|
FT817_NATIVE_CAT_GET_RX_STATUS,
|
|
|
|
FT817_NATIVE_CAT_GET_TX_STATUS,
|
|
|
|
FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS,
|
|
|
|
FT817_NATIVE_CAT_PWR_WAKE,
|
|
|
|
FT817_NATIVE_CAT_PWR_ON,
|
|
|
|
FT817_NATIVE_CAT_PWR_OFF,
|
|
|
|
FT817_NATIVE_CAT_EEPROM_READ,
|
2021-08-22 18:58:29 +00:00
|
|
|
FT817_NATIVE_CAT_GET_TX_METERING,
|
2021-08-22 18:53:24 +00:00
|
|
|
FT817_NATIVE_SIZE /* end marker */
|
|
|
|
};
|
|
|
|
|
2021-08-17 18:23:03 +00:00
|
|
|
struct ft817_priv_data
|
|
|
|
{
|
|
|
|
/* rx status */
|
|
|
|
struct timeval rx_status_tv;
|
|
|
|
unsigned char rx_status;
|
|
|
|
|
|
|
|
/* tx status */
|
|
|
|
struct timeval tx_status_tv;
|
2021-08-22 21:16:41 +00:00
|
|
|
unsigned char tx_status; /* Raw data from rig. Highest bit 0 = PTT */
|
|
|
|
|
|
|
|
/* tx levels */
|
|
|
|
struct timeval tx_level_tv;
|
|
|
|
unsigned char swr_level;
|
|
|
|
unsigned char alc_level;
|
|
|
|
unsigned char mod_level;
|
|
|
|
unsigned char pwr_level; /* TX power level */
|
2021-08-17 18:23:03 +00:00
|
|
|
|
|
|
|
/* freq & mode status */
|
|
|
|
struct timeval fm_status_tv;
|
2021-08-22 19:11:44 +00:00
|
|
|
unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */
|
2021-08-22 18:53:24 +00:00
|
|
|
/* Digi mode is not part of regular fm_status reponse.
|
|
|
|
* So keep track of it in a separate variable. */
|
|
|
|
unsigned char dig_mode;
|
2021-08-17 18:23:03 +00:00
|
|
|
};
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_init(RIG *rig);
|
|
|
|
static int ft817_open(RIG *rig);
|
|
|
|
static int ft817_cleanup(RIG *rig);
|
|
|
|
static int ft817_close(RIG *rig);
|
2021-08-17 19:48:25 +00:00
|
|
|
static int ft817_get_vfo(RIG *rig, vfo_t *vfo);
|
|
|
|
static int ft817_set_vfo(RIG *rig, vfo_t vfo);
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
|
|
|
static int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
|
|
|
|
static int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
|
|
|
static int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
|
|
|
static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
|
|
|
static int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
|
|
|
|
static int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
|
|
|
static int ft817_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
|
|
|
static int ft817_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code);
|
|
|
|
static int ft817_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone);
|
|
|
|
static int ft817_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code);
|
|
|
|
static int ft817_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone);
|
|
|
|
static int ft817_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift);
|
|
|
|
static int ft817_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs);
|
|
|
|
static int ft817_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit);
|
|
|
|
static int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd);
|
|
|
|
static int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
|
|
|
static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
|
|
|
|
vfo_t *tx_vfo);
|
|
|
|
static int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
|
|
|
|
vfo_t tx_vfo);
|
|
|
|
static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power,
|
|
|
|
freq_t freq, rmode_t mode);
|
|
|
|
static int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower,
|
|
|
|
freq_t freq, rmode_t mode);
|
2021-08-24 21:23:48 +00:00
|
|
|
static int ft817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
2021-11-28 18:41:10 +00:00
|
|
|
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx);
|
2021-09-04 20:56:06 +00:00
|
|
|
static int ft818_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
2021-11-28 18:41:10 +00:00
|
|
|
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx);
|
2021-08-17 19:48:25 +00:00
|
|
|
|
2001-12-15 03:19:39 +00:00
|
|
|
/* Native ft817 cmd set prototypes. These are READ ONLY as each */
|
|
|
|
/* rig instance will copy from these and modify if required . */
|
|
|
|
/* Complete sequences (1) can be read and used directly as a cmd sequence . */
|
|
|
|
/* Incomplete sequences (0) must be completed with extra parameters */
|
|
|
|
/* eg: mem number, or freq etc.. */
|
2019-11-30 16:19:08 +00:00
|
|
|
static const yaesu_cmd_set_t ncmd[] =
|
|
|
|
{
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* lock on */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x80 } }, /* lock off */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x08 } }, /* ptt on */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x88 } }, /* ptt off */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* set freq */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main LSB */
|
|
|
|
{ 1, { 0x01, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main USB */
|
|
|
|
{ 1, { 0x02, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main CW */
|
|
|
|
{ 1, { 0x03, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main CWR */
|
|
|
|
{ 1, { 0x04, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main AM */
|
|
|
|
{ 1, { 0x08, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main FM */
|
|
|
|
{ 1, { 0x88, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main FM-N */
|
|
|
|
{ 1, { 0x0a, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main DIG */
|
|
|
|
{ 1, { 0x0c, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main PKT */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x05 } }, /* clar on */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x85 } }, /* clar off */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0xf5 } }, /* set clar freq */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x81 } }, /* toggle vfo a/b */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x02 } }, /* split on */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x82 } }, /* split off */
|
|
|
|
{ 1, { 0x09, 0x00, 0x00, 0x00, 0x09 } }, /* set RPT shift MINUS */
|
|
|
|
{ 1, { 0x49, 0x00, 0x00, 0x00, 0x09 } }, /* set RPT shift PLUS */
|
|
|
|
{ 1, { 0x89, 0x00, 0x00, 0x00, 0x09 } }, /* set RPT shift SIMPLEX */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0xf9 } }, /* set RPT offset freq */
|
|
|
|
{ 1, { 0x0a, 0x00, 0x00, 0x00, 0x0a } }, /* set DCS on */
|
|
|
|
{ 1, { 0x2a, 0x00, 0x00, 0x00, 0x0a } }, /* set CTCSS on */
|
|
|
|
{ 1, { 0x4a, 0x00, 0x00, 0x00, 0x0a } }, /* set CTCSS encoder on */
|
|
|
|
{ 1, { 0x8a, 0x00, 0x00, 0x00, 0x0a } }, /* set CTCSS/DCS off */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0b } }, /* set CTCSS tone */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x0c } }, /* set DCS code */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0xe7 } }, /* get RX status */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0xf7 } }, /* get TX status */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x03 } }, /* get FREQ and MODE status */
|
2020-09-03 22:07:09 +00:00
|
|
|
{ 1, { 0xff, 0xff, 0xff, 0xff, 0xff } }, /* pwr wakeup sequence */
|
2019-11-30 16:19:08 +00:00
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x0f } }, /* pwr on */
|
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x8f } }, /* pwr off */
|
|
|
|
{ 0, { 0x00, 0x00, 0x00, 0x00, 0xbb } }, /* eeprom read */
|
2021-08-22 18:58:29 +00:00
|
|
|
{ 1, { 0x00, 0x00, 0x00, 0x00, 0xbd } }, /* get TX metering levels (PWR, SWR, MOD, ALC) */
|
2015-12-07 19:32:51 +00:00
|
|
|
};
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
enum ft817_digi
|
|
|
|
{
|
|
|
|
FT817_DIGI_RTTY = 0,
|
|
|
|
FT817_DIGI_PSK_L,
|
|
|
|
FT817_DIGI_PSK_U,
|
|
|
|
FT817_DIGI_USER_L,
|
|
|
|
FT817_DIGI_USER_U,
|
2001-12-15 03:19:39 +00:00
|
|
|
};
|
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
#define FT817_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTFM|\
|
2015-12-07 19:32:51 +00:00
|
|
|
RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
2005-09-04 10:44:23 +00:00
|
|
|
#define FT817_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY)
|
|
|
|
#define FT817_CWN_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY)
|
|
|
|
#define FT817_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_PKTFM)
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
#define FT817_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\
|
2015-12-07 19:32:51 +00:00
|
|
|
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
2005-09-04 10:44:23 +00:00
|
|
|
#define FT817_AM_TX_MODES (RIG_MODE_AM)
|
|
|
|
|
|
|
|
#define FT817_VFO_ALL (RIG_VFO_A|RIG_VFO_B)
|
2021-08-24 21:23:48 +00:00
|
|
|
#define FT817_ANT_FRONT (RIG_ANT_1)
|
|
|
|
#define FT817_ANT_REAR (RIG_ANT_2)
|
|
|
|
#define FT817_ANTS (FT817_ANT_FRONT | FT817_ANT_REAR)
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2008-01-05 15:28:57 +00:00
|
|
|
#define FT817_STR_CAL { 16, \
|
|
|
|
{ \
|
|
|
|
{ 0x00, -54 }, /* S0 */ \
|
|
|
|
{ 0x01, -48 }, \
|
|
|
|
{ 0x02, -42 }, \
|
|
|
|
{ 0x03, -36 }, \
|
|
|
|
{ 0x04, -30 }, \
|
|
|
|
{ 0x05, -24 }, \
|
|
|
|
{ 0x06, -18 }, \
|
|
|
|
{ 0x07, -12 }, \
|
|
|
|
{ 0x08, -6 }, \
|
|
|
|
{ 0x09, 0 }, /* S9 */ \
|
|
|
|
{ 0x0A, 10 }, /* +10 */ \
|
|
|
|
{ 0x0B, 20 }, /* +20 */ \
|
|
|
|
{ 0x0C, 30 }, /* +30 */ \
|
|
|
|
{ 0x0D, 40 }, /* +40 */ \
|
|
|
|
{ 0x0E, 50 }, /* +50 */ \
|
|
|
|
{ 0x0F, 60 } /* +60 */ \
|
|
|
|
} }
|
|
|
|
|
2020-10-09 21:21:15 +00:00
|
|
|
// Thanks to Olivier Schmitt sc.olivier@gmail.com for these tables
|
|
|
|
#define FT817_PWR_CAL { 9, \
|
|
|
|
{ \
|
|
|
|
{ 0x00, 0 }, \
|
|
|
|
{ 0x01, 10 }, \
|
|
|
|
{ 0x02, 14 }, \
|
|
|
|
{ 0x03, 20 }, \
|
|
|
|
{ 0x04, 34 }, \
|
|
|
|
{ 0x05, 50 }, \
|
|
|
|
{ 0x06, 66 }, \
|
|
|
|
{ 0x07, 82 }, \
|
|
|
|
{ 0x08, 100 } \
|
|
|
|
} }
|
|
|
|
|
|
|
|
#define FT817_ALC_CAL { 6, \
|
|
|
|
{ \
|
|
|
|
{ 0x00, 0 }, \
|
|
|
|
{ 0x01, 20 }, \
|
|
|
|
{ 0x02, 40 }, \
|
|
|
|
{ 0x03, 60 }, \
|
|
|
|
{ 0x04, 80 }, \
|
|
|
|
{ 0x05, 100 } \
|
|
|
|
} }
|
|
|
|
|
|
|
|
#define FT817_SWR_CAL { 2, \
|
|
|
|
{ \
|
|
|
|
{ 0, 0 }, \
|
|
|
|
{ 15, 100 } \
|
|
|
|
} }
|
|
|
|
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
const struct rig_caps ft817_caps =
|
|
|
|
{
|
2020-03-05 14:44:18 +00:00
|
|
|
RIG_MODEL(RIG_MODEL_FT817),
|
2019-11-30 16:19:08 +00:00
|
|
|
.model_name = "FT-817",
|
|
|
|
.mfg_name = "Yaesu",
|
2021-09-16 20:57:37 +00:00
|
|
|
.version = "20210916.0",
|
2019-11-30 16:19:08 +00:00
|
|
|
.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 = 38400,
|
|
|
|
.serial_data_bits = 8,
|
|
|
|
.serial_stop_bits = 2,
|
|
|
|
.serial_parity = RIG_PARITY_NONE,
|
|
|
|
.serial_handshake = RIG_HANDSHAKE_NONE,
|
|
|
|
.write_delay = FT817_WRITE_DELAY,
|
2020-07-02 17:31:09 +00:00
|
|
|
.post_write_delay = FT817_POST_WRITE_DELAY,
|
|
|
|
.timeout = FT817_TIMEOUT,
|
|
|
|
.retry = 5,
|
|
|
|
.has_get_func = RIG_FUNC_NONE,
|
|
|
|
.has_set_func = RIG_FUNC_LOCK | RIG_FUNC_TONE | RIG_FUNC_TSQL,
|
2021-08-22 21:16:41 +00:00
|
|
|
.has_get_level =
|
2021-11-28 18:41:10 +00:00
|
|
|
RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER |
|
|
|
|
RIG_LEVEL_ALC | RIG_LEVEL_SWR,
|
2020-07-02 17:31:09 +00:00
|
|
|
.has_set_level = RIG_LEVEL_NONE,
|
|
|
|
.has_get_parm = RIG_PARM_NONE,
|
|
|
|
.has_set_parm = RIG_PARM_NONE,
|
|
|
|
.level_gran = {}, /* granularity */
|
|
|
|
.parm_gran = {},
|
|
|
|
.ctcss_list = common_ctcss_list,
|
|
|
|
.dcs_list = common_dcs_list, /* only 104 out of 106 supported */
|
|
|
|
.preamp = { RIG_DBLST_END, },
|
|
|
|
.attenuator = { RIG_DBLST_END, },
|
|
|
|
.max_rit = Hz(9990),
|
|
|
|
.max_xit = Hz(0),
|
|
|
|
.max_ifshift = Hz(0),
|
|
|
|
.vfo_ops = RIG_OP_TOGGLE,
|
|
|
|
.targetable_vfo = 0,
|
|
|
|
.transceive = RIG_TRN_OFF,
|
|
|
|
.bank_qty = 0,
|
|
|
|
.chan_desc_sz = 0,
|
|
|
|
.chan_list = { RIG_CHAN_END, },
|
|
|
|
|
|
|
|
.rx_range_list1 = {
|
2021-08-24 21:23:48 +00:00
|
|
|
{kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
2020-07-02 17:31:09 +00:00
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
.tx_range_list1 = {
|
|
|
|
FRQ_RNG_HF(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_HF(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_6m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_6m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_2m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_2m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_70cm(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_70cm(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
.rx_range_list2 = {
|
2021-08-24 21:23:48 +00:00
|
|
|
{kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
2020-07-02 17:31:09 +00:00
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
.tx_range_list2 = {
|
|
|
|
FRQ_RNG_HF(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_HF(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
/* FIXME: 60 meters in US version */
|
|
|
|
|
|
|
|
FRQ_RNG_6m(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_6m(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_2m(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_2m(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_70cm(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_70cm(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
.tuning_steps = {
|
|
|
|
{FT817_SSB_CW_RX_MODES, Hz(10)},
|
|
|
|
{FT817_AM_FM_RX_MODES | RIG_MODE_WFM, Hz(100)},
|
|
|
|
RIG_TS_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
.filters = {
|
|
|
|
{FT817_SSB_CW_RX_MODES, kHz(2.2)}, /* normal passband */
|
|
|
|
{FT817_CWN_RX_MODES, 500}, /* CW and RTTY narrow */
|
|
|
|
{RIG_MODE_AM, kHz(6)}, /* AM normal */
|
|
|
|
{RIG_MODE_FM | RIG_MODE_PKTFM, kHz(9)},
|
|
|
|
{RIG_MODE_WFM, kHz(15)},
|
|
|
|
RIG_FLT_END,
|
|
|
|
},
|
|
|
|
|
2020-10-09 21:21:15 +00:00
|
|
|
.str_cal = FT817_STR_CAL,
|
|
|
|
.swr_cal = FT817_SWR_CAL,
|
|
|
|
.alc_cal = FT817_ALC_CAL,
|
|
|
|
.rfpower_meter_cal = FT817_PWR_CAL,
|
2020-07-02 17:31:09 +00:00
|
|
|
|
|
|
|
.rig_init = ft817_init,
|
2021-08-24 21:23:48 +00:00
|
|
|
.rig_cleanup = ft817_cleanup,
|
2020-07-02 17:31:09 +00:00
|
|
|
.rig_open = ft817_open,
|
|
|
|
.rig_close = ft817_close,
|
2021-08-17 19:48:25 +00:00
|
|
|
.get_vfo = ft817_get_vfo,
|
|
|
|
.set_vfo = ft817_set_vfo,
|
2020-07-02 17:31:09 +00:00
|
|
|
.set_freq = ft817_set_freq,
|
|
|
|
.get_freq = ft817_get_freq,
|
|
|
|
.set_mode = ft817_set_mode,
|
|
|
|
.get_mode = ft817_get_mode,
|
2021-08-24 21:23:48 +00:00
|
|
|
.set_ptt = ft817_set_ptt,
|
|
|
|
.get_ptt = ft817_get_ptt,
|
|
|
|
.get_dcd = ft817_get_dcd,
|
2020-07-02 17:31:09 +00:00
|
|
|
.set_rptr_shift = ft817_set_rptr_shift,
|
|
|
|
.set_rptr_offs = ft817_set_rptr_offs,
|
|
|
|
.set_split_vfo = ft817_set_split_vfo,
|
|
|
|
.get_split_vfo = ft817_get_split_vfo,
|
2021-08-24 21:23:48 +00:00
|
|
|
.set_rit = ft817_set_rit,
|
2020-07-02 17:31:09 +00:00
|
|
|
.set_dcs_code = ft817_set_dcs_code,
|
|
|
|
.set_ctcss_tone = ft817_set_ctcss_tone,
|
2021-08-24 21:23:48 +00:00
|
|
|
.set_dcs_sql = ft817_set_dcs_sql,
|
2020-07-02 17:31:09 +00:00
|
|
|
.set_ctcss_sql = ft817_set_ctcss_sql,
|
2021-08-24 21:23:48 +00:00
|
|
|
.power2mW = ft817_power2mW,
|
|
|
|
.mW2power = ft817_mW2power,
|
2020-07-02 17:31:09 +00:00
|
|
|
.set_powerstat = ft817_set_powerstat,
|
2021-09-04 20:56:06 +00:00
|
|
|
.get_ant = ft817_get_ant,
|
2020-07-02 17:31:09 +00:00
|
|
|
.get_level = ft817_get_level,
|
|
|
|
.set_func = ft817_set_func,
|
2021-08-24 21:23:48 +00:00
|
|
|
.vfo_op = ft817_vfo_op,
|
2020-07-02 17:31:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct rig_caps ft818_caps =
|
|
|
|
{
|
|
|
|
RIG_MODEL(RIG_MODEL_FT818),
|
|
|
|
.model_name = "FT-818",
|
|
|
|
.mfg_name = "Yaesu",
|
2020-07-10 22:02:16 +00:00
|
|
|
.version = "20200710.0",
|
2020-07-02 17:31:09 +00:00
|
|
|
.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 = 38400,
|
|
|
|
.serial_data_bits = 8,
|
|
|
|
.serial_stop_bits = 2,
|
|
|
|
.serial_parity = RIG_PARITY_NONE,
|
|
|
|
.serial_handshake = RIG_HANDSHAKE_NONE,
|
|
|
|
.write_delay = FT817_WRITE_DELAY,
|
2019-11-30 16:19:08 +00:00
|
|
|
.post_write_delay = FT817_POST_WRITE_DELAY,
|
|
|
|
.timeout = FT817_TIMEOUT,
|
|
|
|
.retry = 5,
|
|
|
|
.has_get_func = RIG_FUNC_NONE,
|
|
|
|
.has_set_func = RIG_FUNC_LOCK | RIG_FUNC_TONE | RIG_FUNC_TSQL,
|
2021-08-22 21:16:41 +00:00
|
|
|
.has_get_level =
|
2021-11-28 18:41:10 +00:00
|
|
|
RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER |
|
|
|
|
RIG_LEVEL_ALC | RIG_LEVEL_SWR,
|
2019-11-30 16:19:08 +00:00
|
|
|
.has_set_level = RIG_LEVEL_NONE,
|
|
|
|
.has_get_parm = RIG_PARM_NONE,
|
|
|
|
.has_set_parm = RIG_PARM_NONE,
|
|
|
|
.level_gran = {}, /* granularity */
|
|
|
|
.parm_gran = {},
|
|
|
|
.ctcss_list = common_ctcss_list,
|
|
|
|
.dcs_list = common_dcs_list, /* only 104 out of 106 supported */
|
|
|
|
.preamp = { RIG_DBLST_END, },
|
|
|
|
.attenuator = { RIG_DBLST_END, },
|
|
|
|
.max_rit = Hz(9990),
|
|
|
|
.max_xit = Hz(0),
|
|
|
|
.max_ifshift = Hz(0),
|
|
|
|
.vfo_ops = RIG_OP_TOGGLE,
|
|
|
|
.targetable_vfo = 0,
|
|
|
|
.transceive = RIG_TRN_OFF,
|
|
|
|
.bank_qty = 0,
|
|
|
|
.chan_desc_sz = 0,
|
|
|
|
.chan_list = { RIG_CHAN_END, },
|
|
|
|
|
|
|
|
.rx_range_list1 = {
|
2021-08-24 21:23:48 +00:00
|
|
|
{kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
2019-11-30 16:19:08 +00:00
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
.tx_range_list1 = {
|
|
|
|
FRQ_RNG_HF(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_HF(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
2021-08-29 20:01:12 +00:00
|
|
|
|
|
|
|
/* One of the key differences between 817 and 818: the 818 has 60m! */
|
|
|
|
FRQ_RNG_60m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_60m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
FRQ_RNG_6m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_6m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_2m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_2m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_70cm(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_70cm(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
.rx_range_list2 = {
|
2021-08-24 21:23:48 +00:00
|
|
|
{kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
|
|
|
{MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS},
|
2019-11-30 16:19:08 +00:00
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
.tx_range_list2 = {
|
|
|
|
FRQ_RNG_HF(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_HF(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
2021-08-29 20:01:12 +00:00
|
|
|
|
|
|
|
/* One of the key differences between 817 and 818: the 818 has 60m! */
|
|
|
|
FRQ_RNG_60m(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_60m(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
FRQ_RNG_6m(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_6m(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_2m(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_2m(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
FRQ_RNG_70cm(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
FRQ_RNG_70cm(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),
|
|
|
|
|
|
|
|
RIG_FRNG_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
.tuning_steps = {
|
|
|
|
{FT817_SSB_CW_RX_MODES, Hz(10)},
|
|
|
|
{FT817_AM_FM_RX_MODES | RIG_MODE_WFM, Hz(100)},
|
|
|
|
RIG_TS_END,
|
|
|
|
},
|
|
|
|
|
|
|
|
.filters = {
|
|
|
|
{FT817_SSB_CW_RX_MODES, kHz(2.2)}, /* normal passband */
|
|
|
|
{FT817_CWN_RX_MODES, 500}, /* CW and RTTY narrow */
|
|
|
|
{RIG_MODE_AM, kHz(6)}, /* AM normal */
|
|
|
|
{RIG_MODE_FM | RIG_MODE_PKTFM, kHz(9)},
|
|
|
|
{RIG_MODE_WFM, kHz(15)},
|
|
|
|
RIG_FLT_END,
|
|
|
|
},
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
.str_cal = FT817_STR_CAL,
|
|
|
|
.swr_cal = FT817_SWR_CAL,
|
|
|
|
.alc_cal = FT817_ALC_CAL,
|
|
|
|
.rfpower_meter_cal = FT817_PWR_CAL,
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
.rig_init = ft817_init,
|
2021-08-24 21:23:48 +00:00
|
|
|
.rig_cleanup = ft817_cleanup,
|
2019-11-30 16:19:08 +00:00
|
|
|
.rig_open = ft817_open,
|
|
|
|
.rig_close = ft817_close,
|
2021-08-17 19:48:25 +00:00
|
|
|
.get_vfo = ft817_get_vfo,
|
|
|
|
.set_vfo = ft817_set_vfo,
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_freq = ft817_set_freq,
|
|
|
|
.get_freq = ft817_get_freq,
|
|
|
|
.set_mode = ft817_set_mode,
|
|
|
|
.get_mode = ft817_get_mode,
|
2021-08-24 21:23:48 +00:00
|
|
|
.set_ptt = ft817_set_ptt,
|
|
|
|
.get_ptt = ft817_get_ptt,
|
|
|
|
.get_dcd = ft817_get_dcd,
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_rptr_shift = ft817_set_rptr_shift,
|
|
|
|
.set_rptr_offs = ft817_set_rptr_offs,
|
|
|
|
.set_split_vfo = ft817_set_split_vfo,
|
|
|
|
.get_split_vfo = ft817_get_split_vfo,
|
2021-08-24 21:23:48 +00:00
|
|
|
.set_rit = ft817_set_rit,
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_dcs_code = ft817_set_dcs_code,
|
|
|
|
.set_ctcss_tone = ft817_set_ctcss_tone,
|
2021-08-24 21:23:48 +00:00
|
|
|
.set_dcs_sql = ft817_set_dcs_sql,
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_ctcss_sql = ft817_set_ctcss_sql,
|
2021-08-24 21:23:48 +00:00
|
|
|
.power2mW = ft817_power2mW,
|
|
|
|
.mW2power = ft817_mW2power,
|
2019-11-30 16:19:08 +00:00
|
|
|
.set_powerstat = ft817_set_powerstat,
|
2021-09-04 20:56:06 +00:00
|
|
|
.get_ant = ft818_get_ant,
|
2019-11-30 16:19:08 +00:00
|
|
|
.get_level = ft817_get_level,
|
|
|
|
.set_func = ft817_set_func,
|
2021-08-24 21:23:48 +00:00
|
|
|
.vfo_op = ft817_vfo_op,
|
2011-08-23 02:26:44 +00:00
|
|
|
};
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
/* ---------------------------------------------------------------------- */
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_init(RIG *rig)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2020-10-15 20:44:43 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called, version %s\n", __func__,
|
|
|
|
rig->caps->version);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2020-01-13 18:48:30 +00:00
|
|
|
if ((rig->state.priv = calloc(1, sizeof(struct ft817_priv_data))) == NULL)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
return -RIG_ENOMEM;
|
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_cleanup(RIG *rig)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
free(rig->state.priv);
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig->state.priv = NULL;
|
|
|
|
|
|
|
|
return RIG_OK;
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_open(RIG *rig)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_close(RIG *rig)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static inline long timediff(struct timeval *tv1, struct timeval *tv2)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct timeval tv;
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
tv.tv_usec = tv1->tv_usec - tv2->tv_usec;
|
|
|
|
tv.tv_sec = tv1->tv_sec - tv2->tv_sec;
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return ((tv.tv_sec * 1000L) + (tv.tv_usec / 1000L));
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int check_cache_timeout(struct timeval *tv)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct timeval curr;
|
|
|
|
long t;
|
|
|
|
|
|
|
|
if (tv->tv_sec == 0 && tv->tv_usec == 0)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: cache invalid\n", __func__);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gettimeofday(&curr, NULL);
|
|
|
|
|
|
|
|
if ((t = timediff(&curr, tv)) < FT817_CACHE_TIMEOUT)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: using cache (%ld ms)\n", t);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: cache timed out (%ld ms)\n", t);
|
|
|
|
return 1;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 19:32:51 +00:00
|
|
|
static int ft817_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH];
|
|
|
|
int n;
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
2021-08-17 20:02:45 +00:00
|
|
|
memcpy(data, ncmd[FT817_NATIVE_CAT_EEPROM_READ].nseq,
|
2019-11-30 16:19:08 +00:00
|
|
|
YAESU_CMD_LENGTH);
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
data[0] = addr >> 8;
|
|
|
|
data[1] = addr & 0xfe;
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2021-12-18 21:49:45 +00:00
|
|
|
write_block(&rig->state.rigport, data, YAESU_CMD_LENGTH);
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2021-12-18 21:49:45 +00:00
|
|
|
if ((n = read_block(&rig->state.rigport, data, 2)) < 0)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (n != 2)
|
|
|
|
{
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
*out = data[addr % 2];
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2015-12-07 19:32:51 +00:00
|
|
|
}
|
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
static int ft817_get_status(RIG *rig, int status)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
|
|
|
struct timeval *tv;
|
|
|
|
unsigned char *data;
|
|
|
|
int len;
|
|
|
|
int n;
|
|
|
|
int retries = rig->state.rigport.retry;
|
2021-08-22 21:16:41 +00:00
|
|
|
unsigned char result[2];
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (status)
|
|
|
|
{
|
|
|
|
case FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS:
|
|
|
|
data = p->fm_status;
|
2021-08-22 21:16:41 +00:00
|
|
|
/* Answer is 5 long; 4 bytes BCD freq, 1 byte status */
|
|
|
|
len = 5;
|
2019-11-30 16:19:08 +00:00
|
|
|
tv = &p->fm_status_tv;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FT817_NATIVE_CAT_GET_RX_STATUS:
|
|
|
|
data = &p->rx_status;
|
2020-10-13 03:42:27 +00:00
|
|
|
len = 1;
|
2019-11-30 16:19:08 +00:00
|
|
|
tv = &p->rx_status_tv;
|
|
|
|
break;
|
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
case FT817_NATIVE_CAT_GET_TX_METERING:
|
|
|
|
data = result;
|
2021-11-28 18:41:10 +00:00
|
|
|
len = sizeof(result) / sizeof(result[0]); /* We expect two bytes */
|
2021-08-22 21:16:41 +00:00
|
|
|
tv = &p->tx_level_tv;
|
|
|
|
break;
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case FT817_NATIVE_CAT_GET_TX_STATUS:
|
|
|
|
data = &p->tx_status;
|
|
|
|
len = 1;
|
|
|
|
tv = &p->tx_status_tv;
|
|
|
|
break;
|
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
default:
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Internal error!\n", __func__);
|
|
|
|
return -RIG_EINTERNAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2020-06-23 14:01:46 +00:00
|
|
|
rig_flush(&rig->state.rigport);
|
2021-12-18 21:49:45 +00:00
|
|
|
write_block(&rig->state.rigport, ncmd[status].nseq,
|
2019-11-30 16:19:08 +00:00
|
|
|
YAESU_CMD_LENGTH);
|
2021-12-18 21:49:45 +00:00
|
|
|
n = read_block(&rig->state.rigport, data, len);
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
|
|
|
while (retries-- && n < 0);
|
|
|
|
|
|
|
|
if (n < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n != len)
|
|
|
|
{
|
2021-08-22 21:16:41 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: Length mismatch exp %d got %d!\n",
|
2021-11-28 18:41:10 +00:00
|
|
|
__func__, len, n);
|
2019-11-30 16:19:08 +00:00
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
switch (status)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
2021-08-22 21:16:41 +00:00
|
|
|
case FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS:
|
2021-11-28 18:41:10 +00:00
|
|
|
{
|
|
|
|
/* Only in digimode we need fetch to extra bits from EEPROM.
|
|
|
|
* This save communication cycle for all other modes.
|
|
|
|
* Because mode and frequency are shared this saves also when
|
|
|
|
* getting the frequency. */
|
|
|
|
switch (p->fm_status[4] & 0x7f)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
2021-11-28 18:41:10 +00:00
|
|
|
unsigned char dig_mode;
|
|
|
|
|
|
|
|
case 0x0a:
|
|
|
|
if ((n = ft817_read_eeprom(rig, 0x0065, &dig_mode)) < 0)
|
2021-08-22 21:16:41 +00:00
|
|
|
{
|
2021-11-28 18:41:10 +00:00
|
|
|
return n;
|
2021-08-22 21:16:41 +00:00
|
|
|
}
|
2021-11-28 18:41:10 +00:00
|
|
|
|
|
|
|
/* Top 3 bit define the digi mode */
|
|
|
|
p->dig_mode = dig_mode >> 5;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
2021-11-28 18:41:10 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
case FT817_NATIVE_CAT_GET_TX_METERING:
|
2021-11-28 18:41:10 +00:00
|
|
|
/* FT-817 returns 2 bytes with 4 nibbles.
|
|
|
|
* Extract raw values here;
|
|
|
|
* convert to float when they are requested. */
|
|
|
|
p->swr_level = result[0] & 0xF;
|
|
|
|
p->pwr_level = result[0] >> 4;
|
|
|
|
p->alc_level = result[1] & 0xF;
|
|
|
|
p->mod_level = result[1] >> 4;
|
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: swr: %d, pwr %d, alc %d, mod %d\n",
|
|
|
|
__func__,
|
|
|
|
p->swr_level,
|
|
|
|
p->pwr_level,
|
|
|
|
p->alc_level,
|
|
|
|
p->mod_level);
|
2021-08-22 21:16:41 +00:00
|
|
|
break;
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gettimeofday(tv, NULL);
|
|
|
|
|
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
|
|
|
freq_t f1 = 0, f2 = 0;
|
|
|
|
int retries = rig->state.rigport.retry +
|
|
|
|
1; // +1 because, because 2 steps are needed even in best scenario
|
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
while ((f1 == 0 || f1 != f2) && retries-- > 0)
|
|
|
|
{
|
2020-07-03 21:17:59 +00:00
|
|
|
int n;
|
2020-06-26 04:20:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: retries=%d\n", __func__, retries);
|
2020-06-29 04:34:23 +00:00
|
|
|
|
2020-06-26 04:20:55 +00:00
|
|
|
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
f1 = f2;
|
|
|
|
f2 = from_bcd_be(p->fm_status, 8);
|
2021-11-28 18:41:10 +00:00
|
|
|
dump_hex(p->fm_status, sizeof(p->fm_status) / sizeof(p->fm_status[0]));
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:02:16 +00:00
|
|
|
#if 1 // user must be twiddling the VFO
|
|
|
|
// usually get_freq is OK but we have to allow that f1 != f2 when knob is moving
|
|
|
|
*freq = f2 * 10;
|
|
|
|
return RIG_OK;
|
|
|
|
#else // remove this if no complaints
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retries >= 0)
|
|
|
|
{
|
|
|
|
*freq = f1 * 10;
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-07-10 22:02:16 +00:00
|
|
|
#endif
|
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
if (check_cache_timeout(&p->fm_status_tv))
|
|
|
|
{
|
2019-12-24 16:02:47 +00:00
|
|
|
int n;
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2019-12-24 16:02:47 +00:00
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
switch (p->fm_status[4] & 0x7f)
|
|
|
|
{
|
|
|
|
case 0x00:
|
|
|
|
*mode = RIG_MODE_LSB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x01:
|
|
|
|
*mode = RIG_MODE_USB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x02:
|
|
|
|
*mode = RIG_MODE_CW;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x03:
|
|
|
|
*mode = RIG_MODE_CWR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x04:
|
|
|
|
*mode = RIG_MODE_AM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x06:
|
|
|
|
*mode = RIG_MODE_WFM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x08:
|
|
|
|
*mode = RIG_MODE_FM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0a:
|
2021-08-22 18:53:24 +00:00
|
|
|
switch (p->dig_mode)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
case FT817_DIGI_RTTY: *mode = RIG_MODE_RTTYR; break;
|
|
|
|
|
|
|
|
case FT817_DIGI_PSK_L: *mode = RIG_MODE_PKTLSB; break;
|
|
|
|
|
|
|
|
case FT817_DIGI_PSK_U: *mode = RIG_MODE_PKTUSB; break;
|
|
|
|
|
|
|
|
case FT817_DIGI_USER_L: *mode = RIG_MODE_PKTLSB; break;
|
|
|
|
|
|
|
|
case FT817_DIGI_USER_U: *mode = RIG_MODE_PKTUSB; break;
|
2021-08-22 18:53:24 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
*mode = RIG_MODE_NONE;
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x0C:
|
|
|
|
*mode = RIG_MODE_PKTFM;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
*mode = RIG_MODE_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p->fm_status[4] & 0x80) /* narrow */
|
|
|
|
{
|
|
|
|
*width = rig_passband_narrow(rig, *mode);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*width = RIG_PASSBAND_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
|
|
|
|
vfo_t *tx_vfo)
|
2015-12-07 19:32:51 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
2021-09-08 19:36:24 +00:00
|
|
|
ptt_t ptt;
|
2019-11-30 16:19:08 +00:00
|
|
|
int n;
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2021-09-08 19:36:24 +00:00
|
|
|
n = ft817_get_ptt(rig, 0, &ptt);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-09-08 19:36:24 +00:00
|
|
|
if (n != RIG_OK)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2015-12-07 19:32:51 +00:00
|
|
|
|
2021-09-08 19:36:24 +00:00
|
|
|
/* Check if rig is in TX mode */
|
|
|
|
if (ptt == RIG_PTT_OFF)
|
2015-12-07 19:32:51 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
// TX status not valid when in RX
|
|
|
|
unsigned char c;
|
|
|
|
|
2021-09-08 19:36:24 +00:00
|
|
|
/* Get split status from EEPROM */
|
|
|
|
n = ft817_read_eeprom(rig, 0x7a, &c);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-09-08 19:36:24 +00:00
|
|
|
if (n != RIG_OK)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
*split = (c & 0x80) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
2015-12-07 19:32:51 +00:00
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
else
|
2015-12-07 19:32:51 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
*split = (p->tx_status & 0x20) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
2015-12-07 19:32:51 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2015-12-07 19:32:51 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
if (check_cache_timeout(&p->tx_status_tv))
|
|
|
|
{
|
2019-12-24 16:02:47 +00:00
|
|
|
int n;
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2019-12-24 16:02:47 +00:00
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
*ptt = ((p->tx_status & 0x80) == 0);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
static int ft817_get_tx_level(RIG *rig, value_t *val, unsigned char *tx_level,
|
|
|
|
const cal_table_float_t *cal)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
if (check_cache_timeout(&p->tx_level_tv))
|
2020-02-23 17:26:09 +00:00
|
|
|
{
|
2019-12-24 16:02:47 +00:00
|
|
|
int n;
|
2021-08-22 21:16:41 +00:00
|
|
|
ptt_t ptt;
|
|
|
|
|
|
|
|
/* Default to not keyed */
|
|
|
|
*tx_level = 0;
|
|
|
|
|
|
|
|
/* TX metering is special; it sends 1 byte if not keyed and 2 if keyed.
|
|
|
|
* To handle this properly we first verify the rig is keyed.
|
|
|
|
* Otherwise we experience at least a full timeout and
|
|
|
|
* perhaps pointless retries + timeouts.
|
|
|
|
*/
|
|
|
|
n = ft817_get_ptt(rig, 0, &ptt);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
if (n != RIG_OK)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
if (ptt == RIG_PTT_OFF)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: rig not keyed\n", __func__);
|
|
|
|
return -RIG_ERJCTED; //Or return OK?
|
|
|
|
}
|
2020-10-09 21:21:15 +00:00
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_METERING);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
if (n != RIG_OK)
|
2020-10-09 21:21:15 +00:00
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-22 21:16:41 +00:00
|
|
|
val->f = rig_raw2val_float(*tx_level, cal);
|
2021-09-04 20:56:06 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: level %f\n", __func__, val->f);
|
2020-10-09 21:21:15 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
2008-11-03 20:48:09 +00:00
|
|
|
|
2008-01-05 15:28:57 +00:00
|
|
|
/* frontend will always use RAWSTR+cal_table */
|
2005-09-04 10:44:23 +00:00
|
|
|
static int ft817_get_smeter_level(RIG *rig, value_t *val)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
|
|
|
int n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (check_cache_timeout(&p->rx_status_tv))
|
|
|
|
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_RX_STATUS)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
//n = (p->rx_status & 0x0F) - 9;
|
2008-01-05 15:28:57 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
//val->i = n * ((n > 0) ? 10 : 6);
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2008-01-05 15:28:57 +00:00
|
|
|
/* S-meter value is returned in the lower 4 bits.
|
|
|
|
0x00 = S0 (-54dB)
|
|
|
|
0x01 = S1
|
|
|
|
0x02 = S2
|
|
|
|
...
|
|
|
|
0x09 = S9 (0dB)
|
|
|
|
0x0A = S9+10 (10dB)
|
|
|
|
0x0B = S9+20 and so on
|
|
|
|
*/
|
|
|
|
n = (p->rx_status & 0x0F);
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (n < 0x0A)
|
|
|
|
{
|
|
|
|
val->i = (6 * n) - 54;
|
2008-01-05 15:28:57 +00:00
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
val->i = 10 * (n - 9);
|
2008-01-05 15:28:57 +00:00
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
2008-11-03 20:48:09 +00:00
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
|
|
|
|
static int ft817_get_raw_smeter_level(RIG *rig, value_t *val)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
if (check_cache_timeout(&p->rx_status_tv))
|
|
|
|
{
|
2019-12-24 16:02:47 +00:00
|
|
|
int n;
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_RX_STATUS)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2019-12-24 16:02:47 +00:00
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
val->i = p->rx_status & 0x0F;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2021-08-22 21:16:41 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (level)
|
|
|
|
{
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_LEVEL_STRENGTH:
|
2008-11-03 20:48:09 +00:00
|
|
|
/* The front-end will always call for RAWSTR and use the cal_table */
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_get_smeter_level(rig, val);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_LEVEL_RAWSTR:
|
|
|
|
return ft817_get_raw_smeter_level(rig, val);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_LEVEL_RFPOWER:
|
2021-11-28 18:41:10 +00:00
|
|
|
return ft817_get_tx_level(rig, val, &p->pwr_level,
|
|
|
|
&rig->caps->rfpower_meter_cal);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-10-09 21:21:15 +00:00
|
|
|
case RIG_LEVEL_ALC:
|
2021-08-22 21:16:41 +00:00
|
|
|
return ft817_get_tx_level(rig, val, &p->alc_level, &rig->caps->alc_cal);
|
|
|
|
|
|
|
|
case RIG_LEVEL_SWR:
|
|
|
|
return ft817_get_tx_level(rig, val, &p->swr_level, &rig->caps->swr_cal);
|
2020-10-09 21:21:15 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2020-02-23 17:26:09 +00:00
|
|
|
if (check_cache_timeout(&p->rx_status_tv))
|
|
|
|
{
|
2019-12-24 16:02:47 +00:00
|
|
|
int n;
|
2020-02-23 17:26:09 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_RX_STATUS)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2020-02-23 17:26:09 +00:00
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* TODO: consider bit 6 too ??? (CTCSS/DCS code match) */
|
|
|
|
if (p->rx_status & 0x80)
|
|
|
|
{
|
|
|
|
*dcd = RIG_DCD_OFF;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*dcd = RIG_DCD_ON;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 20:56:06 +00:00
|
|
|
static int ft818_817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
|
|
|
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx, bool is817)
|
2021-08-24 21:23:48 +00:00
|
|
|
{
|
2021-09-04 20:56:06 +00:00
|
|
|
/* The FT818/817 has no RIG_TARGETABLE_ALL
|
|
|
|
* so rig.c switched the active VFO to the one requested */
|
2021-08-24 21:23:48 +00:00
|
|
|
int ret;
|
|
|
|
unsigned char eeprom_band, eeprom_ant;
|
|
|
|
|
|
|
|
/* Read eeprom for current 'band' for both VFO's */
|
|
|
|
ret = ft817_read_eeprom(rig, 0x59, &eeprom_band);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-08-24 21:23:48 +00:00
|
|
|
if (ret != RIG_OK)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read eeprom for antenna selection per band.
|
|
|
|
* The FT818/817 stores antenna per band not per VFO!
|
|
|
|
* So changing antenna will change for both VFO's */
|
|
|
|
ret = ft817_read_eeprom(rig, 0x7A, &eeprom_ant);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-08-24 21:23:48 +00:00
|
|
|
if (ret != RIG_OK)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if CURR then get real VFO before parsing EEPROM */
|
|
|
|
if (vfo == RIG_VFO_CURR)
|
|
|
|
{
|
|
|
|
vfo = rig->state.current_vfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* band info is 4 bit per VFO, for A lower nibble, B is upper nible */
|
2021-11-28 18:41:10 +00:00
|
|
|
switch (vfo)
|
|
|
|
{
|
|
|
|
case RIG_VFO_A:
|
|
|
|
eeprom_band &= 0xF;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
2021-11-28 18:41:10 +00:00
|
|
|
|
|
|
|
case RIG_VFO_B:
|
|
|
|
eeprom_band = eeprom_band >> 4;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
default:
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %0x!\n",
|
|
|
|
__func__, vfo);
|
|
|
|
return -RIG_EINTERNAL;
|
2021-08-24 21:23:48 +00:00
|
|
|
}
|
|
|
|
|
2021-09-04 20:56:06 +00:00
|
|
|
/* The 818 and the 817 differ in bands: the 818 has 60m.
|
|
|
|
* The band selection flags for the 818 and 817 thus differ:
|
|
|
|
* 2 means 60m on 818 and 40m for 817.
|
|
|
|
* And the rest of the values are shifted.
|
|
|
|
*
|
|
|
|
* So to make the code simple: if we have a 817 and 2 or higher band then
|
|
|
|
* add 1 to the value to align it on the 818 mapping.
|
|
|
|
*/
|
|
|
|
if (is817 && eeprom_band >= 2)
|
|
|
|
{
|
|
|
|
eeprom_band++;
|
|
|
|
}
|
|
|
|
|
2021-08-24 21:23:48 +00:00
|
|
|
/* The 817/818 does not have a antenna selection per VFO but per band.
|
|
|
|
* So we read the band for the requested VFO and then map it to the
|
|
|
|
* selected antenna.
|
|
|
|
*/
|
2021-09-04 20:56:06 +00:00
|
|
|
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
switch (eeprom_band)
|
|
|
|
{
|
|
|
|
case 0: /* 160M */
|
|
|
|
case 1: /* 80M */
|
|
|
|
case 2: /* 60M, 818 only */
|
|
|
|
case 3: /* 40M */
|
|
|
|
case 4: /* 30M */
|
|
|
|
case 5: /* 20M */
|
|
|
|
case 6: /* 17M */
|
|
|
|
case 7: /* 15M */
|
|
|
|
case 8: /* 12M */
|
|
|
|
case 9: /* 10M */
|
|
|
|
/* All HF use the same antenna setting, bit 0 */
|
|
|
|
eeprom_ant &= 1 << 0;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
case 0xA: /* 6m, bit 1 */
|
|
|
|
eeprom_ant &= 1 << 1;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
case 0xB: /* FM BCB 76Mhz - 108Mhz, bit 2 */
|
|
|
|
eeprom_ant &= 1 << 2;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
case 0xC: /* Airband, bit 3 */
|
|
|
|
eeprom_ant &= 1 << 3;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
case 0xD: /* 2M, bit 4 */
|
|
|
|
eeprom_ant &= 1 << 4;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
case 0xE: /* 70cm / UHF, bit 5 */
|
|
|
|
eeprom_ant &= 1 << 5;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
|
2021-11-28 18:41:10 +00:00
|
|
|
case 0xF: /* Free-tuning?, bit 6 */
|
|
|
|
eeprom_ant &= 1 << 6;
|
2021-08-24 21:23:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have no split TX/RX capability per VFO.
|
|
|
|
* So only set ant_curr and leave rx/tx set to unknown. */
|
|
|
|
*ant_curr = eeprom_ant ? FT817_ANT_REAR : FT817_ANT_FRONT;
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2021-09-04 20:56:06 +00:00
|
|
|
static int ft817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
2021-11-28 18:41:10 +00:00
|
|
|
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx)
|
2021-09-04 20:56:06 +00:00
|
|
|
{
|
|
|
|
return ft818_817_get_ant(rig, vfo, ant, option, ant_curr, ant_tx, ant_rx,
|
2021-11-28 18:41:10 +00:00
|
|
|
true);
|
2021-09-04 20:56:06 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ft818_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
|
2021-11-28 18:41:10 +00:00
|
|
|
ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx)
|
2021-09-04 20:56:06 +00:00
|
|
|
{
|
|
|
|
return ft818_817_get_ant(rig, vfo, ant, option, ant_curr, ant_tx, ant_rx,
|
2021-11-28 18:41:10 +00:00
|
|
|
false);
|
2021-09-04 20:56:06 +00:00
|
|
|
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2020-06-29 04:34:23 +00:00
|
|
|
int ft817_read_ack(RIG *rig)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2021-12-18 21:49:45 +00:00
|
|
|
unsigned char dummy;
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2020-06-29 04:34:23 +00:00
|
|
|
if (rig->state.rigport.post_write_delay == 0)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
2020-07-03 21:17:59 +00:00
|
|
|
if (read_block(&rig->state.rigport, &dummy, 1) < 0)
|
2020-06-29 04:34:23 +00:00
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: error reading ack\n", __func__);
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: adjusting post_write_delay to avoid ack\n",
|
|
|
|
__func__);
|
|
|
|
rig->state.rigport.post_write_delay =
|
|
|
|
10; // arbitrary choice right now of max 100 cmds/sec
|
2020-06-29 12:50:55 +00:00
|
|
|
return RIG_OK; // let it continue without checking for ack now
|
2020-06-29 04:34:23 +00:00
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
|
2020-06-29 04:34:23 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: ack received (%d)\n", __func__, dummy);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-06-29 04:34:23 +00:00
|
|
|
if (dummy != 0)
|
|
|
|
{
|
|
|
|
return -RIG_ERJCTED;
|
|
|
|
}
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-09-04 10:44:23 +00:00
|
|
|
* private helper function to send a private command sequence.
|
|
|
|
* Must only be complete sequences.
|
2001-12-15 03:19:39 +00:00
|
|
|
*/
|
2005-09-04 10:44:23 +00:00
|
|
|
static int ft817_send_cmd(RIG *rig, int index)
|
|
|
|
{
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2021-08-17 20:02:45 +00:00
|
|
|
if (ncmd[index].ncomp == 0)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: Incomplete sequence\n", __func__);
|
|
|
|
return -RIG_EINTERNAL;
|
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2020-10-15 17:02:03 +00:00
|
|
|
rig_flush(&rig->state.rigport);
|
2021-12-18 21:49:45 +00:00
|
|
|
write_block(&rig->state.rigport, ncmd[index].nseq, YAESU_CMD_LENGTH);
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_read_ack(rig);
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
/*
|
|
|
|
* The same for incomplete commands.
|
|
|
|
*/
|
|
|
|
static int ft817_send_icmd(RIG *rig, int index, unsigned char *data)
|
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char cmd[YAESU_CMD_LENGTH];
|
2011-08-23 02:26:44 +00:00
|
|
|
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2021-08-17 20:02:45 +00:00
|
|
|
if (ncmd[index].ncomp == 1)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: Complete sequence\n", __func__);
|
|
|
|
return -RIG_EINTERNAL;
|
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-17 20:02:45 +00:00
|
|
|
cmd[YAESU_CMD_LENGTH - 1] = ncmd[index].nseq[YAESU_CMD_LENGTH - 1];
|
2019-11-30 16:19:08 +00:00
|
|
|
memcpy(cmd, data, YAESU_CMD_LENGTH - 1);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-12-18 21:49:45 +00:00
|
|
|
write_block(&rig->state.rigport, cmd, YAESU_CMD_LENGTH);
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_read_ack(rig);
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
/* ---------------------------------------------------------------------- */
|
2021-08-17 19:48:25 +00:00
|
|
|
static int ft817_get_vfo(RIG *rig, vfo_t *vfo)
|
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__);
|
|
|
|
|
|
|
|
if (ft817_read_eeprom(rig, 0x55, &c) < 0) /* get vfo status */
|
|
|
|
{
|
|
|
|
return -RIG_EPROTO;
|
|
|
|
}
|
|
|
|
|
2021-09-06 19:49:09 +00:00
|
|
|
if ((c & 0x1) == 0)
|
|
|
|
{
|
|
|
|
*vfo = RIG_VFO_A;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*vfo = RIG_VFO_B;
|
|
|
|
}
|
2021-08-17 19:48:25 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ft817_set_vfo(RIG *rig, vfo_t vfo)
|
|
|
|
{
|
|
|
|
vfo_t curvfo;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__);
|
|
|
|
|
|
|
|
retval = ft817_get_vfo(rig, &curvfo);
|
|
|
|
|
|
|
|
if (retval != RIG_OK)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: error get_vfo '%s'\n", __func__,
|
|
|
|
rigerror(retval));
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curvfo == vfo)
|
|
|
|
{
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB);
|
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH - 1];
|
2020-10-13 22:34:34 +00:00
|
|
|
int retval;
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: requested freq = %"PRIfreq" Hz\n", freq);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in the frequency */
|
|
|
|
to_bcd_be(data, (freq + 5) / 10, 8);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_force_cache_timeout(
|
|
|
|
&((struct ft817_priv_data *)rig->state.priv)->fm_status_tv);
|
2015-02-06 19:58:21 +00:00
|
|
|
|
2020-10-13 22:34:34 +00:00
|
|
|
retval = ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_FREQ, data);
|
2020-10-15 20:44:43 +00:00
|
|
|
hl_usleep(50 * 1000); // FT817 needs a little time after setting freq
|
2020-10-13 22:34:34 +00:00
|
|
|
return retval;
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
int index; /* index of sequence to send */
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: generic mode = %s\n", __func__,
|
|
|
|
rig_strrmode(mode));
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (mode)
|
|
|
|
{
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_AM:
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_AM;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_CW:
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_CW;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_USB:
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_USB;
|
|
|
|
break;
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_LSB:
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_LSB;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_RTTY:
|
|
|
|
case RIG_MODE_PKTUSB:
|
|
|
|
/* user has to have correct DIG mode setup on rig */
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_DIG;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_FM:
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_FM;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_CWR:
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_CWR;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_MODE_PKTFM:
|
|
|
|
index = FT817_NATIVE_CAT_SET_MODE_PKT;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* just ignore passband */
|
|
|
|
/* if (width != RIG_PASSBAND_NORMAL) */
|
|
|
|
/* return -RIG_EINVAL; */
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_force_cache_timeout(
|
|
|
|
&((struct ft817_priv_data *)rig->state.priv)->fm_status_tv);
|
2015-02-06 19:58:21 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_send_cmd(rig, index);
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-12-24 16:02:47 +00:00
|
|
|
int index;
|
2019-11-30 16:19:08 +00:00
|
|
|
ptt_t ptt_response = -1;
|
|
|
|
int retries = rig->state.rigport.retry;
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
|
|
|
switch (ptt)
|
|
|
|
{
|
|
|
|
case RIG_PTT_ON:
|
|
|
|
index = FT817_NATIVE_CAT_PTT_ON;
|
|
|
|
break;
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_PTT_OFF:
|
|
|
|
index = FT817_NATIVE_CAT_PTT_OFF;
|
|
|
|
break;
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
do
|
|
|
|
{
|
2019-12-24 16:02:47 +00:00
|
|
|
int n;
|
2019-11-30 16:19:08 +00:00
|
|
|
n = ft817_send_cmd(rig, index);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-09-08 20:14:34 +00:00
|
|
|
if (n < 0 && n != -RIG_ERJCTED)
|
|
|
|
{
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: send ptt cmd failed\n", __func__);
|
|
|
|
return n;
|
|
|
|
}
|
2015-02-06 19:58:21 +00:00
|
|
|
|
2021-09-08 20:14:34 +00:00
|
|
|
/* Read TX status it contains the PTT flag.
|
|
|
|
* Use TX_STATUS instead of ft817_get_ptt to skip the cache. */
|
|
|
|
n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (n < 0 && n != -RIG_ERJCTED)
|
|
|
|
{
|
2021-09-08 20:14:34 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: get ptt cmd failed\n", __func__);
|
2019-11-30 16:19:08 +00:00
|
|
|
return n;
|
|
|
|
}
|
2018-10-01 13:54:29 +00:00
|
|
|
|
2021-09-08 20:14:34 +00:00
|
|
|
/* Should be in cache now! But if above command was rejected
|
|
|
|
* we will still try again here. */
|
|
|
|
n = ft817_get_ptt(rig, vfo, &ptt_response);
|
2021-11-28 18:41:10 +00:00
|
|
|
|
2021-09-08 20:14:34 +00:00
|
|
|
if (n < 0 && n != -RIG_ERJCTED)
|
2019-11-30 16:19:08 +00:00
|
|
|
{
|
2021-09-08 20:14:34 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "%s: get ptt cmd failed\n", __func__);
|
|
|
|
return n;
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
2018-10-01 13:54:29 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (ptt_response != ptt)
|
|
|
|
{
|
2021-09-08 20:14:34 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE, "%s: ptt not requested level, retry\n", __func__);
|
2020-01-08 05:18:56 +00:00
|
|
|
hl_usleep(1000l *
|
2020-02-23 17:26:09 +00:00
|
|
|
FT817_RETRY_DELAY); // Wait before next try. Helps with slower rigs cloning FT817 protocol (e.g. MCHF)
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
2018-10-28 18:50:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
|
|
|
while (ptt_response != ptt && retries-- > 0);
|
2018-10-01 13:54:29 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (retries >= 0)
|
|
|
|
{
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (func)
|
|
|
|
{
|
|
|
|
case RIG_FUNC_LOCK:
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_LOCK_ON);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_LOCK_OFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
case RIG_FUNC_TONE:
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_ENC_ON);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
case RIG_FUNC_TSQL:
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_ON);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH - 1];
|
|
|
|
/* int n; */
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2020-03-23 12:52:01 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: set DCS code (%u)\n", code);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (code == 0)
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF);
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in the DCS code - the rig doesn't support separate codes... */
|
|
|
|
to_bcd_be(data, code, 4);
|
|
|
|
to_bcd_be(data + 2, code, 4);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* FT-817 does not have the DCS_ENC_ON command, so we just set the tone here */
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* if ((n = ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_DCS_CODE, data)) < 0) */
|
|
|
|
/* return n; */
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_DCS_ENC_ON); */
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_DCS_CODE, data);
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH - 1];
|
|
|
|
int n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2020-03-23 12:52:01 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: set DCS sql (%u)\n", code);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (code == 0)
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF);
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in the DCS code - the rig doesn't support separate codes... */
|
|
|
|
to_bcd_be(data, code, 4);
|
|
|
|
to_bcd_be(data + 2, code, 4);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_DCS_CODE, data)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_DCS_ON);
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH - 1];
|
|
|
|
int n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: set CTCSS tone (%.1f)\n", tone / 10.0);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (tone == 0)
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF);
|
|
|
|
}
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in the CTCSS freq - the rig doesn't support separate tones... */
|
|
|
|
to_bcd_be(data, tone, 4);
|
|
|
|
to_bcd_be(data + 2, tone, 4);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_CTCSS_FREQ, data)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_ENC_ON);
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH - 1];
|
|
|
|
int n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: set CTCSS sql (%.1f)\n", tone / 10.0);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (tone == 0)
|
|
|
|
{
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF);
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in the CTCSS freq - the rig doesn't support separate tones... */
|
|
|
|
to_bcd_be(data, tone, 4);
|
|
|
|
to_bcd_be(data + 2, tone, 4);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_CTCSS_FREQ, data)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_ON);
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
/* Note: this doesn't have effect unless FT817 is in FM mode
|
|
|
|
although the command is accepted in any mode.
|
|
|
|
*/
|
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: set repeter shift = %i\n", shift);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (shift)
|
|
|
|
{
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_RPT_SHIFT_NONE:
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_RPT_SHIFT_MINUS:
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_RPT_SHIFT_MINUS);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_RPT_SHIFT_PLUS:
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_RPT_SHIFT_PLUS);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return -RIG_EINVAL;
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH - 1];
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: set repeter offs = %li\n", offs);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in the offset freq */
|
|
|
|
to_bcd_be(data, offs / 10, 8);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_RPT_OFFSET, data);
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
unsigned char data[YAESU_CMD_LENGTH - 1];
|
|
|
|
int n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "ft817: set rit = %li)\n", rit);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* fill in the RIT freq */
|
|
|
|
data[0] = (rit < 0) ? 255 : 0;
|
|
|
|
data[1] = 0;
|
|
|
|
to_bcd_be(data + 2, labs(rit) / 10, 4);
|
2001-12-15 03:19:39 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if ((n = ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_CLAR_FREQ, data)) < 0)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
/* the rig rejects if these are repeated - don't confuse user with retcode */
|
|
|
|
if (rit == 0)
|
|
|
|
{
|
|
|
|
ft817_send_cmd(rig, FT817_NATIVE_CAT_CLAR_OFF);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ft817_send_cmd(rig, FT817_NATIVE_CAT_CLAR_ON);
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2001-12-15 03:19:39 +00:00
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
int ft817_set_powerstat(RIG *rig, powerstat_t status)
|
|
|
|
{
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (status)
|
|
|
|
{
|
|
|
|
case RIG_POWER_OFF:
|
|
|
|
return ft817_send_cmd(rig, FT817_NATIVE_CAT_PWR_OFF);
|
|
|
|
|
|
|
|
case RIG_POWER_ON:
|
2020-10-15 16:59:59 +00:00
|
|
|
// send 5 bytes first, snooze a bit, then PWR_ON
|
2020-10-15 20:44:43 +00:00
|
|
|
write_block(&rig->state.rigport,
|
2021-12-18 21:49:45 +00:00
|
|
|
ncmd[FT817_NATIVE_CAT_PWR_WAKE].nseq, YAESU_CMD_LENGTH);
|
2020-10-15 20:44:43 +00:00
|
|
|
hl_usleep(200 * 1000);
|
2021-12-18 21:49:45 +00:00
|
|
|
write_block(&rig->state.rigport, ncmd[FT817_NATIVE_CAT_PWR_ON].nseq,
|
2020-10-15 20:44:43 +00:00
|
|
|
YAESU_CMD_LENGTH);
|
2020-10-15 17:50:21 +00:00
|
|
|
return RIG_OK;
|
2019-11-30 16:19:08 +00:00
|
|
|
|
|
|
|
case RIG_POWER_STANDBY:
|
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (op)
|
|
|
|
{
|
2020-02-23 17:26:09 +00:00
|
|
|
int n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_OP_TOGGLE:
|
|
|
|
rig_force_cache_timeout(&((struct ft817_priv_data *)
|
|
|
|
rig->state.priv)->fm_status_tv);
|
2019-12-09 23:12:13 +00:00
|
|
|
n = ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB);
|
2020-01-08 05:18:56 +00:00
|
|
|
hl_usleep(100 * 1000); // rig needs a little time to do this
|
2019-11-30 16:19:08 +00:00
|
|
|
return n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: this function silently ignores the vfo args and just turns
|
|
|
|
split ON or OFF.
|
|
|
|
*/
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
|
2005-09-04 10:44:23 +00:00
|
|
|
{
|
2019-11-30 16:19:08 +00:00
|
|
|
int index, n;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
switch (split)
|
|
|
|
{
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_SPLIT_ON:
|
|
|
|
index = FT817_NATIVE_CAT_SPLIT_ON;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
case RIG_SPLIT_OFF:
|
|
|
|
index = FT817_NATIVE_CAT_SPLIT_OFF;
|
|
|
|
break;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
default:
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
n = ft817_send_cmd(rig, index);
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
if (n < 0 && n != -RIG_ERJCTED)
|
|
|
|
{
|
|
|
|
return n;
|
|
|
|
}
|
2005-09-04 10:44:23 +00:00
|
|
|
|
2019-11-30 16:19:08 +00:00
|
|
|
return RIG_OK;
|
2005-09-04 10:44:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-05 16:47:35 +00:00
|
|
|
|
|
|
|
/* FIXME: currently ignores mode and freq */
|
|
|
|
/*
|
|
|
|
No documentation on how to interpret it but the max number
|
|
|
|
of bars on the display is 10 and I measure:
|
|
|
|
8 bars = 5W
|
|
|
|
5 bars = 2.5W
|
|
|
|
3 bars = 1W
|
|
|
|
1 bar = 0.5W
|
|
|
|
*/
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power,
|
2021-11-28 18:41:10 +00:00
|
|
|
freq_t freq, rmode_t mode)
|
2008-01-05 16:47:35 +00:00
|
|
|
{
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
2019-11-30 16:19:08 +00:00
|
|
|
*mwpower = (int)(power * 6000);
|
2008-01-05 16:47:35 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* FIXME: currently ignores mode and freq */
|
2021-08-22 18:53:24 +00:00
|
|
|
static int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower,
|
2021-11-28 18:41:10 +00:00
|
|
|
freq_t freq, rmode_t mode)
|
2008-01-05 16:47:35 +00:00
|
|
|
{
|
2020-06-29 12:55:55 +00:00
|
|
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
|
2019-11-30 16:19:08 +00:00
|
|
|
*power = mwpower / 6000.0;
|
2008-01-05 16:47:35 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-04 10:44:23 +00:00
|
|
|
/* ---------------------------------------------------------------------- */
|