Allow the ft757gx to work with WSJT-X.

Adds a new config param "-C fakefreq=1"

The ft757gx only has one-way comm so this simply returns the last freq
set.

WSJT-X can operate in fake it split mode with this too.

RRR
Mike W9MDB
This commit is contained in:
Michael Black 2016-02-23 11:50:30 -06:00 committed by Nate Bargmann
parent 97594e1c96
commit 99cbb5b1ad
2 changed files with 88 additions and 23 deletions

View File

@ -49,24 +49,6 @@
#include "yaesu.h" #include "yaesu.h"
#include "ft757gx.h" #include "ft757gx.h"
/* HAVE_SSLEEP is defined when Windows Sleep is found
* HAVE_SLEEP is defined when POSIX sleep is found
* _WIN32 is defined when compiling with MinGW
*
* When cross-compiling from POSIX to Windows using MinGW, HAVE_SLEEP
* will often be defined by configure although it is not supported by
* MinGW. So substitute the sleep definition below in such a case and
* when compiling on Windows using MinGW where HAVE_SLEEP will be
* undefined.
*
* FIXME: Needs better handling for all versions of MinGW.
*
*/
#if (defined(HAVE_SSLEEP) || defined(_WIN32)) && (!defined(HAVE_SLEEP))
#include "hl_sleep.h"
#endif
/* Private helper function prototypes */ /* Private helper function prototypes */
static int ft757_get_update_data(RIG *rig); static int ft757_get_update_data(RIG *rig);
static int mode2rig(RIG *rig, rmode_t mode, pbwidth_t width); static int mode2rig(RIG *rig, rmode_t mode, pbwidth_t width);
@ -82,8 +64,19 @@ struct ft757_priv_data {
unsigned int read_update_delay; /* depends on pacing value */ unsigned int read_update_delay; /* depends on pacing value */
unsigned char current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A or RIG_VFO_B only */ unsigned char current_vfo; /* active VFO from last cmd , can be either RIG_VFO_A or RIG_VFO_B only */
unsigned char update_data[FT757GX_STATUS_UPDATE_DATA_LENGTH]; /* returned data */ unsigned char update_data[FT757GX_STATUS_UPDATE_DATA_LENGTH]; /* returned data */
double curfreq; /* for fake get_freq on 757G */
char fakefreq; /* 0=no fake, 1=fake get freq */
}; };
#define TOKEN_BACKEND(t) (t)
#define TOK_FAKEFREQ TOKEN_BACKEND(1)
const struct confparams ft757gx_cfg_params[] = {
{ TOK_FAKEFREQ, "fakefreq", "Fake get-freq", "Fake getting freq",
"0", RIG_CONF_CHECKBUTTON
},
{ RIG_CONF_END, NULL, }
};
/* /*
* ft757gx rig capabilities. * ft757gx rig capabilities.
@ -93,7 +86,7 @@ const struct rig_caps ft757gx_caps = {
.rig_model = RIG_MODEL_FT757, .rig_model = RIG_MODEL_FT757,
.model_name = "FT-757GX", .model_name = "FT-757GX",
.mfg_name = "Yaesu", .mfg_name = "Yaesu",
.version = "0.4.1", .version = "0.5.0",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_BETA, .status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_MOBILE, .rig_type = RIG_TYPE_MOBILE,
@ -178,14 +171,17 @@ const struct rig_caps ft757gx_caps = {
.rig_close = NULL, /* port closed */ .rig_close = NULL, /* port closed */
.set_freq = ft757_set_freq, /* set freq */ .set_freq = ft757_set_freq, /* set freq */
.get_freq = NULL, /* get freq */ .get_freq = ft757gx_get_freq, /* get freq */
.set_mode = NULL, /* set mode */ .set_mode = NULL, /* set mode */
.get_mode = NULL, /* get mode */ .get_mode = NULL, /* get mode */
.set_vfo = ft757_set_vfo, /* set vfo */ .set_vfo = ft757_set_vfo, /* set vfo */
.get_vfo = NULL, /* get vfo */
.set_ptt = NULL, /* set ptt */ .set_ptt = NULL, /* set ptt */
.get_ptt = NULL, /* get ptt */ .get_ptt = NULL, /* get ptt */
.cfgparams = ft757gx_cfg_params,
.set_conf = ft757gx_set_conf,
.get_conf = ft757gx_get_conf
}; };
/* /*
@ -319,6 +315,7 @@ int ft757_init(RIG *rig)
p = (struct ft757_priv_data * ) calloc(1, sizeof(struct ft757_priv_data)); p = (struct ft757_priv_data * ) calloc(1, sizeof(struct ft757_priv_data));
if (!p) /* whoops! memory shortage! */ if (!p) /* whoops! memory shortage! */
return -RIG_ENOMEM; return -RIG_ENOMEM;
p->curfreq = 1e6;
/* TODO: read pacing from preferences */ /* TODO: read pacing from preferences */
@ -383,6 +380,7 @@ int ft757_open(RIG *rig)
int ft757_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int ft757_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{ {
struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv;
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0a}; unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x0a};
rig_debug(RIG_DEBUG_VERBOSE, "%s called. Freq=%"PRIfreq"\n", __func__, freq); rig_debug(RIG_DEBUG_VERBOSE, "%s called. Freq=%"PRIfreq"\n", __func__, freq);
@ -393,6 +391,7 @@ int ft757_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
/* fill in first four bytes */ /* fill in first four bytes */
to_bcd(cmd, freq/10, BCD_LEN); to_bcd(cmd, freq/10, BCD_LEN);
priv->curfreq = freq;
return write_block(&rig->state.rigport, (char *)cmd, YAESU_CMD_LENGTH); return write_block(&rig->state.rigport, (char *)cmd, YAESU_CMD_LENGTH);
} }
@ -419,6 +418,16 @@ int ft757_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
} }
int ft757gx_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
struct ft757_priv_data *priv = (struct ft757_priv_data *)rig->state.priv;
if (priv->fakefreq) { // only return last freq set when fakeit is turned on
*freq = priv->curfreq;
return RIG_OK;
}
return RIG_ENAVAIL;
}
/* /*
* Return Freq * Return Freq
*/ */
@ -646,7 +655,7 @@ int ft757_get_update_data(RIG *rig)
__func__, retval, FT757GX_STATUS_UPDATE_DATA_LENGTH, __func__, retval, FT757GX_STATUS_UPDATE_DATA_LENGTH,
nbtries, maxtries); nbtries, maxtries);
/* The delay is quadratic. */ /* The delay is quadratic. */
sleep(nbtries*nbtries); usleep(nbtries*nbtries*1000000);
} }
if (retval != FT757GX_STATUS_UPDATE_DATA_LENGTH) { if (retval != FT757GX_STATUS_UPDATE_DATA_LENGTH) {
@ -737,3 +746,56 @@ int rig2mode(RIG *rig, int md, rmode_t *mode, pbwidth_t *width)
return RIG_OK; return RIG_OK;
} }
/*
* Assumes rig!=NULL, rig->state.priv!=NULL
*/
int ft757gx_get_conf(RIG *rig, token_t token, char *val)
{
struct ft757_priv_data *priv;
struct rig_state *rs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called.\n", __func__);
rs = &rig->state;
priv = (struct ft757_priv_data*)rs->priv;
switch(token) {
case TOK_FAKEFREQ:
sprintf(val,"%d",priv->fakefreq);
break;
default:
val = NULL;
return -RIG_EINVAL;
}
return RIG_OK;
}
/*
* Assumes rig!=NULL, rig->state.priv!=NULL
*/
int ft757gx_set_conf(RIG *rig, token_t token, const char *val)
{
struct ft757_priv_data *priv;
struct rig_state *rs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called. val=%s\n", __func__, val);
rs = &rig->state;
priv = (struct ft757_priv_data*)rs->priv;
switch(token) {
case TOK_FAKEFREQ:
priv->fakefreq = 0; // should only be 0 or 1 -- default to 0
if (val[0] != '0')
priv->fakefreq = 1;
rig_debug(RIG_DEBUG_VERBOSE, "fakefreq=%d\n", __func__, priv->fakefreq);
break;
default:
return -RIG_EINVAL;
}
return RIG_OK;
}

View File

@ -64,7 +64,6 @@
#define MODE_AM 0x04 #define MODE_AM 0x04
#define MODE_FM 0x05 #define MODE_FM 0x05
/* TODO: get better measure numbers */ /* TODO: get better measure numbers */
#define FT757GXII_STR_CAL { 2, { \ #define FT757GXII_STR_CAL { 2, { \
{ 0, -60 }, /* S0 -6dB */ \ { 0, -60 }, /* S0 -6dB */ \
@ -95,8 +94,12 @@ static int ft757_init(RIG *rig);
static int ft757_cleanup(RIG *rig); static int ft757_cleanup(RIG *rig);
static int ft757_open(RIG *rig); static int ft757_open(RIG *rig);
static int ft757gx_get_conf(RIG *rig, token_t token, char *val);
static int ft757gx_set_conf(RIG *rig, token_t token, const char *val);
static int ft757_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft757_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
static int ft757_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int ft757_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
static int ft757gx_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
static int ft757_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */ static int ft757_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */
static int ft757_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); /* get mode */ static int ft757_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); /* get mode */