From a42d408094d89599529abae3be84c5b6415a3792 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 5 Jun 2024 11:55:06 -0500 Subject: [PATCH] Update smartsdr --- rigs/flexradio/smartsdr.c | 35 +++++++++++++++++++++++++--------- rigs/flexradio/smartsdr_caps.h | 2 +- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/rigs/flexradio/smartsdr.c b/rigs/flexradio/smartsdr.c index 25710d11c..747da1e05 100644 --- a/rigs/flexradio/smartsdr.c +++ b/rigs/flexradio/smartsdr.c @@ -196,10 +196,12 @@ static int smartsdr_flush(RIG *rig) // for this flush routine we expect at least one message for sure -- might be more len = read_string(RIGPORT(rig), (unsigned char *)buf, buf_len, stopset, 1, 0, 1); + if (buf[0] == 'S') { smartsdr_parse_S(rig, buf); } rig_debug(RIG_DEBUG_VERBOSE, "%s: read %d bytes\n", __func__, len); #endif + do { buf[0] = 0; @@ -208,8 +210,8 @@ static int smartsdr_flush(RIG *rig) if (buf[0] == 'S') { smartsdr_parse_S(rig, buf); } else if (buf[0] == 'R') { sscanf(buf, "R%d", &retval); } - - else if (strlen(buf)>0) rig_debug(RIG_DEBUG_WARN, "%s: Unknown packet type=%s\n", __func__, buf); + + else if (strlen(buf) > 0) { rig_debug(RIG_DEBUG_WARN, "%s: Unknown packet type=%s\n", __func__, buf); } } while (len > 0); @@ -228,11 +230,14 @@ static int smartsdr_transaction(RIG *rig, char *buf) { sprintf(cmd, "C%d|%s%c", priv->seqnum++, buf, 0x0a); retval = write_block(RIGPORT(rig), (unsigned char *) cmd, strlen(cmd)); + if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: SmartSDR write_block err=0x%x\n", __func__, retval); + rig_debug(RIG_DEBUG_ERR, "%s: SmartSDR write_block err=0x%x\n", __func__, + retval); } } + retval = smartsdr_flush(rig); if (retval != 0) @@ -373,10 +378,16 @@ int smartsdr_set_freq(RIG *rig, vfo_t vfo, freq_t freq) smartsdr_transaction(rig, cmd); rig_debug(RIG_DEBUG_VERBOSE, "%s: set_freq answer: %s", __func__, buf); rig_set_cache_freq(rig, vfo, freq); + if (vfo == RIG_VFO_A) - priv->freqA = freq; + { + priv->freqA = freq; + } else - priv->freqB = freq; + { + priv->freqB = freq; + } + RETURNFUNC(RIG_OK); } @@ -394,6 +405,7 @@ static int smartsdr_parse_S(RIG *rig, char *s) do { rig_debug(RIG_DEBUG_VERBOSE, "%s: parsing '%s'\n", __func__, p); + if (sscanf(p, "RF_frequency=%lf", &freq) == 1) { priv->freqA = freq * 1e6; @@ -436,8 +448,8 @@ static int smartsdr_parse_S(RIG *rig, char *s) } else if (sscanf(p, "state=%s\n", state) == 1) { - if (strcmp(state,"TRANSMITTING")==0) priv->ptt = 1; - else priv->ptt = 0; + if (strcmp(state, "TRANSMITTING") == 0) { priv->ptt = 1; } + else { priv->ptt = 0; } } } while ((p = strtok(NULL, sep))); @@ -459,10 +471,15 @@ int smartsdr_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) //sprintf(cmd, "sub slice %d", priv->slicenum); //sprintf(cmd, "info"); smartsdr_transaction(rig, NULL); + if (vfo == RIG_VFO_A) - *freq = priv->freqA; + { + *freq = priv->freqA; + } else - *freq = priv->freqB; + { + *freq = priv->freqB; + } RETURNFUNC(RIG_OK); } diff --git a/rigs/flexradio/smartsdr_caps.h b/rigs/flexradio/smartsdr_caps.h index e5df3ba96..07a5f8c05 100644 --- a/rigs/flexradio/smartsdr_caps.h +++ b/rigs/flexradio/smartsdr_caps.h @@ -1,5 +1,5 @@ .mfg_name = "Flex-radio", - .version = "20240604.0", + .version = "20240605.0", .copyright = "LGPL", .status = RIG_STATUS_BETA, .rig_type = RIG_TYPE_TRANSCEIVER,