Skip to content

Commit

Permalink
Fix error in k3.c and make k3_get_vfo work with VFOB
Browse files Browse the repository at this point in the history
  • Loading branch information
mdblack98 committed Feb 28, 2021
1 parent 1f23798 commit a568374
Showing 1 changed file with 15 additions and 48 deletions.
63 changes: 15 additions & 48 deletions rigs/kenwood/k3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,15 +1021,29 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
/* The K3 is not limited to specific filter widths so we can query
* the actual bandwidth using the BW command
*/
if (vfo == RIG_VFO_B)
{
err = kenwood_safe_transaction(rig, "BW$", buf, KENWOOD_MAX_BUF_LEN, 7);
}
else
{
err = kenwood_safe_transaction(rig, "BW", buf, KENWOOD_MAX_BUF_LEN, 6);
}

if (err != RIG_OK)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: Cannot read K3 BW value\n", __func__);
return err;
}

*width = atoi(&buf[2]) * 10;
if (vfo == RIG_VFO_B)
{
*width = atoi(&buf[3]) * 10;
}
else
{
*width = atoi(&buf[2]) * 10;
}

return RIG_OK;
}
Expand Down Expand Up @@ -1165,53 +1179,6 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return RIG_OK;
}

int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
char *cmd = "MD";
int offset = 2;
int retval;
char buf[KENWOOD_MAX_BUF_LEN];
int kmode;

ENTERFUNC;

// get our mode
if (vfo == RIG_VFO_B)
{
cmd = "MD$";
offset = 3;
}
retval = kenwood_safe_transaction(rig, cmd, buf, KENWOOD_MAX_BUF_LEN, offset + 1);
if (retval != RIG_OK)
{
RETURNFUNC(retval);
}
if (buf[offset] <= '9')
{
kmode = buf[offset] - '0';
}
else
{
kmode = buf[offset] - 'A' + 10;
}

struct kenwood_priv_caps *caps = kenwood_caps(rig);
*mode = kenwood2rmode(kmode, caps->mode_table);

// now we get the bandwidth
cmd = "BW";
retval = kenwood_safe_transaction(rig, cmd, buf, KENWOOD_MAX_BUF_LEN, 7);
if (retval != RIG_OK)
{
RETURNFUNC(retval);
}
int twidth = 0;
sscanf(buf,"BW%d",&twidth);
*width = twidth;

RETURNFUNC(RIG_OK);
}

/* Elecraft rigs don't really know about swappings vfos.
* We just emulate them so rigctl can work correctly.
*/
Expand Down

0 comments on commit a568374

Please sign in to comment.