From 701d6bf477f784192684c8035cd874d10966a5e6 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Tue, 4 Mar 2025 14:41:31 -0600 Subject: [PATCH] Hopefully fix CODAN NGS set_freq/get_freq --- rigs/codan/codan.c | 29 ++++++++++++++++------------- rigs/codan/codan.h | 2 +- src/rig.c | 4 +++- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/rigs/codan/codan.c b/rigs/codan/codan.c index a311105d9..996d2c595 100644 --- a/rigs/codan/codan.c +++ b/rigs/codan/codan.c @@ -55,7 +55,7 @@ int codan_transaction(RIG *rig, char *cmd, int expected, char **result) // Seems the 2110 wants CR instead of LF if (rig->caps->rig_model == RIG_MODEL_CODAN_2110 || rig->caps->rig_model == RIG_MODEL_CODAN_NGT) { - SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s%c", cmd, 0x0d); + SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s%c%c", cmd, 0x0d, 0x0a); } else { @@ -170,7 +170,7 @@ int codan_init(RIG *rig) RETURNFUNC2(RIG_OK); } -int codan_set_freq_2110(RIG *rig, vfo_t vfo, freq_t freq) +int codan_set_freq_ngt(RIG *rig, vfo_t vfo, freq_t freq) { char cmd_buf[MAXCMDLEN]; int retval; @@ -179,7 +179,7 @@ int codan_set_freq_2110(RIG *rig, vfo_t vfo, freq_t freq) rig_strvfo(vfo), freq); // Purportedly can't do split so we just set VFOB=VFOA - SNPRINTF(cmd_buf, sizeof(cmd_buf), "\rfreq %.0f", freq / 1000); + SNPRINTF(cmd_buf, sizeof(cmd_buf), "\rfreq %.3f", freq / 1000); char *response = NULL; retval = codan_transaction(rig, cmd_buf, 0, &response); @@ -207,9 +207,9 @@ int codan_open(RIG *rig) codan_transaction(rig, "login", 1, &results); - if (rig->caps->rig_model == RIG_MODEL_CODAN_2110) + if (rig->caps->rig_model == RIG_MODEL_CODAN_NGT) { - codan_set_freq_2110(rig, RIG_VFO_A, 14074000.0); + codan_set_freq_ngt(rig, RIG_VFO_A, 14074000.0); } else { @@ -385,6 +385,9 @@ int codan_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) retval = sscanf(response, "FREQ: %lg", freq); + if (retval == 0) + retval = sscanf(response, "CHAN: %lg", freq); + *freq *= 1000; // returned freq is in kHz if (retval != 1) @@ -491,7 +494,7 @@ int codan_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) return RIG_OK; } -int codan_set_ptt_2110(RIG *rig, vfo_t vfo, ptt_t ptt) +int codan_set_ptt_ngs(RIG *rig, vfo_t vfo, ptt_t ptt) { int retval; char cmd_buf[MAXCMDLEN]; @@ -585,7 +588,7 @@ struct rig_caps codan_ngt_caps = RIG_MODEL(RIG_MODEL_CODAN_NGT), .model_name = "NGT", .mfg_name = "CODAN", - .version = BACKEND_VER ".2", + .version = BACKEND_VER ".3", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -635,7 +638,7 @@ struct rig_caps codan_ngt_caps = .rig_open = codan_open, - .set_freq = codan_set_freq, + .set_freq = codan_set_freq_ngt, .get_freq = codan_get_freq, .set_mode = codan_set_mode, .get_mode = codan_get_mode, @@ -650,7 +653,7 @@ struct rig_caps codan_2110_caps = RIG_MODEL(RIG_MODEL_CODAN_2110), .model_name = "2110", .mfg_name = "CODAN", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -699,13 +702,13 @@ struct rig_caps codan_2110_caps = .rig_open = codan_open, .rig_cleanup = codan_cleanup, - .set_freq = codan_set_freq_2110, + .set_freq = codan_set_freq, .get_freq = codan_get_freq, .set_mode = codan_set_mode, .get_mode = codan_get_mode, - .set_ptt = codan_set_ptt_2110, - .get_ptt = codan_get_ptt_2110, + .set_ptt = codan_set_ptt, + .get_ptt = codan_get_ptt, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS }; @@ -714,7 +717,7 @@ DECLARE_INITRIG_BACKEND(codan) rig_debug(RIG_DEBUG_VERBOSE, "%s: _init called\n", __func__); rig_register(&codan_envoy_caps); - rig_register(&codan_ngs_caps); + rig_register(&codan_ngt_caps); rig_register(&codan_2110_caps); rig_debug(RIG_DEBUG_VERBOSE, "%s: _init back from rig_register\n", __func__); diff --git a/rigs/codan/codan.h b/rigs/codan/codan.h index 96ae9e10d..2338be809 100644 --- a/rigs/codan/codan.h +++ b/rigs/codan/codan.h @@ -35,7 +35,7 @@ #define CODAN_DATA_LEN 64 extern struct rig_caps codan_envoy_caps; -extern struct rig_caps codan_ngs_caps; +extern struct rig_caps codan_ngt_caps; extern struct rig_caps codan_2021_caps; struct codan_priv_data { diff --git a/src/rig.c b/src/rig.c index 6e772fcf0..c016f30f4 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1551,9 +1551,11 @@ int HAMLIB_API rig_open(RIG *rig) if (ICOM_EXCEPTIONS) { myvfo = RIG_VFO_MAIN_A; } + if ((STATE(rig)->vfo_list & RIG_VFO_VFO) == RIG_VFO_VFO) { myvfo = RIG_VFO_VFO; } + retval = rig_get_freq(rig, myvfo, &freq); - if (retval == RIG_OK && rig->caps->rig_model != RIG_MODEL_F6K) + if (retval == RIG_OK && rig->caps->rig_model != RIG_MODEL_F6K && ((STATE(rig)->vfo_list & RIG_VFO_VFO) == RIG_VFO_VFO)) { split_t split = RIG_SPLIT_OFF; vfo_t tx_vfo = RIG_VFO_NONE;