Skip to content

Commit

Permalink
Fix KX3 set_vfo
Browse files Browse the repository at this point in the history
KX4 set_vfo may not work
#563
  • Loading branch information
mdblack98 committed Feb 27, 2021
1 parent 4f98d34 commit b2a1955
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
17 changes: 13 additions & 4 deletions rigs/kenwood/elecraft.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ int elecraft_open(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s: K2 level is %d, %s\n", __func__,
priv->k2_ext_lvl, elec_ext_id_str_lst[priv->k2_ext_lvl].id);

priv->is_k2 = 1;
break;

case RIG_MODEL_K3:
Expand All @@ -192,6 +193,9 @@ int elecraft_open(RIG *rig)
priv->has_kpa3 = 0;

if (strstr(buf, "P")) { priv->has_kpa3 = 1; }
if (strstr(buf, "R")) { priv->is_k3s = 1; }
else if (strncmp(&buf[13],"--",2)==0) { priv->is_k3 = 1; }
else if (strncmp(&buf[11],"----",4)==0) { priv->is_k4 = 1; }

if (buf[13] == '0') // then we have a KX3 or KX2
{
Expand All @@ -200,9 +204,15 @@ int elecraft_open(RIG *rig)

switch (modelnum)
{
case '1': model = "KX2"; break;
case '1':
model = "KX2";
priv->is_kx2 = 1;
break;

case '2': model = "KX3"; break;
case '2':
model = "KX3";
priv->is_kx3 = 1;
break;

default:
rig_debug(RIG_DEBUG_ERR, "%s: Unknown Elecraft modelnum=%c, expected 1 or 2\n",
Expand All @@ -219,8 +229,7 @@ int elecraft_open(RIG *rig)
if (strstr(buf, "R")) { model = "K3S"; }
}

rig_debug(RIG_DEBUG_TRACE, "%s: model=%s, kpa3%d\n", __func__, model,
priv->has_kpa3);
rig_debug(RIG_DEBUG_TRACE, "%s: model=%s, is_k2=%d, is_k3=%d, is_k3s=%d, is_kx3=%d, is_kx2=%d, is_k4=%d, kpa3=%d\n", __func__, model, priv->is_k2, priv->is_k3, priv->is_k3s, priv->is_kx3, priv->is_kx2, priv->is_k4, priv->has_kpa3);

err = elecraft_get_extension_level(rig, "K2", &priv->k2_ext_lvl);

Expand Down
22 changes: 17 additions & 5 deletions rigs/kenwood/k3.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ const struct rig_caps kx3_caps =
.mfg_name = "Elecraft",
.version = BACKEND_VER ".4",
.copyright = "LGPL",
.status = RIG_STATUS_BETA,
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
Expand Down Expand Up @@ -1160,15 +1160,18 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)

/* The K3 changes "VFOs" by swapping the contents of
* the upper display with the lower display. This function
* accomplishes this by sending the emulation command, SWT11;
* accomplishes this by sending the emulation command, SWT11, KX3 is SWT24;
* to the K3 to emulate a tap of the A/B button.
*/

int k3_set_vfo(RIG *rig, vfo_t vfo)
{
int err;
// Does SWT11 work for the K4 or do we need to emulate set/get vfo?
char *cmd = "SWT11";
struct kenwood_priv_data *priv = rig->state.priv;

rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
ENTERFUNC;

// vfo is toggle so we check first to see if we need to switch
vfo_t tvfo;
Expand All @@ -1181,20 +1184,29 @@ int k3_set_vfo(RIG *rig, vfo_t vfo)

if (tvfo == vfo) RETURNFUNC(RIG_OK);

err = kenwood_transaction(rig, "SWT11", NULL, 0);
if (priv->is_kx3)
{
cmd = "SWT24";
}
else if (priv->is_k4)
{
cmd = "AB2";
}
err = kenwood_transaction(rig, cmd, NULL, 0);

if (err != RIG_OK)
{
RETURNFUNC(err);
}

return RIG_OK;
RETURNFUNC(RIG_OK);
}

int k3_get_vfo(RIG *rig, vfo_t *vfo)
{
char buf[KENWOOD_MAX_BUF_LEN];
int ret;
struct kenwood_priv_data *priv = rig->state.priv;

ret = write_block(&rig->state.rigport, "IC;", 3);

Expand Down
6 changes: 6 additions & 0 deletions rigs/kenwood/kenwood.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ struct kenwood_priv_data
int has_rit2; /* rig has set 2 rit command */
int ag_format; /* which AG command is being used...see LEVEL_AF in kenwood.c*/
int micgain_min, micgain_max; /* varies by rig so we figure it out automagically */
int is_k2;
int is_k3;
int is_k3s;
int is_kx3;
int is_kx2;
int is_k4;
};


Expand Down

0 comments on commit b2a1955

Please sign in to comment.