diff --git a/rigs/kenwood/elecraft.c b/rigs/kenwood/elecraft.c index ad3d41712..077a4aa44 100644 --- a/rigs/kenwood/elecraft.c +++ b/rigs/kenwood/elecraft.c @@ -165,6 +165,18 @@ int elecraft_open(RIG *rig) } } + if (rig->caps->rig_model != RIG_MODEL_XG3) // XG3 doesn't have extended + { + // turn on k2 extended to get PC values in more resolution + err = kenwood_transaction(rig, "K22;", NULL, 0); + + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: error setting K22='%s'...continuing\n", __func__, + rigerror(err)); + } + } + switch (rig->caps->rig_model) { case RIG_MODEL_K2: @@ -310,8 +322,8 @@ int elecraft_open(RIG *rig) kenwood_get_trn(rig, &priv->trn_state); /* ignore errors */ /* Currently we cannot cope with AI mode so turn it off in case last client left it on */ - kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case - it's not supported */ + kenwood_set_trn(rig, + RIG_TRN_OFF); /* ignore status in case it's not supported */ } // For rigs like K3X vfo emulation need to set VFO_A to start diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index 3847cd814..a9b0a1f6d 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -160,7 +160,8 @@ int kx3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); int kx3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); int k3_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); int k3_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); -int k3_power2mW(RIG *rig, unsigned int *mwpower, float power, freq_t freq, rmode_t mode); +int k3_power2mW(RIG *rig, unsigned int *mwpower, float power, freq_t freq, + rmode_t mode); /* Private helper functions */ int set_rit_xit(RIG *rig, shortfreq_t rit); @@ -1825,6 +1826,7 @@ static int k3_get_maxpower(RIG *rig) break; } } + #endif rig_debug(RIG_DEBUG_TRACE, "%s: maxpower=%d\n", __func__, maxpower); @@ -1944,8 +1946,9 @@ int k3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) break; case RIG_LEVEL_RFPOWER: - SNPRINTF(levelbuf, sizeof(levelbuf), "PC%03d", - (int)(val.f * k3_get_maxpower(rig))); + kenwood_val = (int)(val.f * k3_get_maxpower(rig)); + SNPRINTF(levelbuf, sizeof(levelbuf), "PC%03d%s", kenwood_val, + kenwood_val > 15 ? "1" : "0"); break; default: @@ -2247,7 +2250,15 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_EPROTO; } - val->f = (float) lvl / k3_get_maxpower(rig); + // extended K22 format PCnnnx where 0=.1W units and 1=1W units + if (len == 6 && levelbuf[5] == '0') + { + val->f = (float) lvl / 10.0 / k3_get_maxpower(rig); + } + else + { + val->f = (float) lvl / k3_get_maxpower(rig); + } break; diff --git a/simulators/simelecraft.c b/simulators/simelecraft.c index 661095a92..ea82a0a3a 100644 --- a/simulators/simelecraft.c +++ b/simulators/simelecraft.c @@ -132,7 +132,8 @@ int main(int argc, char *argv[]) { printf("%s\n", buf); usleep(50 * 1000); - pbuf = "IF059014200000+000000700000;"; + //pbuf = "IF059014200000+000000700000;"; + pbuf = "IF00007230000 -000000 0001000001 ;" ; n = write(fd, pbuf, strlen(pbuf)); printf("n=%d\n", n); @@ -280,7 +281,7 @@ int main(int argc, char *argv[]) } else if (strncmp(buf, "PC;", 3) == 0) { - SNPRINTF(buf, sizeof(buf), "PC005;"); + SNPRINTF(buf, sizeof(buf), "PC0150;"); n = write(fd, buf, strlen(buf)); } else if (strlen(buf) > 0)