From b2f1b1880af592442ba453a648fc168002f5affa Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 20 Jun 2020 20:38:46 +0200 Subject: [PATCH] uniden_get_freq_2 to use SG instead of RF for bc780xlt #313 - RF responds NG on bc780xlt - SG responds with the gain + the current frequency - SG is valid in manual mode, scan mode and search mode --- rigs/uniden/bc780.c | 2 +- rigs/uniden/uniden.c | 29 +++++++++++++++++++++++++++++ rigs/uniden/uniden.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/rigs/uniden/bc780.c b/rigs/uniden/bc780.c index e5b41b08a..b31f09ecb 100644 --- a/rigs/uniden/bc780.c +++ b/rigs/uniden/bc780.c @@ -129,7 +129,7 @@ const struct rig_caps bc780_caps = .priv = NULL, .set_freq = uniden_set_freq, - .get_freq = uniden_get_freq, + .get_freq = uniden_get_freq_2, .set_mode = uniden_set_mode, .get_mode = uniden_get_mode, .set_mem = uniden_set_mem, diff --git a/rigs/uniden/uniden.c b/rigs/uniden/uniden.c index 3e6b64793..249bd0b23 100644 --- a/rigs/uniden/uniden.c +++ b/rigs/uniden/uniden.c @@ -318,6 +318,35 @@ int uniden_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return RIG_OK; } +/* + * uniden_get_freq + * Assumes rig!=NULL + */ +int uniden_get_freq_2(RIG *rig, vfo_t vfo, freq_t *freq) +{ + char freqbuf[BUFSZ]; + size_t freq_len = BUFSZ; + int ret; + + ret = uniden_transaction(rig, "SG" EOM, 3, "S", freqbuf, &freq_len); + + if (ret != RIG_OK) + { + return ret; + } + + if (freq_len < 10) + { + return -RIG_EPROTO; + } + + sscanf(freqbuf + 6, "%"SCNfreq, freq); + /* returned freq in hundreds of Hz */ + *freq *= 100; + + return RIG_OK; +} + int uniden_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { const char *modebuf; diff --git a/rigs/uniden/uniden.h b/rigs/uniden/uniden.h index 2212dbc58..c36319813 100644 --- a/rigs/uniden/uniden.h +++ b/rigs/uniden/uniden.h @@ -58,6 +58,7 @@ int uniden_transaction (RIG *rig, const char *cmdstr, int cmd_len, const char *replystr, char *data, size_t *datasize); int uniden_set_freq(RIG *rig, vfo_t vfo, freq_t freq); int uniden_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +int uniden_get_freq_2(RIG *rig, vfo_t vfo, freq_t *freq); int uniden_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); int uniden_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); int uniden_set_mem(RIG *rig, vfo_t vfo, int ch);