diff --git a/rigs/aor/aor.c b/rigs/aor/aor.c
index 6c2dd0450..d69fc9332 100644
--- a/rigs/aor/aor.c
+++ b/rigs/aor/aor.c
@@ -642,7 +642,8 @@ int aor_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
/* should be caught by the front end */
- if ((val.i != 0) && (i >= HAMLIB_MAXDBLSTSIZ || RIG_IS_DBLST_END(rs->attenuator[i])))
+ if ((val.i != 0) && (i >= HAMLIB_MAXDBLSTSIZ
+ || RIG_IS_DBLST_END(rs->attenuator[i])))
{
return -RIG_EINVAL;
}
diff --git a/rigs/aor/sr2200.c b/rigs/aor/sr2200.c
index 954568a0b..63033e055 100644
--- a/rigs/aor/sr2200.c
+++ b/rigs/aor/sr2200.c
@@ -648,7 +648,8 @@ int sr2200_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
}
/* should be caught by the front end */
- if ((val.i != 0) && (i >= HAMLIB_MAXDBLSTSIZ || RIG_IS_DBLST_END(rs->attenuator[i])))
+ if ((val.i != 0) && (i >= HAMLIB_MAXDBLSTSIZ
+ || RIG_IS_DBLST_END(rs->attenuator[i])))
{
return -RIG_EINVAL;
}
diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c
index 1e20ddb65..1bc0a4cee 100644
--- a/rigs/dummy/dummy.c
+++ b/rigs/dummy/dummy.c
@@ -396,15 +396,15 @@ static int dummy_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s\n", __func__,
rig_strvfo(vfo), fstr);
- switch(vfo)
+ switch (vfo)
{
- case RIG_VFO_MAIN:
- case RIG_VFO_A: priv->vfo_a.freq = freq;break;
+ case RIG_VFO_MAIN:
+ case RIG_VFO_A: priv->vfo_a.freq = freq; break;
- case RIG_VFO_SUB:
- case RIG_VFO_B: priv->vfo_b.freq = freq;break;
+ case RIG_VFO_SUB:
+ case RIG_VFO_B: priv->vfo_b.freq = freq; break;
- case RIG_VFO_C: priv->vfo_c.freq = freq;break;
+ case RIG_VFO_C: priv->vfo_c.freq = freq; break;
}
if (!priv->split)
@@ -470,11 +470,11 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
switch (vfo)
{
- case RIG_VFO_A: priv->vfo_a.mode = mode; priv->vfo_a.width = width;break;
+ case RIG_VFO_A: priv->vfo_a.mode = mode; priv->vfo_a.width = width; break;
- case RIG_VFO_B: priv->vfo_b.mode = mode; priv->vfo_b.width = width;break;
+ case RIG_VFO_B: priv->vfo_b.mode = mode; priv->vfo_b.width = width; break;
- case RIG_VFO_C: priv->vfo_c.mode = mode; priv->vfo_c.width = width;break;
+ case RIG_VFO_C: priv->vfo_c.mode = mode; priv->vfo_c.width = width; break;
}
if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); }
@@ -483,6 +483,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
width = curr->width = rig_passband_normal(rig, mode);
}
+
switch (vfo)
{
case RIG_VFO_A: priv->vfo_a.width = width; break;
@@ -504,17 +505,17 @@ static int dummy_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
usleep(CMDSLEEP);
rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rig_strvfo(vfo));
- if (vfo == RIG_VFO_CURR) vfo = rig->state.current_vfo;
+ if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
- switch(vfo)
+ switch (vfo)
{
- case RIG_VFO_MAIN:
- case RIG_VFO_A: *mode = priv->vfo_a.mode;*width = priv->vfo_a.width; break;
+ case RIG_VFO_MAIN:
+ case RIG_VFO_A: *mode = priv->vfo_a.mode; *width = priv->vfo_a.width; break;
- case RIG_VFO_SUB:
- case RIG_VFO_B: *mode = priv->vfo_b.mode;*width = priv->vfo_b.width; break;
+ case RIG_VFO_SUB:
+ case RIG_VFO_B: *mode = priv->vfo_b.mode; *width = priv->vfo_b.width; break;
- case RIG_VFO_C: *mode = priv->vfo_c.mode;*width = priv->vfo_c.width; break;
+ case RIG_VFO_C: *mode = priv->vfo_c.mode; *width = priv->vfo_c.width; break;
}
RETURNFUNC(RIG_OK);
@@ -530,7 +531,7 @@ static int dummy_set_vfo(RIG *rig, vfo_t vfo)
usleep(CMDSLEEP);
rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rig_strvfo(vfo));
- if (vfo == RIG_VFO_CURR) vfo = rig->state.current_vfo;
+ if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
priv->last_vfo = priv->curr_vfo;
priv->curr_vfo = vfo;
@@ -2122,7 +2123,7 @@ struct rig_caps dummy_caps =
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_OTHER,
- .targetable_vfo = RIG_TARGETABLE_PTT | RIG_TARGETABLE_RITXIT|RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE,
+ .targetable_vfo = RIG_TARGETABLE_PTT | RIG_TARGETABLE_RITXIT | RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_NONE,
@@ -2287,7 +2288,7 @@ struct rig_caps dummy_no_vfo_caps =
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_OTHER,
- .targetable_vfo = RIG_TARGETABLE_PTT | RIG_TARGETABLE_RITXIT|RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE,
+ .targetable_vfo = RIG_TARGETABLE_PTT | RIG_TARGETABLE_RITXIT | RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_NONE,
diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c
index 1082e3b2a..5dc5bfd10 100644
--- a/rigs/dummy/flrig.c
+++ b/rigs/dummy/flrig.c
@@ -71,7 +71,7 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
- pbwidth_t width);
+ pbwidth_t width);
static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
static int flrig_get_vfo(RIG *rig, vfo_t *vfo);
static int flrig_set_vfo(RIG *rig, vfo_t vfo);
@@ -80,138 +80,138 @@ static int flrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq);
static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq);
static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
- vfo_t tx_vfo);
+ vfo_t tx_vfo);
static int flrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
- vfo_t *tx_vfo);
+ vfo_t *tx_vfo);
static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
- rmode_t mode, pbwidth_t width);
+ rmode_t mode, pbwidth_t width);
static int flrig_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *freq,
- rmode_t *mode, pbwidth_t *width);
+ rmode_t *mode, pbwidth_t *width);
static int flrig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
static int flrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
static const char *flrig_get_info(RIG *rig);
static int flrig_power2mW(RIG *rig, unsigned int *mwpower, float power,
- freq_t freq, rmode_t mode);
+ freq_t freq, rmode_t mode);
static int flrig_mW2power(RIG *rig, float *power, unsigned int mwpower,
- freq_t freq, rmode_t mode);
+ freq_t freq, rmode_t mode);
struct flrig_priv_data
{
- vfo_t curr_vfo;
- char bandwidths[MAXBANDWIDTHLEN]; /* pipe delimited set returned from flrig */
- int nbandwidths;
- char info[8192];
- ptt_t ptt;
- split_t split;
- rmode_t curr_modeA;
- rmode_t curr_modeB;
- freq_t curr_freqA;
- freq_t curr_freqB;
- pbwidth_t curr_widthA;
- pbwidth_t curr_widthB;
- int has_get_modeA; /* True if this function is available */
- int has_get_bwA; /* True if this function is available */
- float powermeter_scale; /* So we can scale power meter to 0-1 */
+ vfo_t curr_vfo;
+ char bandwidths[MAXBANDWIDTHLEN]; /* pipe delimited set returned from flrig */
+ int nbandwidths;
+ char info[8192];
+ ptt_t ptt;
+ split_t split;
+ rmode_t curr_modeA;
+ rmode_t curr_modeB;
+ freq_t curr_freqA;
+ freq_t curr_freqB;
+ pbwidth_t curr_widthA;
+ pbwidth_t curr_widthB;
+ int has_get_modeA; /* True if this function is available */
+ int has_get_bwA; /* True if this function is available */
+ float powermeter_scale; /* So we can scale power meter to 0-1 */
};
const struct rig_caps flrig_caps =
{
- RIG_MODEL(RIG_MODEL_FLRIG),
- .model_name = "FLRig",
- .mfg_name = "FLRig",
- .version = BACKEND_VER ".0",
- .copyright = "LGPL",
- .status = RIG_STATUS_STABLE,
- .rig_type = RIG_TYPE_TRANSCEIVER,
- .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
- .ptt_type = RIG_PTT_RIG,
- .port_type = RIG_PORT_NETWORK,
- .write_delay = 0,
- .post_write_delay = 0,
- .timeout = 5000,
- .retry = 5,
+ RIG_MODEL(RIG_MODEL_FLRIG),
+ .model_name = "FLRig",
+ .mfg_name = "FLRig",
+ .version = BACKEND_VER ".0",
+ .copyright = "LGPL",
+ .status = RIG_STATUS_STABLE,
+ .rig_type = RIG_TYPE_TRANSCEIVER,
+ .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE,
+ .ptt_type = RIG_PTT_RIG,
+ .port_type = RIG_PORT_NETWORK,
+ .write_delay = 0,
+ .post_write_delay = 0,
+ .timeout = 5000,
+ .retry = 5,
- .has_get_func = RIG_FUNC_NONE,
- .has_set_func = RIG_FUNC_NONE,
- .has_get_level = FLRIG_LEVELS,
- .has_set_level = RIG_LEVEL_SET(FLRIG_LEVELS),
- .has_get_parm = RIG_PARM_NONE,
- .has_set_parm = RIG_PARM_NONE,
- .filters = {
- RIG_FLT_END
- },
+ .has_get_func = RIG_FUNC_NONE,
+ .has_set_func = RIG_FUNC_NONE,
+ .has_get_level = FLRIG_LEVELS,
+ .has_set_level = RIG_LEVEL_SET(FLRIG_LEVELS),
+ .has_get_parm = RIG_PARM_NONE,
+ .has_set_parm = RIG_PARM_NONE,
+ .filters = {
+ RIG_FLT_END
+ },
- .rx_range_list1 = {{
- .startf = kHz(1), .endf = GHz(10), .modes = FLRIG_MODES,
- .low_power = -1, .high_power = -1, FLRIG_VFOS, RIG_ANT_1
- },
- RIG_FRNG_END,
- },
- .tx_range_list1 = {RIG_FRNG_END,},
- .rx_range_list2 = {{
- .startf = kHz(1), .endf = GHz(10), .modes = FLRIG_MODES,
- .low_power = -1, .high_power = -1, FLRIG_VFOS, RIG_ANT_1
- },
- RIG_FRNG_END,
- },
- .tx_range_list2 = {RIG_FRNG_END,},
- .tuning_steps = { {FLRIG_MODES, 1}, {FLRIG_MODES, RIG_TS_ANY}, RIG_TS_END, },
- .priv = NULL, /* priv */
+ .rx_range_list1 = {{
+ .startf = kHz(1), .endf = GHz(10), .modes = FLRIG_MODES,
+ .low_power = -1, .high_power = -1, FLRIG_VFOS, RIG_ANT_1
+ },
+ RIG_FRNG_END,
+ },
+ .tx_range_list1 = {RIG_FRNG_END,},
+ .rx_range_list2 = {{
+ .startf = kHz(1), .endf = GHz(10), .modes = FLRIG_MODES,
+ .low_power = -1, .high_power = -1, FLRIG_VFOS, RIG_ANT_1
+ },
+ RIG_FRNG_END,
+ },
+ .tx_range_list2 = {RIG_FRNG_END,},
+ .tuning_steps = { {FLRIG_MODES, 1}, {FLRIG_MODES, RIG_TS_ANY}, RIG_TS_END, },
+ .priv = NULL, /* priv */
- .rig_init = flrig_init,
- .rig_open = flrig_open,
- .rig_close = flrig_close,
- .rig_cleanup = flrig_cleanup,
+ .rig_init = flrig_init,
+ .rig_open = flrig_open,
+ .rig_close = flrig_close,
+ .rig_cleanup = flrig_cleanup,
- .set_freq = flrig_set_freq,
- .get_freq = flrig_get_freq,
- .set_mode = flrig_set_mode,
- .get_mode = flrig_get_mode,
- .set_vfo = flrig_set_vfo,
- .get_vfo = flrig_get_vfo,
- .get_info = flrig_get_info,
- .set_ptt = flrig_set_ptt,
- .get_ptt = flrig_get_ptt,
- .set_split_mode = flrig_set_split_mode,
- .set_split_freq = flrig_set_split_freq,
- .get_split_freq = flrig_get_split_freq,
- .set_split_vfo = flrig_set_split_vfo,
- .get_split_vfo = flrig_get_split_vfo,
- .set_split_freq_mode = flrig_set_split_freq_mode,
- .get_split_freq_mode = flrig_get_split_freq_mode,
- .set_level = flrig_set_level,
- .get_level = flrig_get_level,
- .power2mW = flrig_power2mW,
- .mW2power = flrig_mW2power
+ .set_freq = flrig_set_freq,
+ .get_freq = flrig_get_freq,
+ .set_mode = flrig_set_mode,
+ .get_mode = flrig_get_mode,
+ .set_vfo = flrig_set_vfo,
+ .get_vfo = flrig_get_vfo,
+ .get_info = flrig_get_info,
+ .set_ptt = flrig_set_ptt,
+ .get_ptt = flrig_get_ptt,
+ .set_split_mode = flrig_set_split_mode,
+ .set_split_freq = flrig_set_split_freq,
+ .get_split_freq = flrig_get_split_freq,
+ .set_split_vfo = flrig_set_split_vfo,
+ .get_split_vfo = flrig_get_split_vfo,
+ .set_split_freq_mode = flrig_set_split_freq_mode,
+ .get_split_freq_mode = flrig_get_split_freq_mode,
+ .set_level = flrig_set_level,
+ .get_level = flrig_get_level,
+ .power2mW = flrig_power2mW,
+ .mW2power = flrig_mW2power
};
//Structure for mapping flrig dynmamic modes to hamlib modes
//flrig displays modes as the rig displays them
struct s_modeMap
{
- rmode_t mode_hamlib;
- char *mode_flrig;
+ rmode_t mode_hamlib;
+ char *mode_flrig;
};
//FLRig will provide us the modes for the selected rig
//We will then put them in this struct
static struct s_modeMap modeMap[] =
{
- {RIG_MODE_USB, NULL},
- {RIG_MODE_LSB, NULL},
- {RIG_MODE_PKTUSB, NULL},
- {RIG_MODE_PKTLSB, NULL},
- {RIG_MODE_AM, NULL},
- {RIG_MODE_FM, NULL},
- {RIG_MODE_FMN, NULL},
- {RIG_MODE_WFM, NULL},
- {RIG_MODE_CW, NULL},
- {RIG_MODE_CWR, NULL},
- {RIG_MODE_RTTY, NULL},
- {RIG_MODE_RTTYR, NULL},
- {RIG_MODE_C4FM, NULL},
- {0, NULL}
+ {RIG_MODE_USB, NULL},
+ {RIG_MODE_LSB, NULL},
+ {RIG_MODE_PKTUSB, NULL},
+ {RIG_MODE_PKTLSB, NULL},
+ {RIG_MODE_AM, NULL},
+ {RIG_MODE_FM, NULL},
+ {RIG_MODE_FMN, NULL},
+ {RIG_MODE_WFM, NULL},
+ {RIG_MODE_CW, NULL},
+ {RIG_MODE_CWR, NULL},
+ {RIG_MODE_RTTY, NULL},
+ {RIG_MODE_RTTYR, NULL},
+ {RIG_MODE_C4FM, NULL},
+ {0, NULL}
};
/*
@@ -220,23 +220,23 @@ static struct s_modeMap modeMap[] =
*/
static int check_vfo(vfo_t vfo)
{
- switch (vfo)
- {
- case RIG_VFO_A:
- break;
+ switch (vfo)
+ {
+ case RIG_VFO_A:
+ break;
- case RIG_VFO_TX:
- case RIG_VFO_B:
- break;
+ case RIG_VFO_TX:
+ case RIG_VFO_B:
+ break;
- case RIG_VFO_CURR:
- break; // will default to A in which_vfo
+ case RIG_VFO_CURR:
+ break; // will default to A in which_vfo
- default:
- RETURNFUNC(FALSE);
- }
+ default:
+ RETURNFUNC(FALSE);
+ }
- RETURNFUNC(TRUE);
+ RETURNFUNC(TRUE);
}
/*Rather than use some huge XML library we only need a few things
@@ -245,52 +245,52 @@ static int check_vfo(vfo_t vfo)
*/
static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
{
- char xml[4096]; // we shouldn't need more the 4096 bytes for this
- char tmp[32];
- char *header;
- int n;
+ char xml[4096]; // we shouldn't need more the 4096 bytes for this
+ char tmp[32];
+ char *header;
+ int n;
- // We want at least a 4K buf to play with
- if (xmlbuflen < 4096)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: xmllen < 4096\n", __func__);
- return NULL;
- }
+ // We want at least a 4K buf to play with
+ if (xmlbuflen < 4096)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: xmllen < 4096\n", __func__);
+ return NULL;
+ }
- header =
- "POST /RPC2 HTTP/1.1\r\n" "User-Agent: XMLRPC++ 0.8\r\n"
- "Host: 127.0.0.1:12345\r\n" "Content-type: text/xml\r\n";
- n = snprintf(xmlbuf, xmlbuflen, "%s", header);
+ header =
+ "POST /RPC2 HTTP/1.1\r\n" "User-Agent: XMLRPC++ 0.8\r\n"
+ "Host: 127.0.0.1:12345\r\n" "Content-type: text/xml\r\n";
+ n = snprintf(xmlbuf, xmlbuflen, "%s", header);
- if (n != strlen(header))
- {
- rig_debug(RIG_DEBUG_ERR, "%s: snprintf of header failed, len=%d, got=%d\n",
- __func__, (int)strlen(header), n);
- }
+ if (n != strlen(header))
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: snprintf of header failed, len=%d, got=%d\n",
+ __func__, (int)strlen(header), n);
+ }
- n = snprintf(xml, sizeof(xml), "\r\n");
+ n = snprintf(xml, sizeof(xml), "\r\n");
- if (n != strlen(xml))
- {
- rig_debug(RIG_DEBUG_ERR, "%s: snprintf of xml failed, len=%d, got=%d\n",
- __func__, (int)strlen(header), n);
- }
+ if (n != strlen(xml))
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: snprintf of xml failed, len=%d, got=%d\n",
+ __func__, (int)strlen(header), n);
+ }
- strncat(xml, "", sizeof(xml) - 1);
- strncat(xml, cmd, sizeof(xml) - strlen(xml) - 1);
- strncat(xml, "\r\n", sizeof(xml) - strlen(xml) - 1);
+ strncat(xml, "", sizeof(xml) - 1);
+ strncat(xml, cmd, sizeof(xml) - strlen(xml) - 1);
+ strncat(xml, "\r\n", sizeof(xml) - strlen(xml) - 1);
- if (value && strlen(value) > 0)
- {
- strncat(xml, value, sizeof(xml) - 1);
- }
+ if (value && strlen(value) > 0)
+ {
+ strncat(xml, value, sizeof(xml) - 1);
+ }
- strncat(xml, "\r\n", sizeof(xml) - 1);
- strncat(xmlbuf, "Content-length: ", xmlbuflen - 1);
- snprintf(tmp, sizeof(tmp), "%d\r\n\r\n", (int)strlen(xml));
- strncat(xmlbuf, tmp, xmlbuflen - 1);
- strncat(xmlbuf, xml, xmlbuflen - 1);
- return xmlbuf;
+ strncat(xml, "\r\n", sizeof(xml) - 1);
+ strncat(xmlbuf, "Content-length: ", xmlbuflen - 1);
+ snprintf(tmp, sizeof(tmp), "%d\r\n\r\n", (int)strlen(xml));
+ strncat(xmlbuf, tmp, xmlbuflen - 1);
+ strncat(xmlbuf, xml, xmlbuflen - 1);
+ return xmlbuf;
}
/*This is a very crude xml parse specific to what we need from FLRig
@@ -299,59 +299,59 @@ static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
*/
static char *xml_parse2(char *xml, char *value, int valueLen)
{
- char *delims = "<>\r\n ";
- char *xmltmp = strdup(xml);
- //rig_debug(RIG_DEBUG_TRACE, "%s: xml='%s'\n", __func__,xml);
- char *pr = xml;
- char *p = strtok_r(xmltmp, delims, &pr);
- value[0] = 0;
+ char *delims = "<>\r\n ";
+ char *xmltmp = strdup(xml);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: xml='%s'\n", __func__,xml);
+ char *pr = xml;
+ char *p = strtok_r(xmltmp, delims, &pr);
+ value[0] = 0;
- while (p)
- {
- if (streq(p, "value"))
- {
- p = strtok_r(NULL, delims, &pr);
+ while (p)
+ {
+ if (streq(p, "value"))
+ {
+ p = strtok_r(NULL, delims, &pr);
- if (streq(p, "array")) { continue; }
+ if (streq(p, "array")) { continue; }
- if (streq(p, "/value")) { continue; } // empty value
+ if (streq(p, "/value")) { continue; } // empty value
- if (streq(p, "i4") || streq(p, "double"))
- {
- p = strtok_r(NULL, delims, &pr);
- }
- else if (streq(p, "array"))
- {
- strtok_r(NULL, delims, &pr);
- p = strtok_r(NULL, delims, &pr);
- }
+ if (streq(p, "i4") || streq(p, "double"))
+ {
+ p = strtok_r(NULL, delims, &pr);
+ }
+ else if (streq(p, "array"))
+ {
+ strtok_r(NULL, delims, &pr);
+ p = strtok_r(NULL, delims, &pr);
+ }
- if (strlen(value) + strlen(p) + 1 < valueLen)
- {
- if (value[0] != 0) { strcat(value, "|"); }
+ if (strlen(value) + strlen(p) + 1 < valueLen)
+ {
+ if (value[0] != 0) { strcat(value, "|"); }
- strcat(value, p);
- }
- else // we'll just stop adding stuff
- {
- rig_debug(RIG_DEBUG_ERR, "%s: max value length exceeded\n", __func__);
- }
- }
- else
- {
- p = strtok_r(NULL, delims, &pr);
- }
- }
+ strcat(value, p);
+ }
+ else // we'll just stop adding stuff
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: max value length exceeded\n", __func__);
+ }
+ }
+ else
+ {
+ p = strtok_r(NULL, delims, &pr);
+ }
+ }
- rig_debug(RIG_DEBUG_TRACE, "%s: value returned='%s'\n", __func__, value);
+ rig_debug(RIG_DEBUG_TRACE, "%s: value returned='%s'\n", __func__, value);
- if (rig_need_debug(RIG_DEBUG_WARN) && value != NULL && strlen(value) == 0)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: xml='%s'\n", __func__, xml);
- }
+ if (rig_need_debug(RIG_DEBUG_WARN) && value != NULL && strlen(value) == 0)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: xml='%s'\n", __func__, xml);
+ }
- free(xmltmp);
- return value;
+ free(xmltmp);
+ return value;
}
/*
@@ -361,39 +361,39 @@ static char *xml_parse2(char *xml, char *value, int valueLen)
*/
static char *xml_parse(char *xml, char *value, int value_len)
{
- char *next;
- char *pxml;
+ char *next;
+ char *pxml;
- /* first off we should have an OK on the 1st line */
- if (strstr(xml, " 200 OK") == NULL)
- {
- return(NULL);
- }
+ /* first off we should have an OK on the 1st line */
+ if (strstr(xml, " 200 OK") == NULL)
+ {
+ return (NULL);
+ }
- rig_debug(RIG_DEBUG_TRACE, "%s XML:\n%s\n", __func__, xml);
+ rig_debug(RIG_DEBUG_TRACE, "%s XML:\n%s\n", __func__, xml);
- // find the xml skipping the other stuff above it
- pxml = strstr(xml, "";
- struct rig_state *rs = &rig->state;
+ int retval;
+ int retry;
+ char *delims;
+ char *terminator = "";
+ struct rig_state *rs = &rig->state;
- ENTERFUNC;
+ ENTERFUNC;
- retry = 2;
- delims = "\n";
- xml[0] = 0;
+ retry = 2;
+ delims = "\n";
+ xml[0] = 0;
- do
- {
- char tmp_buf[MAXXMLLEN]; // plenty big for expected flrig responses hopefully
+ do
+ {
+ char tmp_buf[MAXXMLLEN]; // plenty big for expected flrig responses hopefully
- if (retry < 2)
- {
- rig_debug(RIG_DEBUG_WARN, "%s: retry needed? retry=%d\n", __func__, retry);
- }
+ if (retry < 2)
+ {
+ rig_debug(RIG_DEBUG_WARN, "%s: retry needed? retry=%d\n", __func__, retry);
+ }
- int len = read_string(&rs->rigport, tmp_buf, sizeof(tmp_buf), delims,
- strlen(delims));
- rig_debug(RIG_DEBUG_TRACE, "%s: string='%s'\n", __func__, tmp_buf);
+ int len = read_string(&rs->rigport, tmp_buf, sizeof(tmp_buf), delims,
+ strlen(delims));
+ rig_debug(RIG_DEBUG_TRACE, "%s: string='%s'\n", __func__, tmp_buf);
- // if our first response we should see the HTTP header
- if (strlen(xml) == 0 && strstr(tmp_buf, "HTTP/1.1 200 OK") == NULL)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: Expected 'HTTP/1.1 200 OK', got '%s'\n", __func__,
- tmp_buf);
- RETURNFUNC(-1);
- }
+ // if our first response we should see the HTTP header
+ if (strlen(xml) == 0 && strstr(tmp_buf, "HTTP/1.1 200 OK") == NULL)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: Expected 'HTTP/1.1 200 OK', got '%s'\n", __func__,
+ tmp_buf);
+ continue; // we'll try again
+ }
- if (len > 0) { retry = 3; }
+ if (len > 0) { retry = 3; }
- if (len <= 0)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: read_string error=%d\n", __func__, len);
- continue;
- }
+ if (len <= 0)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: read_string error=%d\n", __func__, len);
+ continue;
+ }
- if (strlen(xml) + strlen(tmp_buf) < xml_len - 1)
- {
- strncat(xml, tmp_buf, xml_len - 1);
- }
- else
- {
- rig_debug(RIG_DEBUG_ERR,
- "%s: xml buffer overflow!!\nTrying to add len=%d\nTo len=%d\n", __func__,
- (int)strlen(tmp_buf), (int)strlen(xml));
- RETURNFUNC(-RIG_EPROTO);
- }
- }
- while (retry-- > 0 && strstr(xml, terminator) == NULL);
+ if (strlen(xml) + strlen(tmp_buf) < xml_len - 1)
+ {
+ strncat(xml, tmp_buf, xml_len - 1);
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: xml buffer overflow!!\nTrying to add len=%d\nTo len=%d\n", __func__,
+ (int)strlen(tmp_buf), (int)strlen(xml));
+ RETURNFUNC(-RIG_EPROTO);
+ }
+ }
+ while (retry-- > 0 && strstr(xml, terminator) == NULL);
- if (retry == 0)
- {
- rig_debug(RIG_DEBUG_WARN, "%s: retry timeout\n", __func__);
- RETURNFUNC(-RIG_ETIMEOUT);
- }
+ if (retry == 0)
+ {
+ rig_debug(RIG_DEBUG_WARN, "%s: retry timeout\n", __func__);
+ RETURNFUNC(-RIG_ETIMEOUT);
+ }
- if (strstr(xml, terminator))
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: got %s\n", __func__, terminator);
- // Slow down just a bit -- not sure this is needed anymore but not a big deal here
- hl_usleep(2 * 1000);
- retval = RIG_OK;
- }
- else
- {
- rig_debug(RIG_DEBUG_VERBOSE, "%s: did not get %s\n", __func__, terminator);
- retval = -(101 + RIG_EPROTO);
- }
+ if (strstr(xml, terminator))
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: got %s\n", __func__, terminator);
+ // Slow down just a bit -- not sure this is needed anymore but not a big deal here
+ hl_usleep(2 * 1000);
+ retval = RIG_OK;
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: did not get %s\n", __func__, terminator);
+ retval = -(101 + RIG_EPROTO);
+ }
- RETURNFUNC(retval);
+ RETURNFUNC(retval);
}
/*
@@ -486,89 +486,89 @@ static int read_transaction(RIG *rig, char *xml, int xml_len)
static int write_transaction(RIG *rig, char *xml, int xml_len)
{
- int try = rig->caps->retry;
+ int try = rig->caps->retry;
- int retval = -RIG_EPROTO;
+ int retval = -RIG_EPROTO;
- struct rig_state *rs = &rig->state;
+ struct rig_state *rs = &rig->state;
- ENTERFUNC;
+ ENTERFUNC;
- // This shouldn't ever happen...but just in case
- // We need to avoid an empty write as rigctld replies with blank line
- if (xml_len == 0)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: len==0??\n", __func__);
- RETURNFUNC(retval);
- }
+ // This shouldn't ever happen...but just in case
+ // We need to avoid an empty write as rigctld replies with blank line
+ if (xml_len == 0)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: len==0??\n", __func__);
+ RETURNFUNC(retval);
+ }
- // appears we can lose sync if we don't clear things out
- // shouldn't be anything for us now anyways
- rig_flush(&rig->state.rigport);
+ // appears we can lose sync if we don't clear things out
+ // shouldn't be anything for us now anyways
+ rig_flush(&rig->state.rigport);
- while (try-- >= 0 && retval != RIG_OK)
- {
- retval = write_block(&rs->rigport, xml, strlen(xml));
+ while (try-- >= 0 && retval != RIG_OK)
+ {
+ retval = write_block(&rs->rigport, xml, strlen(xml));
- if (retval < 0)
- {
- RETURNFUNC(-RIG_EIO);
- }
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(-RIG_EIO);
+ }
+ }
- RETURNFUNC(retval);
+ RETURNFUNC(retval);
}
static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value,
- int value_len)
+ int value_len)
{
- char xml[MAXXMLLEN];
- int retry = 5;
+ char xml[MAXXMLLEN];
+ int retry = 5;
- ENTERFUNC;
+ ENTERFUNC;
- if (value)
- {
- value[0] = 0;
- }
+ if (value)
+ {
+ value[0] = 0;
+ }
- do
- {
- char *pxml;
- int retval;
+ do
+ {
+ char *pxml;
+ int retval;
- if (retry < 2)
- {
- rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s, retry=%d\n", __func__, cmd, retry);
- }
+ if (retry < 2)
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s, retry=%d\n", __func__, cmd, retry);
+ }
- pxml = xml_build(cmd, cmd_arg, xml, sizeof(xml));
- retval = write_transaction(rig, pxml, strlen(pxml));
+ pxml = xml_build(cmd, cmd_arg, xml, sizeof(xml));
+ retval = write_transaction(rig, pxml, strlen(pxml));
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: write_transaction error=%d\n", __func__, retval);
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: write_transaction error=%d\n", __func__, retval);
- // if we get RIG_EIO the socket has probably disappeared
- // so bubble up the error so port can re re-opened
- if (retval == -RIG_EIO) { RETURNFUNC(retval); }
+ // if we get RIG_EIO the socket has probably disappeared
+ // so bubble up the error so port can re re-opened
+ if (retval == -RIG_EIO) { RETURNFUNC(retval); }
- hl_usleep(50 * 1000); // 50ms sleep if error
- }
+ hl_usleep(50 * 1000); // 50ms sleep if error
+ }
- read_transaction(rig, xml, sizeof(xml)); // this might time out -- that's OK
+ read_transaction(rig, xml, sizeof(xml)); // this might time out -- that's OK
- if (value)
- {
- xml_parse(xml, value, value_len);
- }
- }
- while (((value && strlen(value) == 0) || (strlen(xml) == 0))
- && retry--); // we'll do retries if needed
+ if (value)
+ {
+ xml_parse(xml, value, value_len);
+ }
+ }
+ while (((value && strlen(value) == 0) || (strlen(xml) == 0))
+ && retry--); // we'll do retries if needed
- if (value && strlen(value) == 0) { RETURNFUNC(RIG_EPROTO); }
+ if (value && strlen(value) == 0) { RETURNFUNC(RIG_EPROTO); }
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -577,43 +577,43 @@ static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value,
*/
static int flrig_init(RIG *rig)
{
- struct flrig_priv_data *priv;
+ struct flrig_priv_data *priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
- rig->state.priv = (struct flrig_priv_data *)malloc(sizeof(
- struct flrig_priv_data));
+ rig->state.priv = (struct flrig_priv_data *)malloc(sizeof(
+ struct flrig_priv_data));
- if (!rig->state.priv)
- {
- RETURNFUNC(-RIG_ENOMEM);
- }
+ if (!rig->state.priv)
+ {
+ RETURNFUNC(-RIG_ENOMEM);
+ }
- priv = rig->state.priv;
+ priv = rig->state.priv;
- memset(priv, 0, sizeof(struct flrig_priv_data));
+ memset(priv, 0, sizeof(struct flrig_priv_data));
- /*
- * set arbitrary initial status
- */
- rig->state.current_vfo = RIG_VFO_A;
- priv->split = 0;
- priv->ptt = 0;
- priv->curr_modeA = -1;
- priv->curr_modeB = -1;
- priv->curr_widthA = -1;
- priv->curr_widthB = -1;
+ /*
+ * set arbitrary initial status
+ */
+ rig->state.current_vfo = RIG_VFO_A;
+ priv->split = 0;
+ priv->ptt = 0;
+ priv->curr_modeA = -1;
+ priv->curr_modeB = -1;
+ priv->curr_widthA = -1;
+ priv->curr_widthB = -1;
- if (!rig->caps)
- {
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (!rig->caps)
+ {
+ RETURNFUNC(-RIG_EINVAL);
+ }
- strncpy(rig->state.rigport.pathname, DEFAULTPATH,
- sizeof(rig->state.rigport.pathname));
+ strncpy(rig->state.rigport.pathname, DEFAULTPATH,
+ sizeof(rig->state.rigport.pathname));
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -623,27 +623,27 @@ static int flrig_init(RIG *rig)
*/
static const char *modeMapGetFLRig(rmode_t modeHamlib)
{
- int i;
+ int i;
- rig_debug(RIG_DEBUG_TRACE,"%s: called\n", __func__);
+ rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
- for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
- {
- rig_debug(RIG_DEBUG_TRACE,
- "%s: checking modeMap[%d]=%.0f to modeHamlib=%.0f, mode_flrig='%s'\n", __func__,
- i, (double)modeMap[i].mode_hamlib, (double)modeHamlib, modeMap[i].mode_flrig);
+ for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
+ {
+ rig_debug(RIG_DEBUG_TRACE,
+ "%s: checking modeMap[%d]=%.0f to modeHamlib=%.0f, mode_flrig='%s'\n", __func__,
+ i, (double)modeMap[i].mode_hamlib, (double)modeHamlib, modeMap[i].mode_flrig);
- if (modeMap[i].mode_hamlib == modeHamlib)
- {
- rig_debug(RIG_DEBUG_TRACE, "%s matched mode=%.0f, returning '%s'\n", __func__,
- (double)modeHamlib, modeMap[i].mode_flrig);
- return(modeMap[i].mode_flrig);
- }
- }
+ if (modeMap[i].mode_hamlib == modeHamlib)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s matched mode=%.0f, returning '%s'\n", __func__,
+ (double)modeHamlib, modeMap[i].mode_flrig);
+ return (modeMap[i].mode_flrig);
+ }
+ }
- rig_debug(RIG_DEBUG_ERR, "%s: Unknown mode requested: %s\n", __func__,
- rig_strrmode(modeHamlib));
- return("ERROR");
+ rig_debug(RIG_DEBUG_ERR, "%s: Unknown mode requested: %s\n", __func__,
+ rig_strrmode(modeHamlib));
+ return ("ERROR");
}
/*
@@ -653,28 +653,28 @@ static const char *modeMapGetFLRig(rmode_t modeHamlib)
*/
static rmode_t modeMapGetHamlib(const char *modeFLRig)
{
- int i;
- char modeFLRigCheck[64];
+ int i;
+ char modeFLRigCheck[64];
- ENTERFUNC;
+ ENTERFUNC;
- snprintf(modeFLRigCheck, sizeof(modeFLRigCheck), "|%s|", modeFLRig);
+ snprintf(modeFLRigCheck, sizeof(modeFLRigCheck), "|%s|", modeFLRig);
- for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: find '%s' in '%s'\n", __func__,
- modeFLRigCheck, modeMap[i].mode_flrig);
+ for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: find '%s' in '%s'\n", __func__,
+ modeFLRigCheck, modeMap[i].mode_flrig);
- if (modeMap[i].mode_flrig
- && strcmp(modeMap[i].mode_flrig, modeFLRigCheck) == 0)
- {
- RETURNFUNC(modeMap[i].mode_hamlib);
- }
- }
+ if (modeMap[i].mode_flrig
+ && strcmp(modeMap[i].mode_flrig, modeFLRigCheck) == 0)
+ {
+ RETURNFUNC(modeMap[i].mode_hamlib);
+ }
+ }
- rig_debug(RIG_DEBUG_TRACE, "%s: mode requested: %s, not in modeMap\n", __func__,
- modeFLRig);
- RETURNFUNC(RIG_MODE_NONE);
+ rig_debug(RIG_DEBUG_TRACE, "%s: mode requested: %s, not in modeMap\n", __func__,
+ modeFLRig);
+ RETURNFUNC(RIG_MODE_NONE);
}
@@ -684,51 +684,51 @@ static rmode_t modeMapGetHamlib(const char *modeFLRig)
*/
static void modeMapAdd(rmode_t *modes, rmode_t mode_hamlib, char *mode_flrig)
{
- int i;
- int len1;
+ int i;
+ int len1;
- rig_debug(RIG_DEBUG_TRACE, "%s:mode_flrig=%s\n", __func__, mode_flrig);
+ rig_debug(RIG_DEBUG_TRACE, "%s:mode_flrig=%s\n", __func__, mode_flrig);
- // if we already have it just return
- // We get ERROR if the mode is not known so non-ERROR is OK
- if (modeMapGetHamlib(mode_flrig) != RIG_MODE_NONE) { return; }
+ // if we already have it just return
+ // We get ERROR if the mode is not known so non-ERROR is OK
+ if (modeMapGetHamlib(mode_flrig) != RIG_MODE_NONE) { return; }
- len1 = strlen(mode_flrig) + 3; /* bytes needed for allocating */
+ len1 = strlen(mode_flrig) + 3; /* bytes needed for allocating */
- for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
- {
- if (modeMap[i].mode_hamlib == mode_hamlib)
- {
- int len2;
- *modes |= modeMap[i].mode_hamlib;
+ for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
+ {
+ if (modeMap[i].mode_hamlib == mode_hamlib)
+ {
+ int len2;
+ *modes |= modeMap[i].mode_hamlib;
- /* we will pipe delimit all the entries for easier matching */
- /* all entries will have pipe symbol on both sides */
- if (modeMap[i].mode_flrig == NULL)
- {
- modeMap[i].mode_flrig = calloc(1, len1);
+ /* we will pipe delimit all the entries for easier matching */
+ /* all entries will have pipe symbol on both sides */
+ if (modeMap[i].mode_flrig == NULL)
+ {
+ modeMap[i].mode_flrig = calloc(1, len1);
- if (modeMap[i].mode_flrig == NULL)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: error allocating memory for modeMap\n",
- __func__);
- return;
- }
- }
+ if (modeMap[i].mode_flrig == NULL)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: error allocating memory for modeMap\n",
+ __func__);
+ return;
+ }
+ }
- len2 = strlen(modeMap[i].mode_flrig); /* current len w/o null */
- modeMap[i].mode_flrig = realloc(modeMap[i].mode_flrig,
- strlen(modeMap[i].mode_flrig) + len1);
+ len2 = strlen(modeMap[i].mode_flrig); /* current len w/o null */
+ modeMap[i].mode_flrig = realloc(modeMap[i].mode_flrig,
+ strlen(modeMap[i].mode_flrig) + len1);
- if (strlen(modeMap[i].mode_flrig) == 0) { modeMap[i].mode_flrig[0] = '|'; }
+ if (strlen(modeMap[i].mode_flrig) == 0) { modeMap[i].mode_flrig[0] = '|'; }
- strncat(modeMap[i].mode_flrig, mode_flrig, len1 + len2);
- strncat(modeMap[i].mode_flrig, "|", len1 + len2);
- rig_debug(RIG_DEBUG_TRACE, "%s: Adding mode=%s, index=%d, result=%s\n",
- __func__, mode_flrig, i, modeMap[i].mode_flrig);
- return;
- }
- }
+ strncat(modeMap[i].mode_flrig, mode_flrig, len1 + len2);
+ strncat(modeMap[i].mode_flrig, "|", len1 + len2);
+ rig_debug(RIG_DEBUG_TRACE, "%s: Adding mode=%s, index=%d, result=%s\n",
+ __func__, mode_flrig, i, modeMap[i].mode_flrig);
+ return;
+ }
+ }
}
/*
@@ -737,251 +737,254 @@ static void modeMapAdd(rmode_t *modes, rmode_t mode_hamlib, char *mode_flrig)
*/
static int flrig_open(RIG *rig)
{
- int retval;
- char value[MAXXMLLEN];
- char arg[MAXXMLLEN];
- rmode_t modes;
- char *p;
- char *pr;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ char value[MAXXMLLEN];
+ char arg[MAXXMLLEN];
+ rmode_t modes;
+ char *p;
+ char *pr;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__, BACKEND_VER);
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__, BACKEND_VER);
- retval = flrig_transaction(rig, "main.get_version", NULL, value, sizeof(value));
+ retval = flrig_transaction(rig, "main.get_version", NULL, value, sizeof(value));
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: get_version failed: %s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
- rig_debug(RIG_DEBUG_VERBOSE, "%s FlRig version %s\n", __func__, value);
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: get_version failed: %s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- retval = flrig_transaction(rig, "rig.get_xcvr", NULL, value, sizeof(value));
+ rig_debug(RIG_DEBUG_VERBOSE, "%s FlRig version %s\n", __func__, value);
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: get_xcvr failed: %s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
- retval = flrig_transaction(rig, "rig.get_xcvr", NULL, value, sizeof(value));
+ retval = flrig_transaction(rig, "rig.get_xcvr", NULL, value, sizeof(value));
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: get_xcvr failed: %s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
- retval = flrig_transaction(rig, "rig.get_xcvr", NULL, value, sizeof(value));
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: get_xcvr failed: %s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: get_xcvr failed: %s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
+ retval = flrig_transaction(rig, "rig.get_xcvr", NULL, value, sizeof(value));
- strncpy(priv->info, value, sizeof(priv->info));
- rig_debug(RIG_DEBUG_VERBOSE, "Transceiver=%s\n", value);
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: get_xcvr failed: %s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- /* see if get_pwrmeter_scale is available */
- retval = flrig_transaction(rig, "rig.get_pwrmeter_scale", NULL, value,
- sizeof(value));
+ retval = flrig_transaction(rig, "rig.get_xcvr", NULL, value, sizeof(value));
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: get_xcvr failed: %s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- priv->powermeter_scale = 1; // default
+ strncpy(priv->info, value, sizeof(priv->info));
+ rig_debug(RIG_DEBUG_VERBOSE, "Transceiver=%s\n", value);
- if (strlen(value) > 0)
- {
- priv->powermeter_scale = atof(value);
- }
+ /* see if get_pwrmeter_scale is available */
+ retval = flrig_transaction(rig, "rig.get_pwrmeter_scale", NULL, value,
+ sizeof(value));
- /* see if get_modeA is available */
- retval = flrig_transaction(rig, "rig.get_modeA", NULL, value, sizeof(value));
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ priv->powermeter_scale = 1; // default
- if (strlen(value) > 0) /* must have it since we got an answer */
- {
- priv->has_get_modeA = 1;
- rig_debug(RIG_DEBUG_VERBOSE, "%s: getmodeA is available=%s\n", __func__,
- value);
- }
- else
- {
- rig_debug(RIG_DEBUG_VERBOSE, "%s: getmodeA is not available\n", __func__);
- }
+ if (strlen(value) > 0)
+ {
+ priv->powermeter_scale = atof(value);
+ }
- /* see if get_bwA is available */
- retval = flrig_transaction(rig, "rig.get_bwA", NULL, value, sizeof(value));
+ /* see if get_modeA is available */
+ retval = flrig_transaction(rig, "rig.get_modeA", NULL, value, sizeof(value));
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- if (strlen(value) > 0) /* must have it since we got an answer */
- {
- priv->has_get_bwA = 1;
- rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwA is available=%s\n", __func__,
- value);
- }
- else
- {
- rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwA is not available\n", __func__);
- }
+ if (strlen(value) > 0) /* must have it since we got an answer */
+ {
+ priv->has_get_modeA = 1;
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: getmodeA is available=%s\n", __func__,
+ value);
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: getmodeA is not available\n", __func__);
+ }
- strcpy(arg, value);
- retval = flrig_transaction(rig, "rig.get_AB", arg, value, sizeof(value));
+ /* see if get_bwA is available */
+ retval = flrig_transaction(rig, "rig.get_bwA", NULL, value, sizeof(value));
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- if (streq(value, "A"))
- {
- rig->state.current_vfo = RIG_VFO_A;
- }
- else
- {
- rig->state.current_vfo = RIG_VFO_B;
- }
+ if (strlen(value) > 0) /* must have it since we got an answer */
+ {
+ priv->has_get_bwA = 1;
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwA is available=%s\n", __func__,
+ value);
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwA is not available\n", __func__);
+ }
- rig_debug(RIG_DEBUG_TRACE, "%s: currvfo=%s value=%s\n", __func__,
- rig_strvfo(rig->state.current_vfo), value);
- //vfo_t vfo=RIG_VFO_A;
- //vfo_t vfo_tx=RIG_VFO_B; // split is always VFOB
- //flrig_get_split_vfo(rig, vfo, &priv->split, &vfo_tx);
+ strcpy(arg, value);
+ retval = flrig_transaction(rig, "rig.get_AB", arg, value, sizeof(value));
- /* find out available widths and modes */
- retval = flrig_transaction(rig, "rig.get_modes", NULL, value, sizeof(value));
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ if (streq(value, "A"))
+ {
+ rig->state.current_vfo = RIG_VFO_A;
+ }
+ else
+ {
+ rig->state.current_vfo = RIG_VFO_B;
+ }
- rig_debug(RIG_DEBUG_VERBOSE, "%s: modes=%s\n", __func__, value);
- modes = 0;
- pr = value;
+ rig_debug(RIG_DEBUG_TRACE, "%s: currvfo=%s value=%s\n", __func__,
+ rig_strvfo(rig->state.current_vfo), value);
+ //vfo_t vfo=RIG_VFO_A;
+ //vfo_t vfo_tx=RIG_VFO_B; // split is always VFOB
+ //flrig_get_split_vfo(rig, vfo, &priv->split, &vfo_tx);
- /* The following modes in FLRig are not implemented yet
- A1A
- AM-2
- AM6.0
- AM-D1 -- doesn't appear to be read/set
- AM-D2 -- doesn't appear to be read/set
- AM-D3 -- doesn't appear to be read/set
- AMW -- don't have mode in rig.h
- CW2.4 -- could be CW
- CW500 -- could be CWN but CWN not in rig.h
- CW-N -- could be CWN but CWN not in rig.h
- CWN -- dcould be CWN but CWN not in rig.h
- CW-NR -- don't have mode in rig.h
- DATA2-LSB
- DV
- DV-R
- F1B
- FM-D1 -- doesn't appear to be read/set
- FM-D2 -- doesn't appear to be read/set
- FM-D3 -- doesn't appear to be read/set
- H3E
- M11
- USB-D -- doesn't appear to be read/set
- USB-D1 -- doesn't appear to be read/set
- USB-D2 -- doesn't appear to be read/set
- USB-D3 -- doesn't appear to be read/set
- USER-L -- doesn't appear to be read/set
- USER-U -- doesn't appear to be read/set
- */
+ /* find out available widths and modes */
+ retval = flrig_transaction(rig, "rig.get_modes", NULL, value, sizeof(value));
- for (p = strtok_r(value, "|", &pr); p != NULL; p = strtok_r(NULL, "|", &pr))
- {
- if (streq(p, "AM-D")) { modeMapAdd(&modes, RIG_MODE_PKTAM, p); }
- else if (streq(p, "AM")) { modeMapAdd(&modes, RIG_MODE_AM, p); }
- else if (streq(p, "AM-N")) { modeMapAdd(&modes, RIG_MODE_AMN, p); }
- else if (streq(p, "AMN")) { modeMapAdd(&modes, RIG_MODE_AMN, p); }
- else if (streq(p, "CW")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
- else if (streq(p, "CW-L")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
- else if (streq(p, "CW-LSB")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
- else if (streq(p, "CW-R")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
- else if (streq(p, "CW-U")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
- else if (streq(p, "CW-USB")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
- else if (streq(p, "CWL")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
- else if (streq(p, "CWU")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
- else if (streq(p, "D-LSB")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "D-USB")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "DATA")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "DATA-FM")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); }
- else if (streq(p, "DATA-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "DATA-R")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "DATA-LSB")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "DATA-USB")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "DATA-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "DIG")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "DIGI")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "DIGL")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "DIGU")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "DSB")) { modeMapAdd(&modes, RIG_MODE_DSB, p); }
- else if (streq(p, "FM")) { modeMapAdd(&modes, RIG_MODE_FM, p); }
- else if (streq(p, "FM-D")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); }
- else if (streq(p, "FMN")) { modeMapAdd(&modes, RIG_MODE_FMN, p); }
- else if (streq(p, "FM-N")) { modeMapAdd(&modes, RIG_MODE_FMN, p); }
- else if (streq(p, "FMW")) { modeMapAdd(&modes, RIG_MODE_WFM, p); }
- else if (streq(p, "FSK")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "FSK-R")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "LCW")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
- else if (streq(p, "LSB")) { modeMapAdd(&modes, RIG_MODE_LSB, p); }
- else if (streq(p, "LSB-D")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "LSB-D1")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "LSB-D2")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "LSB-D3")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "NFM")) { modeMapAdd(&modes, RIG_MODE_FMN, p); }
- else if (streq(p, "PKT")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "PKT-FM")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); }
- else if (streq(p, "PKT-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "PKT-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "PKT(L)")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "PKT(U)")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "PSK")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "PSK-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "PSK-R")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "PSK-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "RTTY")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); }
- else if (streq(p, "RTTY-L")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); }
- else if (streq(p, "RTTY-R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); }
- else if (streq(p, "RTTY-U")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); }
- else if (streq(p, "RTTY(U)")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); }
- else if (streq(p, "RTTY(R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); }
- else if (streq(p, "SAH")) { modeMapAdd(&modes, RIG_MODE_SAH, p); }
- else if (streq(p, "SAL")) { modeMapAdd(&modes, RIG_MODE_SAL, p); }
- else if (streq(p, "SAM")) { modeMapAdd(&modes, RIG_MODE_SAM, p); }
- else if (streq(p, "USB")) { modeMapAdd(&modes, RIG_MODE_USB, p); }
- else if (streq(p, "USB-D")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "USB-D1")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "USB-D2")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "USB-D3")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "USER-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
- else if (streq(p, "USER-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
- else if (streq(p, "W-FM")) { modeMapAdd(&modes, RIG_MODE_WFM, p); }
- else if (streq(p, "WFM")) { modeMapAdd(&modes, RIG_MODE_WFM, p); }
- else if (streq(p, "UCW")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
- else if (streq(p, "C4FM")) { modeMapAdd(&modes, RIG_MODE_C4FM, p); }
- else if (streq(p, "SPEC")) { modeMapAdd(&modes, RIG_MODE_SPEC, p); }
- else if (streq(p, "DRM")) // we don't support DRM yet (or maybe ever)
- {
- rig_debug(RIG_DEBUG_VERBOSE, "%s: no mapping for mode %s\n", __func__, p);
- }
- else { rig_debug(RIG_DEBUG_ERR, "%s: Unknown mode (new?) for this rig='%s'\n", __func__, p); }
- }
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- rig->state.mode_list = modes;
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: modes=%s\n", __func__, value);
+ modes = 0;
+ pr = value;
- retval = rig_strrmodes(modes, value, sizeof(value));
+ /* The following modes in FLRig are not implemented yet
+ A1A
+ AM-2
+ AM6.0
+ AM-D1 -- doesn't appear to be read/set
+ AM-D2 -- doesn't appear to be read/set
+ AM-D3 -- doesn't appear to be read/set
+ AMW -- don't have mode in rig.h
+ CW2.4 -- could be CW
+ CW500 -- could be CWN but CWN not in rig.h
+ CW-N -- could be CWN but CWN not in rig.h
+ CWN -- dcould be CWN but CWN not in rig.h
+ CW-NR -- don't have mode in rig.h
+ DATA2-LSB
+ DV
+ DV-R
+ F1B
+ FM-D1 -- doesn't appear to be read/set
+ FM-D2 -- doesn't appear to be read/set
+ FM-D3 -- doesn't appear to be read/set
+ H3E
+ M11
+ USB-D -- doesn't appear to be read/set
+ USB-D1 -- doesn't appear to be read/set
+ USB-D2 -- doesn't appear to be read/set
+ USB-D3 -- doesn't appear to be read/set
+ USER-L -- doesn't appear to be read/set
+ USER-U -- doesn't appear to be read/set
+ */
- if (retval != RIG_OK) // we might get TRUNC but we can still print the debug
- {
- rig_debug(RIG_DEBUG_VERBOSE, "%s: %s\n", __func__, rigerror(retval));
- }
+ for (p = strtok_r(value, "|", &pr); p != NULL; p = strtok_r(NULL, "|", &pr))
+ {
+ if (streq(p, "AM-D")) { modeMapAdd(&modes, RIG_MODE_PKTAM, p); }
+ else if (streq(p, "AM")) { modeMapAdd(&modes, RIG_MODE_AM, p); }
+ else if (streq(p, "AM-N")) { modeMapAdd(&modes, RIG_MODE_AMN, p); }
+ else if (streq(p, "AMN")) { modeMapAdd(&modes, RIG_MODE_AMN, p); }
+ else if (streq(p, "CW")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
+ else if (streq(p, "CW-L")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
+ else if (streq(p, "CW-LSB")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
+ else if (streq(p, "CW-R")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
+ else if (streq(p, "CW-U")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
+ else if (streq(p, "CW-USB")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
+ else if (streq(p, "CWL")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
+ else if (streq(p, "CWU")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
+ else if (streq(p, "D-LSB")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "D-USB")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "DATA")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "DATA-FM")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); }
+ else if (streq(p, "DATA-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "DATA-R")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "DATA-LSB")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "DATA-USB")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "DATA-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "DIG")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "DIGI")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "DIGL")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "DIGU")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "DSB")) { modeMapAdd(&modes, RIG_MODE_DSB, p); }
+ else if (streq(p, "FM")) { modeMapAdd(&modes, RIG_MODE_FM, p); }
+ else if (streq(p, "FM-D")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); }
+ else if (streq(p, "FMN")) { modeMapAdd(&modes, RIG_MODE_FMN, p); }
+ else if (streq(p, "FM-N")) { modeMapAdd(&modes, RIG_MODE_FMN, p); }
+ else if (streq(p, "FMW")) { modeMapAdd(&modes, RIG_MODE_WFM, p); }
+ else if (streq(p, "FSK")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "FSK-R")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "LCW")) { modeMapAdd(&modes, RIG_MODE_CWR, p); }
+ else if (streq(p, "LSB")) { modeMapAdd(&modes, RIG_MODE_LSB, p); }
+ else if (streq(p, "LSB-D")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "LSB-D1")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "LSB-D2")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "LSB-D3")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "NFM")) { modeMapAdd(&modes, RIG_MODE_FMN, p); }
+ else if (streq(p, "PKT")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "PKT-FM")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); }
+ else if (streq(p, "PKT-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "PKT-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "PKT(L)")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "PKT(U)")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "PSK")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "PSK-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "PSK-R")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "PSK-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "RTTY")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); }
+ else if (streq(p, "RTTY-L")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); }
+ else if (streq(p, "RTTY-R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); }
+ else if (streq(p, "RTTY-U")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); }
+ else if (streq(p, "RTTY(U)")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); }
+ else if (streq(p, "RTTY(R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); }
+ else if (streq(p, "SAH")) { modeMapAdd(&modes, RIG_MODE_SAH, p); }
+ else if (streq(p, "SAL")) { modeMapAdd(&modes, RIG_MODE_SAL, p); }
+ else if (streq(p, "SAM")) { modeMapAdd(&modes, RIG_MODE_SAM, p); }
+ else if (streq(p, "USB")) { modeMapAdd(&modes, RIG_MODE_USB, p); }
+ else if (streq(p, "USB-D")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "USB-D1")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "USB-D2")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "USB-D3")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "USER-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); }
+ else if (streq(p, "USER-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); }
+ else if (streq(p, "W-FM")) { modeMapAdd(&modes, RIG_MODE_WFM, p); }
+ else if (streq(p, "WFM")) { modeMapAdd(&modes, RIG_MODE_WFM, p); }
+ else if (streq(p, "UCW")) { modeMapAdd(&modes, RIG_MODE_CW, p); }
+ else if (streq(p, "C4FM")) { modeMapAdd(&modes, RIG_MODE_C4FM, p); }
+ else if (streq(p, "SPEC")) { modeMapAdd(&modes, RIG_MODE_SPEC, p); }
+ else if (streq(p, "DRM")) // we don't support DRM yet (or maybe ever)
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: no mapping for mode %s\n", __func__, p);
+ }
+ else { rig_debug(RIG_DEBUG_ERR, "%s: Unknown mode (new?) for this rig='%s'\n", __func__, p); }
+ }
- rig_debug(RIG_DEBUG_VERBOSE, "%s: hamlib modes=%s\n", __func__, value);
+ rig->state.mode_list = modes;
- RETURNFUNC(retval);
+ retval = rig_strrmodes(modes, value, sizeof(value));
+
+ if (retval != RIG_OK) // we might get TRUNC but we can still print the debug
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: %s\n", __func__, rigerror(retval));
+ }
+
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: hamlib modes=%s\n", __func__, value);
+
+ RETURNFUNC(retval);
}
/*
@@ -990,9 +993,9 @@ static int flrig_open(RIG *rig)
*/
static int flrig_close(RIG *rig)
{
- ENTERFUNC;
+ ENTERFUNC;
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1001,35 +1004,37 @@ static int flrig_close(RIG *rig)
*/
static int flrig_cleanup(RIG *rig)
{
- rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
- if (!rig)
- {
- RETURNFUNC(-RIG_EINVAL);
- }
+ rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
- free(rig->state.priv);
- rig->state.priv = NULL;
+ if (!rig)
+ {
+ RETURNFUNC(-RIG_EINVAL);
+ }
- // we really don't need to free this up as it's only done once
- // was causing problem when cleanup was followed by rig_open
- // model_flrig was not getting refilled
- // if we can figure out that one we can re-enable this
+ free(rig->state.priv);
+ rig->state.priv = NULL;
+
+ // we really don't need to free this up as it's only done once
+ // was causing problem when cleanup was followed by rig_open
+ // model_flrig was not getting refilled
+ // if we can figure out that one we can re-enable this
#if 0
- int i;
+ int i;
- for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
- {
- if (modeMap[i].mode_flrig)
- {
- free(modeMap[i].mode_flrig);
- modeMap[i].mode_flrig = NULL;
- modeMap[i].mode_hamlib = 0;
- }
+ for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
+ {
+ if (modeMap[i].mode_flrig)
+ {
+ free(modeMap[i].mode_flrig);
+ modeMap[i].mode_flrig = NULL;
+ modeMap[i].mode_hamlib = 0;
+ }
+
+ }
- }
#endif
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1038,63 +1043,63 @@ static int flrig_cleanup(RIG *rig)
*/
static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
- char value[MAXARGLEN];
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ char value[MAXARGLEN];
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
- rig_strvfo(vfo));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
+ rig_strvfo(vfo));
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- if (vfo == RIG_VFO_CURR)
- {
- vfo = rig->state.current_vfo;
- rig_debug(RIG_DEBUG_TRACE, "%s: get_freq2 vfo=%s\n",
- __func__, rig_strvfo(vfo));
- }
+ if (vfo == RIG_VFO_CURR)
+ {
+ vfo = rig->state.current_vfo;
+ rig_debug(RIG_DEBUG_TRACE, "%s: get_freq2 vfo=%s\n",
+ __func__, rig_strvfo(vfo));
+ }
- char *cmd = vfo == RIG_VFO_A ? "rig.get_vfoA" : "rig.get_vfoB";
- int retval;
+ char *cmd = vfo == RIG_VFO_A ? "rig.get_vfoA" : "rig.get_vfoB";
+ int retval;
- retval = flrig_transaction(rig, cmd, NULL, value, sizeof(value));
+ retval = flrig_transaction(rig, cmd, NULL, value, sizeof(value));
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: flrig_transaction failed retval=%s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: flrig_transaction failed retval=%s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- *freq = atof(value);
+ *freq = atof(value);
- if (*freq == 0)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: freq==0??\nvalue=%s\n", __func__,
- value);
- RETURNFUNC(-RIG_EPROTO);
- }
- else
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: freq=%.0f\n", __func__, *freq);
- }
+ if (*freq == 0)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: freq==0??\nvalue=%s\n", __func__,
+ value);
+ RETURNFUNC(-RIG_EPROTO);
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: freq=%.0f\n", __func__, *freq);
+ }
- if (vfo == RIG_VFO_A)
- {
- priv->curr_freqA = *freq;
- }
- else
- {
- priv->curr_freqB = *freq;
- }
+ if (vfo == RIG_VFO_A)
+ {
+ priv->curr_freqA = *freq;
+ }
+ else
+ {
+ priv->curr_freqB = *freq;
+ }
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1103,55 +1108,55 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
*/
static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
- int retval;
- char cmd_arg[MAXARGLEN];
- char *cmd;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ char cmd_arg[MAXARGLEN];
+ char *cmd;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.0f\n", __func__,
- rig_strvfo(vfo), freq);
+ rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.0f\n", __func__,
+ rig_strvfo(vfo), freq);
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- if (vfo == RIG_VFO_CURR)
- {
- vfo = rig->state.current_vfo;
- }
- else if (vfo == RIG_VFO_TX && priv->split)
- {
- vfo = RIG_VFO_B; // if split always TX on VFOB
- }
+ if (vfo == RIG_VFO_CURR)
+ {
+ vfo = rig->state.current_vfo;
+ }
+ else if (vfo == RIG_VFO_TX && priv->split)
+ {
+ vfo = RIG_VFO_B; // if split always TX on VFOB
+ }
- sprintf(cmd_arg,
- "%.0f", freq);
+ sprintf(cmd_arg,
+ "%.0f", freq);
- if (vfo == RIG_VFO_A)
- {
- cmd = "rig.set_vfoA";
- rig_debug(RIG_DEBUG_TRACE, "rig.set_vfoA %.0f\n", freq);
- priv->curr_freqA = freq;
- }
- else
- {
- cmd = "rig.set_vfoB";
- rig_debug(RIG_DEBUG_TRACE, "rig.set_vfoB %.0f\n", freq);
- priv->curr_freqB = freq;
- }
+ if (vfo == RIG_VFO_A)
+ {
+ cmd = "rig.set_vfoA";
+ rig_debug(RIG_DEBUG_TRACE, "rig.set_vfoA %.0f\n", freq);
+ priv->curr_freqA = freq;
+ }
+ else
+ {
+ cmd = "rig.set_vfoB";
+ rig_debug(RIG_DEBUG_TRACE, "rig.set_vfoB %.0f\n", freq);
+ priv->curr_freqB = freq;
+ }
- retval = flrig_transaction(rig, cmd, cmd_arg, NULL, 0);
+ retval = flrig_transaction(rig, cmd, cmd_arg, NULL, 0);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1160,34 +1165,34 @@ static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
*/
static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
- int retval;
- char cmd_arg[MAXARGLEN];
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ char cmd_arg[MAXARGLEN];
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d\n", __func__, ptt);
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d\n", __func__, ptt);
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- sprintf(cmd_arg,
- "%d",
- ptt);
- retval = flrig_transaction(rig, "rig.set_ptt", cmd_arg, NULL, 0);
+ sprintf(cmd_arg,
+ "%d",
+ ptt);
+ retval = flrig_transaction(rig, "rig.set_ptt", cmd_arg, NULL, 0);
- if (retval != RIG_OK)
- {
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ RETURNFUNC(retval);
+ }
- priv->ptt = ptt;
+ priv->ptt = ptt;
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1196,30 +1201,30 @@ static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
*/
static int flrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
- char value[MAXCMDLEN];
- char xml[MAXXMLLEN];
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ char value[MAXCMDLEN];
+ char xml[MAXXMLLEN];
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
- rig_strvfo(vfo));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
+ rig_strvfo(vfo));
- int retval;
+ int retval;
- retval = flrig_transaction(rig, "rig.get_ptt", NULL, value, sizeof(value));
+ retval = flrig_transaction(rig, "rig.get_ptt", NULL, value, sizeof(value));
- if (retval != RIG_OK)
- {
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ RETURNFUNC(retval);
+ }
- xml_parse(xml, value, sizeof(value));
- *ptt = atoi(value);
- rig_debug(RIG_DEBUG_TRACE, "%s: '%s'\n", __func__, value);
+ xml_parse(xml, value, sizeof(value));
+ *ptt = atoi(value);
+ rig_debug(RIG_DEBUG_TRACE, "%s: '%s'\n", __func__, value);
- priv->ptt = *ptt;
+ priv->ptt = *ptt;
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1227,42 +1232,42 @@ static int flrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
* Assumes rig!=NULL
*/
static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
- pbwidth_t width)
+ pbwidth_t width)
{
- int retval;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
- __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
+ __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
- switch (vfo)
- {
- case RIG_VFO_CURR:
- vfo = rig->state.current_vfo;
- break;
+ switch (vfo)
+ {
+ case RIG_VFO_CURR:
+ vfo = rig->state.current_vfo;
+ break;
- case RIG_VFO_TX:
- vfo = RIG_VFO_B;
- break;
- }
+ case RIG_VFO_TX:
+ vfo = RIG_VFO_B;
+ break;
+ }
- // If no change don't do it...modes are kept up to date by client calls
- // to get_mode and set_mode so should be current here
- rig_debug(RIG_DEBUG_TRACE, "%s: vfoa privmode=%s\n", __func__,
- rig_strrmode(priv->curr_modeA));
- rig_debug(RIG_DEBUG_TRACE, "%s: vfob privmode=%s\n", __func__,
- rig_strrmode(priv->curr_modeB));
+ // If no change don't do it...modes are kept up to date by client calls
+ // to get_mode and set_mode so should be current here
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfoa privmode=%s\n", __func__,
+ rig_strrmode(priv->curr_modeA));
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfob privmode=%s\n", __func__,
+ rig_strrmode(priv->curr_modeB));
- // save some VFO swapping .. may replace with VFO specific calls that won't cause VFO change
- if (vfo == RIG_VFO_A && mode == priv->curr_modeA) { RETURNFUNC(RIG_OK); }
+ // save some VFO swapping .. may replace with VFO specific calls that won't cause VFO change
+ if (vfo == RIG_VFO_A && mode == priv->curr_modeA) { RETURNFUNC(RIG_OK); }
- if (vfo == RIG_VFO_B && mode == priv->curr_modeB) { RETURNFUNC(RIG_OK); }
+ if (vfo == RIG_VFO_B && mode == priv->curr_modeB) { RETURNFUNC(RIG_OK); }
- retval = flrig_set_mode(rig, vfo, mode, width);
- rig_debug(RIG_DEBUG_TRACE, "%s: set mode=%s\n", __func__,
- rig_strrmode(mode));
- RETURNFUNC(retval);
+ retval = flrig_set_mode(rig, vfo, mode, width);
+ rig_debug(RIG_DEBUG_TRACE, "%s: set mode=%s\n", __func__,
+ rig_strrmode(mode));
+ RETURNFUNC(retval);
}
/*
@@ -1271,192 +1276,192 @@ static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
*/
static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
- int retval;
- int needBW;
- int vfoSwitched;
- char cmd_arg[MAXCMDLEN];
- char *p;
- char *pttmode;
- char *ttmode;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ int needBW;
+ int vfoSwitched;
+ char cmd_arg[MAXCMDLEN];
+ char *p;
+ char *pttmode;
+ char *ttmode;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
- __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
+ __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
- // if ptt is on do not set mode
- if (priv->ptt)
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: returning because priv->ptt=%d\n", __func__,
- (int)priv->ptt);
- RETURNFUNC(RIG_OK);
- }
+ // if ptt is on do not set mode
+ if (priv->ptt)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: returning because priv->ptt=%d\n", __func__,
+ (int)priv->ptt);
+ RETURNFUNC(RIG_OK);
+ }
- if (vfo == RIG_VFO_CURR)
- {
- vfo = rig->state.current_vfo;
- }
+ if (vfo == RIG_VFO_CURR)
+ {
+ vfo = rig->state.current_vfo;
+ }
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- if (priv->ptt)
- {
- rig_debug(RIG_DEBUG_WARN, "%s set_mode call not made as PTT=1\n", __func__);
- RETURNFUNC(RIG_OK); // just return OK and ignore this
- }
+ if (priv->ptt)
+ {
+ rig_debug(RIG_DEBUG_WARN, "%s set_mode call not made as PTT=1\n", __func__);
+ RETURNFUNC(RIG_OK); // just return OK and ignore this
+ }
- // Switch to VFOB if appropriate since we can't set mode directly
- // MDB
- vfoSwitched = 0;
- rig_debug(RIG_DEBUG_TRACE, "%s: curr_vfo = %s\n", __func__,
- rig_strvfo(rig->state.current_vfo));
+ // Switch to VFOB if appropriate since we can't set mode directly
+ // MDB
+ vfoSwitched = 0;
+ rig_debug(RIG_DEBUG_TRACE, "%s: curr_vfo = %s\n", __func__,
+ rig_strvfo(rig->state.current_vfo));
- // If we don't have the get_bwA call we have to switch VFOs ourself
- if (!priv->has_get_bwA && vfo == RIG_VFO_B
- && rig->state.current_vfo != RIG_VFO_B)
- {
- vfoSwitched = 1;
- rig_debug(RIG_DEBUG_TRACE, "%s: switch to VFOB = %d\n", __func__,
- vfoSwitched);
- }
+ // If we don't have the get_bwA call we have to switch VFOs ourself
+ if (!priv->has_get_bwA && vfo == RIG_VFO_B
+ && rig->state.current_vfo != RIG_VFO_B)
+ {
+ vfoSwitched = 1;
+ rig_debug(RIG_DEBUG_TRACE, "%s: switch to VFOB = %d\n", __func__,
+ vfoSwitched);
+ }
- if (vfoSwitched) // swap to B and we'll swap back later
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: switching to VFOB = %d\n", __func__,
- vfoSwitched);
- retval = flrig_set_vfo(rig, RIG_VFO_B);
+ if (vfoSwitched) // swap to B and we'll swap back later
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: switching to VFOB = %d\n", __func__,
+ vfoSwitched);
+ retval = flrig_set_vfo(rig, RIG_VFO_B);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
+ }
- // Set the mode
- ttmode = strdup(modeMapGetFLRig(mode));
- rig_debug(RIG_DEBUG_TRACE, "%s: got ttmode = %s\n", __func__,
- ttmode == NULL ? "NULL" : ttmode);
+ // Set the mode
+ ttmode = strdup(modeMapGetFLRig(mode));
+ rig_debug(RIG_DEBUG_TRACE, "%s: got ttmode = %s\n", __func__,
+ ttmode == NULL ? "NULL" : ttmode);
- if (ttmode == NULL)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: strdup failed\n", __func__);
- RETURNFUNC(-RIG_EINTERNAL);
- }
+ if (ttmode == NULL)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: strdup failed\n", __func__);
+ RETURNFUNC(-RIG_EINTERNAL);
+ }
// if (strncmp(ttmode,"ERROR",5)==0) RETURNFUNC(-RIG_EINTERN);
- pttmode = ttmode;
+ pttmode = ttmode;
- if (ttmode[0] == '|') { pttmode = &ttmode[1]; } // remove first pipe symbol
+ if (ttmode[0] == '|') { pttmode = &ttmode[1]; } // remove first pipe symbol
- p = strchr(pttmode, '|');
+ p = strchr(pttmode, '|');
- if (p) { *p = 0; } // remove any other pipe
+ if (p) { *p = 0; } // remove any other pipe
- sprintf(cmd_arg, "%s", pttmode);
- free(ttmode);
+ sprintf(cmd_arg, "%s", pttmode);
+ free(ttmode);
- if (!priv->has_get_modeA)
- {
- retval = flrig_transaction(rig, "rig.set_mode", cmd_arg, NULL, 0);
- }
- else
- {
- char *cmd = "rig.set_modeA";
+ if (!priv->has_get_modeA)
+ {
+ retval = flrig_transaction(rig, "rig.set_mode", cmd_arg, NULL, 0);
+ }
+ else
+ {
+ char *cmd = "rig.set_modeA";
- if (vfo == RIG_VFO_B)
- {
- cmd = "rig.set_modeB";
- }
- else
- {
- // we make VFO_B mode unknown so it expires the cache
- priv->curr_modeB = RIG_MODE_NONE;
- }
+ if (vfo == RIG_VFO_B)
+ {
+ cmd = "rig.set_modeB";
+ }
+ else
+ {
+ // we make VFO_B mode unknown so it expires the cache
+ priv->curr_modeB = RIG_MODE_NONE;
+ }
- retval = flrig_transaction(rig, cmd, cmd_arg, NULL, 0);
- }
+ retval = flrig_transaction(rig, cmd, cmd_arg, NULL, 0);
+ }
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: failed: %s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: failed: %s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- // Determine if we need to update the bandwidth
- needBW = 0;
+ // Determine if we need to update the bandwidth
+ needBW = 0;
- if (vfo == RIG_VFO_A)
- {
- needBW = priv->curr_widthA != width;
- rig_debug(RIG_DEBUG_TRACE, "%s: bw change on VFOA, curr width=%d needBW=%d\n",
- __func__, (int)width, needBW);
- }
- else if (vfo == RIG_VFO_B)
- {
- needBW = priv->curr_widthB != width;
- rig_debug(RIG_DEBUG_TRACE, "%s: bw change on VFOB, curr width=%d needBW=%d\n",
- __func__, (int)width, needBW);
- }
- else
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: needBW unknown vfo=%s\n", __func__,
- rig_strvfo(vfo));
- }
+ if (vfo == RIG_VFO_A)
+ {
+ needBW = priv->curr_widthA != width;
+ rig_debug(RIG_DEBUG_TRACE, "%s: bw change on VFOA, curr width=%d needBW=%d\n",
+ __func__, (int)width, needBW);
+ }
+ else if (vfo == RIG_VFO_B)
+ {
+ needBW = priv->curr_widthB != width;
+ rig_debug(RIG_DEBUG_TRACE, "%s: bw change on VFOB, curr width=%d needBW=%d\n",
+ __func__, (int)width, needBW);
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: needBW unknown vfo=%s\n", __func__,
+ rig_strvfo(vfo));
+ }
- // Need to update the bandwidth
- if (width > 0 && needBW)
- {
- sprintf(cmd_arg, "%ld",
- width);
+ // Need to update the bandwidth
+ if (width > 0 && needBW)
+ {
+ sprintf(cmd_arg, "%ld",
+ width);
- retval = flrig_transaction(rig, "rig.set_bandwidth", cmd_arg, NULL, 0);
+ retval = flrig_transaction(rig, "rig.set_bandwidth", cmd_arg, NULL, 0);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
+ }
- // Return to VFOA if needed
- rig_debug(RIG_DEBUG_TRACE, "%s: switch to VFOA? = %d\n", __func__,
- vfoSwitched);
+ // Return to VFOA if needed
+ rig_debug(RIG_DEBUG_TRACE, "%s: switch to VFOA? = %d\n", __func__,
+ vfoSwitched);
- if (vfoSwitched)
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: switching to VFOA\n", __func__);
- retval = flrig_set_vfo(rig, RIG_VFO_A);
+ if (vfoSwitched)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: switching to VFOA\n", __func__);
+ retval = flrig_set_vfo(rig, RIG_VFO_A);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
+ }
- if (vfo == RIG_VFO_A)
- {
- priv->curr_modeA = mode;
- priv->curr_widthA = width;
- }
- else
- {
- priv->curr_modeB = mode;
- priv->curr_widthB = width;
- }
+ if (vfo == RIG_VFO_A)
+ {
+ priv->curr_modeA = mode;
+ priv->curr_widthA = width;
+ }
+ else
+ {
+ priv->curr_modeB = mode;
+ priv->curr_widthB = width;
+ }
- rig_debug(RIG_DEBUG_TRACE,
- "%s: return modeA=%s, widthA=%d\n,modeB=%s, widthB=%d\n", __func__,
- rig_strrmode(priv->curr_modeA), (int)priv->curr_widthA,
- rig_strrmode(priv->curr_modeB), (int)priv->curr_widthB);
- RETURNFUNC(RIG_OK);
+ rig_debug(RIG_DEBUG_TRACE,
+ "%s: return modeA=%s, widthA=%d\n,modeB=%s, widthB=%d\n", __func__,
+ rig_strrmode(priv->curr_modeA), (int)priv->curr_widthA,
+ rig_strrmode(priv->curr_modeB), (int)priv->curr_widthB);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1465,157 +1470,157 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
*/
static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
- int retval;
- int vfoSwitched;
- char value[MAXCMDLEN];
- char *cmdp;
- vfo_t curr_vfo;
- rmode_t my_mode;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ int vfoSwitched;
+ char value[MAXCMDLEN];
+ char *cmdp;
+ vfo_t curr_vfo;
+ rmode_t my_mode;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
- rig_strvfo(vfo));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
+ rig_strvfo(vfo));
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- curr_vfo = rig->state.current_vfo;
+ curr_vfo = rig->state.current_vfo;
- if (vfo == RIG_VFO_CURR)
- {
- vfo = rig->state.current_vfo;
- }
+ if (vfo == RIG_VFO_CURR)
+ {
+ vfo = rig->state.current_vfo;
+ }
- rig_debug(RIG_DEBUG_TRACE, "%s: using vfo=%s\n", __func__,
- rig_strvfo(vfo));
+ rig_debug(RIG_DEBUG_TRACE, "%s: using vfo=%s\n", __func__,
+ rig_strvfo(vfo));
- if (priv->ptt)
- {
- if (vfo == RIG_VFO_A) { *mode = priv->curr_modeA; }
- else { *mode = priv->curr_modeB; }
+ if (priv->ptt)
+ {
+ if (vfo == RIG_VFO_A) { *mode = priv->curr_modeA; }
+ else { *mode = priv->curr_modeB; }
- rig_debug(RIG_DEBUG_WARN, "%s call not made as PTT=1\n", __func__);
- RETURNFUNC(RIG_OK); // just return OK and ignore this
- }
+ rig_debug(RIG_DEBUG_WARN, "%s call not made as PTT=1\n", __func__);
+ RETURNFUNC(RIG_OK); // just return OK and ignore this
+ }
- // Switch to VFOB if appropriate
- vfoSwitched = 0;
+ // Switch to VFOB if appropriate
+ vfoSwitched = 0;
- if (priv->has_get_modeA == 0 && vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B)
- {
- vfoSwitched = 1;
- }
+ if (priv->has_get_modeA == 0 && vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B)
+ {
+ vfoSwitched = 1;
+ }
- if (vfoSwitched)
- {
- rig_debug(RIG_DEBUG_TRACE, "%s switch to VFOB=%d\n", __func__,
- priv->has_get_modeA);
- retval = flrig_set_vfo(rig, RIG_VFO_B);
+ if (vfoSwitched)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s switch to VFOB=%d\n", __func__,
+ priv->has_get_modeA);
+ retval = flrig_set_vfo(rig, RIG_VFO_B);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
+ }
- cmdp = "rig.get_mode"; /* default to old way */
+ cmdp = "rig.get_mode"; /* default to old way */
- if (priv->has_get_modeA) /* change to new way if we can */
- {
- /* calling this way reduces VFO swapping */
- /* we get the cached value in flrig */
- /* vfo B may not be getting polled though in FLRig */
- /* so we may not be 100% accurate if op is twiddling knobs */
- cmdp = "rig.get_modeA";
+ if (priv->has_get_modeA) /* change to new way if we can */
+ {
+ /* calling this way reduces VFO swapping */
+ /* we get the cached value in flrig */
+ /* vfo B may not be getting polled though in FLRig */
+ /* so we may not be 100% accurate if op is twiddling knobs */
+ cmdp = "rig.get_modeA";
- if (vfo == RIG_VFO_B) { cmdp = "rig.get_modeB"; }
- }
+ if (vfo == RIG_VFO_B) { cmdp = "rig.get_modeB"; }
+ }
- retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value));
+ retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value));
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: %s failed: %s\n", __func__, cmdp,
- rigerror(retval));
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: %s failed: %s\n", __func__, cmdp,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- my_mode = modeMapGetHamlib(value);
- *mode = my_mode;
- rig_debug(RIG_DEBUG_TRACE, "%s: mode='%s'\n", __func__,
- rig_strrmode(*mode));
+ my_mode = modeMapGetHamlib(value);
+ *mode = my_mode;
+ rig_debug(RIG_DEBUG_TRACE, "%s: mode='%s'\n", __func__,
+ rig_strrmode(*mode));
- if (vfo == RIG_VFO_A)
- {
- priv->curr_modeA = *mode;
- }
- else
- {
- priv->curr_modeB = *mode;
- }
+ if (vfo == RIG_VFO_A)
+ {
+ priv->curr_modeA = *mode;
+ }
+ else
+ {
+ priv->curr_modeB = *mode;
+ }
- /* Get the bandwidth */
- cmdp = "rig.get_bw"; /* default to old way */
+ /* Get the bandwidth */
+ cmdp = "rig.get_bw"; /* default to old way */
- if (priv->has_get_bwA) /* change to new way if we can */
- {
- /* calling this way reduces VFO swapping */
- /* we get the cached value in flrig */
- /* vfo B may not be getting polled though in FLRig */
- /* so we may not be 100% accurate if op is twiddling knobs */
- cmdp = "rig.get_bwA";
+ if (priv->has_get_bwA) /* change to new way if we can */
+ {
+ /* calling this way reduces VFO swapping */
+ /* we get the cached value in flrig */
+ /* vfo B may not be getting polled though in FLRig */
+ /* so we may not be 100% accurate if op is twiddling knobs */
+ cmdp = "rig.get_bwA";
- if (vfo == RIG_VFO_B) { cmdp = "rig.get_bwB"; }
- }
+ if (vfo == RIG_VFO_B) { cmdp = "rig.get_bwB"; }
+ }
- retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value));
+ retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value));
- if (retval != RIG_OK)
- {
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ RETURNFUNC(retval);
+ }
- rig_debug(RIG_DEBUG_TRACE, "%s: mode=%s width='%s'\n", __func__,
- rig_strrmode(*mode), value);
+ rig_debug(RIG_DEBUG_TRACE, "%s: mode=%s width='%s'\n", __func__,
+ rig_strrmode(*mode), value);
- // we get 2 entries pipe separated for bandwidth, lower and upper
- if (strlen(value) > 0)
- {
- char *p = value;
+ // we get 2 entries pipe separated for bandwidth, lower and upper
+ if (strlen(value) > 0)
+ {
+ char *p = value;
- /* we might get two values and then we want the 2nd one */
- if (strchr(value, '|') != NULL) { p = strchr(value, '|') + 1; }
+ /* we might get two values and then we want the 2nd one */
+ if (strchr(value, '|') != NULL) { p = strchr(value, '|') + 1; }
- *width = atoi(p);
- }
+ *width = atoi(p);
+ }
- if (vfo == RIG_VFO_A)
- {
- priv->curr_widthA = *width;
- }
- else
- {
- priv->curr_widthB = *width;
- }
+ if (vfo == RIG_VFO_A)
+ {
+ priv->curr_widthA = *width;
+ }
+ else
+ {
+ priv->curr_widthB = *width;
+ }
- // Return to VFOA if needed
- if (vfoSwitched)
- {
- retval = flrig_set_vfo(rig, RIG_VFO_A);
+ // Return to VFOA if needed
+ if (vfoSwitched)
+ {
+ retval = flrig_set_vfo(rig, RIG_VFO_A);
- if (retval != RIG_OK)
- {
- RETURNFUNC(retval);
- }
- }
+ if (retval != RIG_OK)
+ {
+ RETURNFUNC(retval);
+ }
+ }
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1624,63 +1629,63 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
*/
static int flrig_set_vfo(RIG *rig, vfo_t vfo)
{
- int retval;
- char cmd_arg[MAXXMLLEN];
- struct rig_state *rs = &rig->state;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ char cmd_arg[MAXXMLLEN];
+ struct rig_state *rs = &rig->state;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
- rig_strvfo(vfo));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
+ rig_strvfo(vfo));
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- if (vfo == RIG_VFO_TX)
- {
- rig_debug(RIG_DEBUG_TRACE, "%s: RIG_VFO_TX used\n", __func__);
- vfo = RIG_VFO_B; // always TX on VFOB
- }
+ if (vfo == RIG_VFO_TX)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: RIG_VFO_TX used\n", __func__);
+ vfo = RIG_VFO_B; // always TX on VFOB
+ }
- if (vfo == RIG_VFO_CURR)
- {
- vfo = rig->state.current_vfo;
- }
+ if (vfo == RIG_VFO_CURR)
+ {
+ vfo = rig->state.current_vfo;
+ }
- sprintf(cmd_arg, "%s",
- vfo == RIG_VFO_A ? "A" : "B");
- retval = flrig_transaction(rig, "rig.set_AB", cmd_arg, NULL, 0);
+ sprintf(cmd_arg, "%s",
+ vfo == RIG_VFO_A ? "A" : "B");
+ retval = flrig_transaction(rig, "rig.set_AB", cmd_arg, NULL, 0);
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: rig.set_AB failed: %s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: rig.set_AB failed: %s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- rig->state.current_vfo = vfo;
- rs->tx_vfo = RIG_VFO_B; // always VFOB
+ rig->state.current_vfo = vfo;
+ rs->tx_vfo = RIG_VFO_B; // always VFOB
- /* for some rigs FLRig turns off split when VFOA is selected */
- /* so if we are in split and asked for A we have to turn split back on */
- if (priv->split && vfo == RIG_VFO_A)
- {
- sprintf(cmd_arg, "%d",
- priv->split);
- retval = flrig_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
+ /* for some rigs FLRig turns off split when VFOA is selected */
+ /* so if we are in split and asked for A we have to turn split back on */
+ if (priv->split && vfo == RIG_VFO_A)
+ {
+ sprintf(cmd_arg, "%d",
+ priv->split);
+ retval = flrig_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
+ }
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1689,49 +1694,49 @@ static int flrig_set_vfo(RIG *rig, vfo_t vfo)
*/
static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
{
- char value[MAXCMDLEN];
+ char value[MAXCMDLEN];
- ENTERFUNC;
+ ENTERFUNC;
- int retval;
- retval = flrig_transaction(rig, "rig.get_AB", NULL, value, sizeof(value));
+ int retval;
+ retval = flrig_transaction(rig, "rig.get_AB", NULL, value, sizeof(value));
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo value=%s\n", __func__, value);
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo value=%s\n", __func__, value);
- switch (value[0])
- {
- case 'A':
- *vfo = RIG_VFO_A;
- break;
+ switch (value[0])
+ {
+ case 'A':
+ *vfo = RIG_VFO_A;
+ break;
- case 'B':
- *vfo = RIG_VFO_B;
- break;
+ case 'B':
+ *vfo = RIG_VFO_B;
+ break;
- default:
- *vfo = RIG_VFO_CURR;
- RETURNFUNC(-RIG_EINVAL);
- }
+ default:
+ *vfo = RIG_VFO_CURR;
+ RETURNFUNC(-RIG_EINVAL);
+ }
- if (check_vfo(*vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(*vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(*vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(*vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- rig->state.current_vfo = *vfo;
+ rig->state.current_vfo = *vfo;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
- rig_strvfo(*vfo));
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
+ rig_strvfo(*vfo));
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1740,42 +1745,42 @@ static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
*/
static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
- int retval;
- char cmd_arg[MAXXMLLEN];
- freq_t qtx_freq;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ char cmd_arg[MAXXMLLEN];
+ freq_t qtx_freq;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
- rig_strvfo(vfo), tx_freq);
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
+ rig_strvfo(vfo), tx_freq);
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- // we always split on VFOB so if no change just return
- retval = flrig_get_freq(rig, RIG_VFO_B, &qtx_freq);
+ // we always split on VFOB so if no change just return
+ retval = flrig_get_freq(rig, RIG_VFO_B, &qtx_freq);
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- if (tx_freq == qtx_freq) { RETURNFUNC(RIG_OK); }
+ if (tx_freq == qtx_freq) { RETURNFUNC(RIG_OK); }
- sprintf(cmd_arg,
- "%.6f",
- tx_freq);
- retval = flrig_transaction(rig, "rig.set_vfoB", cmd_arg, NULL, 0);
+ sprintf(cmd_arg,
+ "%.6f",
+ tx_freq);
+ retval = flrig_transaction(rig, "rig.set_vfoB", cmd_arg, NULL, 0);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
- priv->curr_freqB = tx_freq;
+ priv->curr_freqB = tx_freq;
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1784,16 +1789,16 @@ static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
*/
static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
{
- int retval;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
- rig_strvfo(vfo));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
+ rig_strvfo(vfo));
- retval = flrig_get_freq(rig, RIG_VFO_B, tx_freq);
- priv->curr_freqB = *tx_freq;
- RETURNFUNC(retval);
+ retval = flrig_get_freq(rig, RIG_VFO_B, tx_freq);
+ priv->curr_freqB = *tx_freq;
+ RETURNFUNC(retval);
}
/*
@@ -1802,40 +1807,40 @@ static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
*/
static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
{
- int retval;
- vfo_t qtx_vfo;
- split_t qsplit;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- char cmd_arg[MAXXMLLEN];
+ int retval;
+ vfo_t qtx_vfo;
+ split_t qsplit;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ char cmd_arg[MAXXMLLEN];
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
- rig_strvfo(tx_vfo));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
+ rig_strvfo(tx_vfo));
- retval = flrig_get_split_vfo(rig, RIG_VFO_A, &qsplit, &qtx_vfo);
+ retval = flrig_get_split_vfo(rig, RIG_VFO_A, &qsplit, &qtx_vfo);
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- if (split == qsplit) { RETURNFUNC(RIG_OK); }
+ if (split == qsplit) { RETURNFUNC(RIG_OK); }
- if (priv->ptt)
- {
- rig_debug(RIG_DEBUG_WARN, "%s call not made as PTT=1\n", __func__);
- RETURNFUNC(RIG_OK); // just return OK and ignore this
- }
+ if (priv->ptt)
+ {
+ rig_debug(RIG_DEBUG_WARN, "%s call not made as PTT=1\n", __func__);
+ RETURNFUNC(RIG_OK); // just return OK and ignore this
+ }
- sprintf(cmd_arg, "%d",
- split);
- retval = flrig_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
+ sprintf(cmd_arg, "%d",
+ split);
+ retval = flrig_transaction(rig, "rig.set_split", cmd_arg, NULL, 0);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
- priv->split = split;
+ priv->split = split;
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1843,27 +1848,27 @@ static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
* assumes rig!=NULL, tx_freq!=NULL
*/
static int flrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
- vfo_t *tx_vfo)
+ vfo_t *tx_vfo)
{
- char value[MAXCMDLEN];
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ char value[MAXCMDLEN];
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
+ ENTERFUNC;
- int retval;
- retval = flrig_transaction(rig, "rig.get_split", NULL, value, sizeof(value));
+ int retval;
+ retval = flrig_transaction(rig, "rig.get_split", NULL, value, sizeof(value));
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
- *tx_vfo = RIG_VFO_B;
- *split = atoi(value);
- priv->split = *split;
- rig_debug(RIG_DEBUG_TRACE, "%s tx_vfo=%s, split=%d\n", __func__,
- rig_strvfo(*tx_vfo), *split);
- RETURNFUNC(RIG_OK);
+ *tx_vfo = RIG_VFO_B;
+ *split = atoi(value);
+ priv->split = *split;
+ rig_debug(RIG_DEBUG_TRACE, "%s tx_vfo=%s, split=%d\n", __func__,
+ rig_strvfo(*tx_vfo), *split);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1871,52 +1876,52 @@ static int flrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
* assumes rig!=NULL
*/
static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
- rmode_t mode, pbwidth_t width)
+ rmode_t mode, pbwidth_t width)
{
- int retval;
- rmode_t qmode;
- pbwidth_t qwidth;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ int retval;
+ rmode_t qmode;
+ pbwidth_t qwidth;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
+ ENTERFUNC;
- if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
- {
- RETURNFUNC(-RIG_ENTARGET);
- }
+ if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
+ {
+ RETURNFUNC(-RIG_ENTARGET);
+ }
- retval = flrig_set_freq(rig, RIG_VFO_B, freq);
+ retval = flrig_set_freq(rig, RIG_VFO_B, freq);
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s flrig_set_freq failed\n", __func__);
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s flrig_set_freq failed\n", __func__);
+ RETURNFUNC(retval);
+ }
- // Make VFOB mode match VFOA mode, keep VFOB width
- retval = flrig_get_mode(rig, RIG_VFO_B, &qmode, &qwidth);
+ // Make VFOB mode match VFOA mode, keep VFOB width
+ retval = flrig_get_mode(rig, RIG_VFO_B, &qmode, &qwidth);
- if (retval != RIG_OK) { RETURNFUNC(retval); }
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
- if (qmode == priv->curr_modeA) { RETURNFUNC(RIG_OK); }
+ if (qmode == priv->curr_modeA) { RETURNFUNC(RIG_OK); }
- if (priv->ptt)
- {
- rig_debug(RIG_DEBUG_WARN, "%s set_mode call not made as PTT=1\n", __func__);
- RETURNFUNC(RIG_OK); // just return OK and ignore this
- }
+ if (priv->ptt)
+ {
+ rig_debug(RIG_DEBUG_WARN, "%s set_mode call not made as PTT=1\n", __func__);
+ RETURNFUNC(RIG_OK); // just return OK and ignore this
+ }
- retval = flrig_set_mode(rig, RIG_VFO_B, priv->curr_modeA, width);
+ retval = flrig_set_mode(rig, RIG_VFO_B, priv->curr_modeA, width);
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s flrig_set_mode failed\n", __func__);
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s flrig_set_mode failed\n", __func__);
+ RETURNFUNC(retval);
+ }
- retval = flrig_set_vfo(rig, RIG_VFO_A);
+ retval = flrig_set_vfo(rig, RIG_VFO_A);
- RETURNFUNC(retval);
+ RETURNFUNC(retval);
}
/*
@@ -1924,73 +1929,73 @@ static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
* assumes rig!=NULL, freq!=NULL, mode!=NULL, width!=NULL
*/
static int flrig_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *freq,
- rmode_t *mode, pbwidth_t *width)
+ rmode_t *mode, pbwidth_t *width)
{
- int retval;
+ int retval;
- ENTERFUNC;
+ ENTERFUNC;
- if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
- {
- RETURNFUNC(-RIG_ENTARGET);
- }
+ if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
+ {
+ RETURNFUNC(-RIG_ENTARGET);
+ }
- retval = flrig_get_freq(rig, RIG_VFO_B, freq);
+ retval = flrig_get_freq(rig, RIG_VFO_B, freq);
- if (RIG_OK == retval)
- {
- retval = flrig_get_mode(rig, vfo, mode, width);
- }
+ if (RIG_OK == retval)
+ {
+ retval = flrig_get_mode(rig, vfo, mode, width);
+ }
- RETURNFUNC(retval);
+ RETURNFUNC(retval);
}
static int flrig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
- int retval;
- char cmd_arg[MAXARGLEN];
- char *cmd;
- char *param_type = "i4";
+ int retval;
+ char cmd_arg[MAXARGLEN];
+ char *cmd;
+ char *param_type = "i4";
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s level=%d, val=%f\n", __func__,
- rig_strvfo(vfo), (int)level, val.f);
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s level=%d, val=%f\n", __func__,
+ rig_strvfo(vfo), (int)level, val.f);
- if (check_vfo(vfo) == FALSE)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
- __func__, rig_strvfo(vfo));
- RETURNFUNC(-RIG_EINVAL);
- }
+ if (check_vfo(vfo) == FALSE)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
+ __func__, rig_strvfo(vfo));
+ RETURNFUNC(-RIG_EINVAL);
+ }
- switch (level)
- {
- case RIG_LEVEL_RF: cmd = "rig.set_rfgain"; val.f *= 100; break;
+ switch (level)
+ {
+ case RIG_LEVEL_RF: cmd = "rig.set_rfgain"; val.f *= 100; break;
- case RIG_LEVEL_AF: cmd = "rig.set_volume"; val.f *= 100; break;
+ case RIG_LEVEL_AF: cmd = "rig.set_volume"; val.f *= 100; break;
- case RIG_LEVEL_MICGAIN: cmd = "rig.set_micgain"; val.f *= 100; break;
+ case RIG_LEVEL_MICGAIN: cmd = "rig.set_micgain"; val.f *= 100; break;
- case RIG_LEVEL_RFPOWER: cmd = "rig.set_power"; val.f *= 100; break;
+ case RIG_LEVEL_RFPOWER: cmd = "rig.set_power"; val.f *= 100; break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: invalid level=%d\n", __func__, (int)level);
- RETURNFUNC(-RIG_EINVAL);
- }
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: invalid level=%d\n", __func__, (int)level);
+ RETURNFUNC(-RIG_EINVAL);
+ }
- sprintf(cmd_arg,
- "<%s>%d%s>",
- param_type, (int)val.f, param_type);
+ sprintf(cmd_arg,
+ "<%s>%d%s>",
+ param_type, (int)val.f, param_type);
- retval = flrig_transaction(rig, cmd, cmd_arg, NULL, 0);
+ retval = flrig_transaction(rig, cmd, cmd_arg, NULL, 0);
- if (retval < 0)
- {
- RETURNFUNC(retval);
- }
+ if (retval < 0)
+ {
+ RETURNFUNC(retval);
+ }
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -1999,76 +2004,76 @@ static int flrig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
*/
static int flrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
- char value[MAXARGLEN];
- char *cmd;
- int retval;
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ char value[MAXARGLEN];
+ char *cmd;
+ int retval;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
- rig_strvfo(vfo));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
+ rig_strvfo(vfo));
- switch (level)
- {
- case RIG_LEVEL_AF: cmd = "rig.get_volume"; break;
+ switch (level)
+ {
+ case RIG_LEVEL_AF: cmd = "rig.get_volume"; break;
- case RIG_LEVEL_RF: cmd = "rig.get_rfgain"; break;
+ case RIG_LEVEL_RF: cmd = "rig.get_rfgain"; break;
- case RIG_LEVEL_MICGAIN: cmd = "rig.get_micgain"; break;
+ case RIG_LEVEL_MICGAIN: cmd = "rig.get_micgain"; break;
- case RIG_LEVEL_STRENGTH: cmd = "rig.get_smeter"; break;
+ case RIG_LEVEL_STRENGTH: cmd = "rig.get_smeter"; break;
- case RIG_LEVEL_RFPOWER: cmd = "rig.get_power"; break;
+ case RIG_LEVEL_RFPOWER: cmd = "rig.get_power"; break;
- case RIG_LEVEL_RFPOWER_METER_WATTS:
- case RIG_LEVEL_RFPOWER_METER: cmd = "rig.get_pwrmeter"; break;
+ case RIG_LEVEL_RFPOWER_METER_WATTS:
+ case RIG_LEVEL_RFPOWER_METER: cmd = "rig.get_pwrmeter"; break;
- default:
- rig_debug(RIG_DEBUG_ERR, "%s: unknown level=%d\n", __func__, (int)level);
- RETURNFUNC(-RIG_EINVAL);
- }
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: unknown level=%d\n", __func__, (int)level);
+ RETURNFUNC(-RIG_EINVAL);
+ }
- retval = flrig_transaction(rig, cmd, NULL, value, sizeof(value));
+ retval = flrig_transaction(rig, cmd, NULL, value, sizeof(value));
- if (retval != RIG_OK)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: flrig_transaction failed retval=%s\n", __func__,
- rigerror(retval));
- RETURNFUNC(retval);
- }
+ if (retval != RIG_OK)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s: flrig_transaction failed retval=%s\n", __func__,
+ rigerror(retval));
+ RETURNFUNC(retval);
+ }
- // most levels are 0-100 -- may have to allow for different ranges
- switch (level)
- {
- case RIG_LEVEL_STRENGTH:
- val->i = atoi(value) - 54;
- //if (val->i > 0) val->i /= 10;
- rig_debug(RIG_DEBUG_TRACE, "%s: val.i='%s'(%d)\n", __func__, value, val->i);
- break;
+ // most levels are 0-100 -- may have to allow for different ranges
+ switch (level)
+ {
+ case RIG_LEVEL_STRENGTH:
+ val->i = atoi(value) - 54;
+ //if (val->i > 0) val->i /= 10;
+ rig_debug(RIG_DEBUG_TRACE, "%s: val.i='%s'(%d)\n", __func__, value, val->i);
+ break;
- case RIG_LEVEL_RFPOWER:
- val->f = atof(value) / 100.0 * priv->powermeter_scale;
- rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f);
- break;
+ case RIG_LEVEL_RFPOWER:
+ val->f = atof(value) / 100.0 * priv->powermeter_scale;
+ rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f);
+ break;
- case RIG_LEVEL_RFPOWER_METER:
- val->f = atof(value) / 100.0 * priv->powermeter_scale;
- rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f);
- break;
+ case RIG_LEVEL_RFPOWER_METER:
+ val->f = atof(value) / 100.0 * priv->powermeter_scale;
+ rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f);
+ break;
- case RIG_LEVEL_RFPOWER_METER_WATTS:
- val->f = atof(value) * priv->powermeter_scale;
- rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f);
- break;
+ case RIG_LEVEL_RFPOWER_METER_WATTS:
+ val->f = atof(value) * priv->powermeter_scale;
+ rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f);
+ break;
- default:
- val->f = atof(value) / 100;
- rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%f)\n", __func__, value, val->f);
- }
+ default:
+ val->f = atof(value) / 100;
+ rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%f)\n", __func__, value, val->f);
+ }
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
/*
@@ -2077,38 +2082,38 @@ static int flrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
*/
static const char *flrig_get_info(RIG *rig)
{
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- return(priv->info);
+ return (priv->info);
}
static int flrig_power2mW(RIG *rig, unsigned int *mwpower, float power,
- freq_t freq, rmode_t mode)
+ freq_t freq, rmode_t mode)
{
- struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: passed power = %f\n", __func__, power);
- rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq);
- rig_debug(RIG_DEBUG_TRACE, "%s: passed mode = %s\n", __func__,
- rig_strrmode(mode));
+ struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: passed power = %f\n", __func__, power);
+ rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq);
+ rig_debug(RIG_DEBUG_TRACE, "%s: passed mode = %s\n", __func__,
+ rig_strrmode(mode));
- power *= priv->powermeter_scale;
- *mwpower = (power * 100000);
+ power *= priv->powermeter_scale;
+ *mwpower = (power * 100000);
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
static int flrig_mW2power(RIG *rig, float *power, unsigned int mwpower,
- freq_t freq, rmode_t mode)
+ freq_t freq, rmode_t mode)
{
- ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: passed mwpower = %u\n", __func__, mwpower);
- rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq);
- rig_debug(RIG_DEBUG_TRACE, "%s: passed mode = %s\n", __func__,
- rig_strrmode(mode));
+ ENTERFUNC;
+ rig_debug(RIG_DEBUG_TRACE, "%s: passed mwpower = %u\n", __func__, mwpower);
+ rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq);
+ rig_debug(RIG_DEBUG_TRACE, "%s: passed mode = %s\n", __func__,
+ rig_strrmode(mode));
- *power = ((float)mwpower / 100000);
+ *power = ((float)mwpower / 100000);
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(RIG_OK);
}
diff --git a/rigs/dummy/flrig.h b/rigs/dummy/flrig.h
index 3eca86304..464a8db0b 100644
--- a/rigs/dummy/flrig.h
+++ b/rigs/dummy/flrig.h
@@ -28,7 +28,7 @@
#include
#endif
-#define BACKEND_VER "20210312"
+#define BACKEND_VER "20210315"
#define EOM "\r"
#define TRUE 1
diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c
index 718233efc..3eaf8df75 100644
--- a/rigs/dummy/netrigctl.c
+++ b/rigs/dummy/netrigctl.c
@@ -526,13 +526,15 @@ static int netrigctl_open(RIG *rig)
gran_t parm_gran[RIG_SETTING_MAX]; /*!< parm granularity */
#endif
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(rs->rx_range_list[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(rs->rx_range_list[i]); i++)
{
rs->mode_list |= rs->rx_range_list[i].modes;
rs->vfo_list |= rs->rx_range_list[i].vfo;
}
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(rs->tx_range_list[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(rs->tx_range_list[i]); i++)
{
rs->mode_list |= rs->tx_range_list[i].modes;
rs->vfo_list |= rs->tx_range_list[i].vfo;
diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c
index 9832eb9c3..5e7076257 100644
--- a/rigs/icom/frame.c
+++ b/rigs/icom/frame.c
@@ -279,17 +279,21 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
}
if (frm_len < ACKFRMLEN) { RETURNFUNC(-RIG_EPROTO); }
+
// if we send a bad command we will get back a NAK packet
// e.g. fe fe e0 50 fa fd
if (frm_len == 6 && NAK == buf[frm_len - 2]) { RETURNFUNC(-RIG_ERJCTED); }
- rig_debug(RIG_DEBUG_TRACE, "%s: frm_len=%d, frm_len-1=%02x, frm_len-2=%02x\n", __func__, frm_len, buf[frm_len-1], buf[frm_len-2]);
+ rig_debug(RIG_DEBUG_TRACE, "%s: frm_len=%d, frm_len-1=%02x, frm_len-2=%02x\n",
+ __func__, frm_len, buf[frm_len - 1], buf[frm_len - 2]);
// has to be one of these two now or frame is corrupt
if (FI != buf[frm_len - 1] && ACK != buf[frm_len - 1]) { RETURNFUNC(-RIG_BUSBUSY); }
*data_len = frm_len - (ACKFRMLEN - 1);
+
if (*data_len <= 0) { RETURNFUNC(-RIG_EPROTO); }
+
memcpy(data, buf + 4, *data_len);
/*
diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c
index 6cecd81b0..7d24c0cc6 100644
--- a/rigs/icom/icom.c
+++ b/rigs/icom/icom.c
@@ -1024,7 +1024,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
subcmd = -1;
retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf,
&ack_len);
- hl_usleep(50*1000); // pause for transceive message and we'll flush it
+ hl_usleep(50 * 1000); // pause for transceive message and we'll flush it
if (retval != RIG_OK)
{
@@ -1663,8 +1663,8 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode,
rig_debug(RIG_DEBUG_VERBOSE, "%s mode=%d, width=%d\n", __func__, (int)icom_mode,
(int)width);
retval = icom_set_mode(rig, vfo, icom_mode, width);
-
- hl_usleep(50*1000); // pause for possible transceive message which we'll flush
+
+ hl_usleep(50 * 1000); // pause for possible transceive message which we'll flush
if (RIG_OK == retval)
{
@@ -3204,13 +3204,16 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
val->f =
rig_raw2val_float(icom_val, &icom_default_rfpower_meter_cal);
- rig_debug(RIG_DEBUG_TRACE, "%s: using rig table to convert %d to %.01f\n", __func__, icom_val, val->f);
+ rig_debug(RIG_DEBUG_TRACE, "%s: using rig table to convert %d to %.01f\n",
+ __func__, icom_val, val->f);
}
else
{
val->f =
rig_raw2val_float(icom_val, &rig->caps->rfpower_meter_cal);
- rig_debug(RIG_DEBUG_TRACE, "%s: using default icom table to convert %d to %.01f\n", __func__, icom_val, val->f);
+ rig_debug(RIG_DEBUG_TRACE,
+ "%s: using default icom table to convert %d to %.01f\n", __func__, icom_val,
+ val->f);
}
break;
diff --git a/rigs/kenwood/flex6xxx.c b/rigs/kenwood/flex6xxx.c
index f2229c67e..06d956005 100644
--- a/rigs/kenwood/flex6xxx.c
+++ b/rigs/kenwood/flex6xxx.c
@@ -877,6 +877,7 @@ int powersdr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_AF:
n = sscanf(lvlbuf, "ZZAG%f", &val->f);
+
if (n != 1)
{
rig_debug(RIG_DEBUG_ERR, "%s: Error parsing value from lvlbuf='%s'\n",
@@ -884,6 +885,7 @@ int powersdr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
val->f = 0;
return -RIG_EPROTO;
}
+
val->f /= 100.0;
break;
diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c
index d93ff6d1e..2ad5cfe0f 100644
--- a/rigs/kenwood/k3.c
+++ b/rigs/kenwood/k3.c
@@ -1101,7 +1101,7 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
switch (mode)
{
- case RIG_MODE_PKTLSB:
+ case RIG_MODE_PKTLSB:
mode = RIG_MODE_RTTY; // in "DT0" Subband RIG_MODE_RTTYR = USB and RIG_MODE_RTTY = LSB
snprintf(cmd_m, sizeof(cmd_m),
"DT0"); /* DATA A mode - DATA (REV) on LSB optimized for HF Packet, VFO dial is suppressed carrier QRG */
@@ -1485,7 +1485,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
"DT2"); /* FSK D mode - direct FSK on USB optimized for RTTY, VFO dial is MARK */
break;
- case RIG_MODE_PSK:
+ case RIG_MODE_PSK:
tx_mode = RIG_MODE_PSK;
snprintf(cmd_m, sizeof(cmd_m),
"DT3"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */
diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c
index 798be67ba..2fb25aa0a 100644
--- a/rigs/kenwood/kenwood.c
+++ b/rigs/kenwood/kenwood.c
@@ -1001,8 +1001,8 @@ static int kenwood_get_if(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
- return(kenwood_safe_transaction(rig, "IF", priv->info,
- KENWOOD_MAX_BUF_LEN, caps->if_len));
+ return (kenwood_safe_transaction(rig, "IF", priv->info,
+ KENWOOD_MAX_BUF_LEN, caps->if_len));
}
@@ -3752,6 +3752,7 @@ int kenwood_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
default: RETURNFUNC(-RIG_EINVAL);
}
+
int retval = kenwood_transaction(rig, ptt_cmd, NULL, 0);
RETURNFUNC(retval);
@@ -4573,25 +4574,25 @@ const char *kenwood_get_info(RIG *rig)
if (!rig)
{
- return("*rig == NULL");
+ return ("*rig == NULL");
}
retval = kenwood_safe_transaction(rig, "TY", firmbuf, 10, 5);
if (retval != RIG_OK)
{
- return(NULL);
+ return (NULL);
}
switch (firmbuf[4])
{
- case '0': return("Firmware: Overseas type");
+ case '0': return ("Firmware: Overseas type");
- case '1': return("Firmware: Japanese 100W type");
+ case '1': return ("Firmware: Japanese 100W type");
- case '2': return("Firmware: Japanese 20W type");
+ case '2': return ("Firmware: Japanese 20W type");
- default: return("Firmware: unknown");
+ default: return ("Firmware: unknown");
}
}
diff --git a/rigs/kit/hiqsdr.c b/rigs/kit/hiqsdr.c
index bbb956812..17b8b2962 100644
--- a/rigs/kit/hiqsdr.c
+++ b/rigs/kit/hiqsdr.c
@@ -307,7 +307,8 @@ int hiqsdr_init(RIG *rig)
priv->split = RIG_SPLIT_OFF;
priv->ref_clock = REFCLOCK;
priv->sample_rate = DEFAULT_SAMPLE_RATE;
- strncpy(rig->state.rigport.pathname, "192.168.2.196:48248", HAMLIB_FILPATHLEN - 1);
+ strncpy(rig->state.rigport.pathname, "192.168.2.196:48248",
+ HAMLIB_FILPATHLEN - 1);
return RIG_OK;
}
diff --git a/rigs/winradio/winradio.c b/rigs/winradio/winradio.c
index 84c3428be..522a3a82b 100644
--- a/rigs/winradio/winradio.c
+++ b/rigs/winradio/winradio.c
@@ -46,7 +46,8 @@
int wr_rig_init(RIG *rig)
{
rig->state.rigport.type.rig = RIG_PORT_DEVICE;
- strncpy(rig->state.rigport.pathname, DEFAULT_WINRADIO_PATH, HAMLIB_FILPATHLEN - 1);
+ strncpy(rig->state.rigport.pathname, DEFAULT_WINRADIO_PATH,
+ HAMLIB_FILPATHLEN - 1);
return RIG_OK;
}
diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c
index 1809eacf1..5fcc36ecf 100644
--- a/rigs/yaesu/ft1000mp.c
+++ b/rigs/yaesu/ft1000mp.c
@@ -1167,7 +1167,9 @@ int ft1000mp_get_vfo(RIG *rig, vfo_t *vfo)
else // we are emulating vfo status
{
*vfo = rig->state.current_vfo;
- if (*vfo == RIG_VFO_CURR) {
+
+ if (*vfo == RIG_VFO_CURR)
+ {
rig_debug(RIG_DEBUG_TRACE, "%s: no get_vfo, defaulting to VFOA\n", __func__);
*vfo = RIG_VFO_A;
}
diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c
index e69c6223f..105f4098e 100644
--- a/rigs/yaesu/newcat.c
+++ b/rigs/yaesu/newcat.c
@@ -510,7 +510,8 @@ int newcat_open(RIG *rig)
ENTERFUNC;
- rig_debug(RIG_DEBUG_TRACE, "%s: Rig=%s, version=%s\n", __func__, rig->caps->model_name, rig->caps->version);
+ rig_debug(RIG_DEBUG_TRACE, "%s: Rig=%s, version=%s\n", __func__,
+ rig->caps->model_name, rig->caps->version);
rig_debug(RIG_DEBUG_TRACE, "%s: write_delay = %i msec\n",
__func__, rig_s->rigport.write_delay);
@@ -597,6 +598,7 @@ int newcat_close(RIG *rig)
case it's not
supported */
}
+
if (priv->poweron != 0 && rig_s->auto_power_off)
{
rig_set_powerstat(rig, 0);
@@ -3182,7 +3184,8 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
rig_debug(RIG_DEBUG_TRACE, "%s: Wait #%d for power up\n", __func__, i + 1);
retval = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
- if (retval != RIG_OK) RETURNFUNC(retval);
+
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
}
}
@@ -3471,7 +3474,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
fpf = newcat_scale_float(scale, val.f);
- if (is_ft950 || is_ft891 || is_ft991 || is_ftdx3000 || is_ftdx101d || is_ftdx101mp || is_ftdx10)
+ if (is_ft950 || is_ft891 || is_ft991 || is_ftdx3000 || is_ftdx101d
+ || is_ftdx101mp || is_ftdx10)
{
// Minimum is 5 watts on these rigs
if (fpf < 5)
@@ -3661,7 +3665,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
if (val.f > 1.0) { RETURNFUNC(-RIG_EINVAL); }
- if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d || is_ftdx101mp
+ if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d
+ || is_ftdx101mp
|| is_ftdx10)
{
fpf = newcat_scale_float(100, val.f);
@@ -3691,7 +3696,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ftdx101d || is_ftdx101mp) // new format for the command with VFO selection
+ if (is_ftdx101d
+ || is_ftdx101mp) // new format for the command with VFO selection
{
format = "MS0%d;";
@@ -4216,7 +4222,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
if (val.f > 1.0) { RETURNFUNC(-RIG_EINVAL); }
- if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d || is_ftdx101mp
+ if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d
+ || is_ftdx101mp
|| is_ftdx10)
{
fpf = newcat_scale_float(100, val.f);
@@ -4859,7 +4866,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
break;
case RIG_LEVEL_MICGAIN:
- if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d || is_ftdx101mp
+ if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d
+ || is_ftdx101mp
|| is_ftdx10)
{
scale = 100.;
@@ -5171,7 +5179,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
break;
case RIG_LEVEL_MONITOR_GAIN:
- if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d || is_ftdx101mp)
+ if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d
+ || is_ftdx101mp)
{
scale = 100.;
}
@@ -5422,7 +5431,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
newcat_get_mode(rig, vfo, &mode, &width);
}
- if (is_ft891 || is_ft991 || is_ftdx1200 || is_ftdx3000 || is_ftdx101d || is_ftdx101mp)
+ if (is_ft891 || is_ft991 || is_ftdx1200 || is_ftdx3000 || is_ftdx101d
+ || is_ftdx101mp)
{
// There seems to be an error in the manuals for some of these rigs stating that values should be 1 = OFF and 2 = ON, but they are 0 = OFF and 1 = ON instead
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "PR0%d%c", status ? 1 : 0,
@@ -5662,7 +5672,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
RETURNFUNC(-RIG_ENAVAIL);
}
- if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d || is_ftdx101mp)
+ if (is_ftdx1200 || is_ftdx3000 || is_ft891 || is_ft991 || is_ftdx101d
+ || is_ftdx101mp)
{
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "PR0%c", cat_term);
}
@@ -6567,13 +6578,13 @@ const char *newcat_get_info(RIG *rig)
/* Get Identification Channel */
if (RIG_OK != newcat_get_cmd(rig))
{
- return(NULL);
+ return (NULL);
}
priv->ret_data[6] = '\0';
snprintf(idbuf, sizeof(idbuf), "%s", priv->ret_data);
- return(idbuf);
+ return (idbuf);
}
@@ -6623,7 +6634,8 @@ ncboolean newcat_valid_command(RIG *rig, char const *const command)
is_ftdx10 = newcat_is_rig(rig, RIG_MODEL_FTDX10);
if (!is_ft450 && !is_ft950 && !is_ft891 && !is_ft991 && !is_ft2000
- && !is_ftdx5000 && !is_ftdx9000 && !is_ftdx1200 && !is_ftdx3000 && !is_ftdx101d && !is_ftdx101mp && !is_ftdx10)
+ && !is_ftdx5000 && !is_ftdx9000 && !is_ftdx1200 && !is_ftdx3000 && !is_ftdx101d
+ && !is_ftdx101mp && !is_ftdx10)
{
rig_debug(RIG_DEBUG_ERR, "%s: '%s' is unknown\n", __func__, caps->model_name);
RETURNFUNC(FALSE);
@@ -9689,7 +9701,7 @@ int newcat_set_cmd_validate(RIG *rig)
// For FA and FB rig.c now tries to verify the set_freq actually works
// For example the FT-2000 can't do a FA set followed by an immediate read
- // We were using "ID" to verify the command but rig.c now does
+ // We were using "ID" to verify the command but rig.c now does
// a verifcation of frequency and retries if it doesn't match
if ((strncmp(priv->cmd_str, "FA", 2) == 0) && (strlen(priv->cmd_str) > 3))
{
diff --git a/src/rig.c b/src/rig.c
index 2745504bb..af5f686a2 100644
--- a/src/rig.c
+++ b/src/rig.c
@@ -311,8 +311,9 @@ const char *HAMLIB_API rigerror(int errnum)
if (*p == '\n') { *p = 0; }
- snprintf(msg, sizeof(msg), "%.80s\n%.15000s%.15000s%.15000s", rigerror_table[errnum],
- debugmsgsave3,debugmsgsave2, debugmsgsave);
+ snprintf(msg, sizeof(msg), "%.80s\n%.15000s%.15000s%.15000s",
+ rigerror_table[errnum],
+ debugmsgsave3, debugmsgsave2, debugmsgsave);
return msg;
}
@@ -375,7 +376,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
if (!caps)
{
- return(NULL);
+ return (NULL);
}
/*
@@ -390,7 +391,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
* FIXME: how can the caller know it's a memory shortage,
* and not "rig not found" ?
*/
- return(NULL);
+ return (NULL);
}
/* caps is const, so we need to tell compiler
@@ -518,25 +519,29 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
rs->vfo_list = 0;
rs->mode_list = 0;
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(caps->rx_range_list1[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(caps->rx_range_list1[i]); i++)
{
rs->vfo_list |= caps->rx_range_list1[i].vfo;
rs->mode_list |= caps->rx_range_list1[i].modes;
}
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(caps->tx_range_list1[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(caps->tx_range_list1[i]); i++)
{
rs->vfo_list |= caps->tx_range_list1[i].vfo;
rs->mode_list |= caps->tx_range_list1[i].modes;
}
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(caps->rx_range_list2[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(caps->rx_range_list2[i]); i++)
{
rs->vfo_list |= caps->rx_range_list2[i].vfo;
rs->mode_list |= caps->rx_range_list2[i].modes;
}
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(caps->tx_range_list2[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(caps->tx_range_list2[i]); i++)
{
rs->vfo_list |= caps->tx_range_list2[i].vfo;
rs->mode_list |= caps->tx_range_list2[i].modes;
@@ -613,11 +618,11 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
__func__);
/* cleanup and exit */
free(rig);
- return(NULL);
+ return (NULL);
}
}
- return(rig);
+ return (rig);
}
@@ -1324,13 +1329,16 @@ int HAMLIB_API rig_get_twiddle(RIG *rig, int *seconds)
static int set_cache_mode(RIG *rig, vfo_t vfo, mode_t mode, pbwidth_t width)
{
ENTERFUNC;
+
if (vfo == RIG_VFO_CURR)
{
// if CURR then update this before we figure out the real VFO
vfo = rig->state.current_vfo;
}
+
// pick a sane default
- if (vfo == RIG_VFO_NONE || vfo == RIG_VFO_CURR) vfo = RIG_VFO_A;
+ if (vfo == RIG_VFO_NONE || vfo == RIG_VFO_CURR) { vfo = RIG_VFO_A; }
+
switch (vfo)
{
case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches
@@ -1341,29 +1349,39 @@ static int set_cache_mode(RIG *rig, vfo_t vfo, mode_t mode, pbwidth_t width)
elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE);
elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE);
break;
+
case RIG_VFO_A:
case RIG_VFO_MAIN:
case RIG_VFO_MAIN_A:
rig->state.cache.modeMainA = mode;
- if (width > 0) rig->state.cache.widthMainA = width;
+
+ if (width > 0) { rig->state.cache.widthMainA = width; }
+
elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_SET);
elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_SET);
break;
+
case RIG_VFO_B:
case RIG_VFO_SUB:
case RIG_VFO_MAIN_B:
rig->state.cache.modeMainB = mode;
- if (width > 0) rig->state.cache.widthMainB = width;
+
+ if (width > 0) { rig->state.cache.widthMainB = width; }
+
elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_SET);
elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_SET);
break;
+
case RIG_VFO_C:
case RIG_VFO_MAIN_C:
rig->state.cache.modeMainC = mode;
- if (width > 0) rig->state.cache.widthMainC = width;
+
+ if (width > 0) { rig->state.cache.widthMainC = width; }
+
elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_SET);
elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_SET);
break;
+
default:
rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo));
RETURNFUNC(-RIG_EINTERNAL);
@@ -1383,8 +1401,9 @@ static int set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq)
// if CURR then update this before we figure out the real VFO
vfo = rig->state.current_vfo;
}
+
// pick a sane default
- if (vfo == RIG_VFO_NONE || vfo == RIG_VFO_CURR) vfo = RIG_VFO_A;
+ if (vfo == RIG_VFO_NONE || vfo == RIG_VFO_CURR) { vfo = RIG_VFO_A; }
rig_debug(RIG_DEBUG_TRACE, "%s: set vfo=%s to freq=%.0f\n", __func__,
rig_strvfo(vfo), freq);
@@ -1459,13 +1478,15 @@ static int set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq)
RETURNFUNC(RIG_OK);
}
-int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width)
+int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
+ rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width)
{
ENTERFUNC;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, current_vfo=%s\n", __func__,
rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo));
if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
+
// pick a sane default
if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_NONE) { vfo = RIG_VFO_A; }
@@ -1478,9 +1499,12 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, rmode_t
*freq = rig->state.cache.freqMainA;
*mode = rig->state.cache.modeMainA;
*width = rig->state.cache.widthMainA;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainA, HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_GET);
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainA,
+ HAMLIB_ELAPSED_GET);
break;
case RIG_VFO_B:
@@ -1488,27 +1512,36 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, rmode_t
*freq = rig->state.cache.freqMainB;
*mode = rig->state.cache.modeMainB;
*width = rig->state.cache.widthMainB;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainB, HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_GET);
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainB,
+ HAMLIB_ELAPSED_GET);
break;
case RIG_VFO_SUB_A:
*freq = rig->state.cache.freqSubA;
*mode = rig->state.cache.modeSubA;
*width = rig->state.cache.widthSubA;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubA, HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubA, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubA, HAMLIB_ELAPSED_GET);
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubA,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubA,
+ HAMLIB_ELAPSED_GET);
break;
case RIG_VFO_SUB_B:
*freq = rig->state.cache.freqSubB;
*mode = rig->state.cache.modeSubB;
*width = rig->state.cache.widthSubB;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubB, HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubB, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubB, HAMLIB_ELAPSED_GET);
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubB,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubB,
+ HAMLIB_ELAPSED_GET);
break;
case RIG_VFO_C:
@@ -1516,18 +1549,24 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, rmode_t
*freq = rig->state.cache.freqMainC;
*mode = rig->state.cache.modeMainC;
*width = rig->state.cache.widthMainC;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainC, HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_GET);
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainC,
+ HAMLIB_ELAPSED_GET);
break;
case RIG_VFO_SUB_C:
*freq = rig->state.cache.freqSubC;
*mode = rig->state.cache.modeSubC;
*width = rig->state.cache.widthSubC;
- *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubC, HAMLIB_ELAPSED_GET);
- *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubC, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubC, HAMLIB_ELAPSED_GET);
+ *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubC,
+ HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubC,
+ HAMLIB_ELAPSED_GET);
break;
case RIG_VFO_MEM:
@@ -1536,7 +1575,8 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, rmode_t
*width = rig->state.cache.widthMem;
*cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_GET);
*cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMem, HAMLIB_ELAPSED_GET);
- *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMem, HAMLIB_ELAPSED_GET);
+ *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMem,
+ HAMLIB_ELAPSED_GET);
break;
default:
@@ -1694,7 +1734,9 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
if (retry == 0 && tfreq != freq)
{
- rig_debug(RIG_DEBUG_ERR, "%s: unable to set frequency!!, asked for %.0f, got %.0f\n", __func__, freq, tfreq);
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: unable to set frequency!!, asked for %.0f, got %.0f\n", __func__, freq,
+ tfreq);
}
}
else
@@ -1774,6 +1816,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// update our current freq too
if (vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { rig->state.current_freq = freq_new; }
+
set_cache_freq(rig, vfo, freq_new);
RETURNFUNC(retcode);
@@ -1831,7 +1874,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_strvfo(rig->state.tx_vfo));
// always return the cached freq for this clause
int cache_ms_freq, cache_ms_mode, cache_ms_width;
- rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width, &cache_ms_width);
+ rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width,
+ &cache_ms_width);
RETURNFUNC(RIG_OK);
}
@@ -1862,8 +1906,10 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
int cache_ms_freq, cache_ms_mode, cache_ms_width;
- rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width, &cache_ms_width);
- rig_debug(RIG_DEBUG_TRACE, "%s: cache check1 age=%dms\n", __func__, cache_ms_freq);
+ rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width,
+ &cache_ms_width);
+ rig_debug(RIG_DEBUG_TRACE, "%s: cache check1 age=%dms\n", __func__,
+ cache_ms_freq);
if (freq != 0 && cache_ms_freq < rig->state.cache.timeout_ms)
{
@@ -1874,7 +1920,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
else
{
rig_debug(RIG_DEBUG_TRACE,
- "%s: cache miss age=%dms, cached_vfo=%s, asked_vfo=%s\n", __func__, cache_ms_freq,
+ "%s: cache miss age=%dms, cached_vfo=%s, asked_vfo=%s\n", __func__,
+ cache_ms_freq,
rig_strvfo(vfo), rig_strvfo(vfo));
}
@@ -1900,13 +1947,14 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
retcode = caps->get_freq(rig, vfo, freq);
- // sometimes a network rig like FLRig will return freq=0
+ // sometimes a network rig like FLRig will return freq=0
// so we'll just reuse the cache for that condition
- if (*freq == 0) {
+ if (*freq == 0)
+ {
rmode_t mode;
pbwidth_t width;
- int freq_ms,mode_ms,width_ms;
- rig_get_cache(rig,vfo,freq,&freq_ms,&mode,&mode_ms,&width,&width_ms);
+ int freq_ms, mode_ms, width_ms;
+ rig_get_cache(rig, vfo, freq, &freq_ms, &mode, &mode_ms, &width, &width_ms);
}
if (retcode == RIG_OK)
@@ -2033,7 +2081,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|| vfo == rig->state.current_vfo)
{
retcode = caps->set_mode(rig, vfo, mode, width);
- rig_debug(RIG_DEBUG_TRACE, "%s: targetable retcode after set_mode=%d\n", __func__,
+ rig_debug(RIG_DEBUG_TRACE, "%s: targetable retcode after set_mode=%d\n",
+ __func__,
retcode);
}
else
@@ -2042,6 +2091,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
vfo_t curr_vfo;
rig_debug(RIG_DEBUG_TRACE, "%s: not targetable need vfo swap\n", __func__);
+
if (!caps->set_vfo)
{
RETURNFUNC(-RIG_ENAVAIL);
@@ -2066,10 +2116,10 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
}
}
- if (retcode != RIG_OK) RETURNFUNC(retcode);
+ if (retcode != RIG_OK) { RETURNFUNC(retcode); }
+
+ set_cache_mode(rig, vfo, mode, width);
- set_cache_mode(rig,vfo,mode,width);
-
RETURNFUNC(retcode);
}
@@ -2117,19 +2167,23 @@ int HAMLIB_API rig_get_mode(RIG *rig,
}
int cache_ms_freq, cache_ms_mode, cache_ms_width;
- rig_get_cache(rig, vfo, &freq, &cache_ms_freq, mode, &cache_ms_mode, width, &cache_ms_width);
+ rig_get_cache(rig, vfo, &freq, &cache_ms_freq, mode, &cache_ms_mode, width,
+ &cache_ms_width);
rig_debug(RIG_DEBUG_TRACE, "%s: %s cache check age=%dms\n", __func__,
rig_strvfo(vfo), cache_ms_freq);
- if (cache_ms_mode < rig->state.cache.timeout_ms || cache_ms_width < rig->state.cache.timeout_ms)
+ if (cache_ms_mode < rig->state.cache.timeout_ms
+ || cache_ms_width < rig->state.cache.timeout_ms)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age mode=%dms, width=%dms\n", __func__, cache_ms_mode, cache_ms_width);
+ rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age mode=%dms, width=%dms\n",
+ __func__, cache_ms_mode, cache_ms_width);
RETURNFUNC(RIG_OK);
}
else
{
- rig_debug(RIG_DEBUG_TRACE, "%s: cache miss age mode=%dms, width=%dms\n", __func__, cache_ms_mode, cache_ms_width);
+ rig_debug(RIG_DEBUG_TRACE, "%s: cache miss age mode=%dms, width=%dms\n",
+ __func__, cache_ms_mode, cache_ms_width);
}
if ((caps->targetable_vfo & RIG_TARGETABLE_MODE)
@@ -2184,7 +2238,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
*width = rig_passband_normal(rig, *mode);
}
- set_cache_mode(rig,vfo,*mode,*width);
+ set_cache_mode(rig, vfo, *mode, *width);
RETURNFUNC(retcode);
}
@@ -2425,8 +2479,9 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
rigerror(retcode));
}
else
- { // if no get_freq clear all cache to be sure we refresh whatever we can
- set_cache_freq(rig, RIG_VFO_ALL, (freq_t)0);
+ {
+ // if no get_freq clear all cache to be sure we refresh whatever we can
+ set_cache_freq(rig, RIG_VFO_ALL, (freq_t)0);
}
// expire several cached items when we switch VFOs
@@ -2576,7 +2631,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
if (retcode != RIG_OK) { RETURNFUNC(retcode); }
- hl_usleep(50*1000); // give PTT a chance to do it's thing
+ hl_usleep(50 * 1000); // give PTT a chance to do it's thing
// don't use the cached value and check to see if it worked
elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_INVALIDATE);
@@ -3037,7 +3092,7 @@ int HAMLIB_API rig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->get_dcd(rig, vfo, dcd));
}
@@ -3138,7 +3193,7 @@ int HAMLIB_API rig_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->set_rptr_shift(rig, vfo, rptr_shift));
}
@@ -3205,7 +3260,7 @@ int HAMLIB_API rig_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->get_rptr_shift(rig, vfo, rptr_shift));
}
@@ -3272,7 +3327,7 @@ int HAMLIB_API rig_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->set_rptr_offs(rig, vfo, rptr_offs));
}
@@ -3339,7 +3394,7 @@ int HAMLIB_API rig_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->get_rptr_offs(rig, vfo, rptr_offs));
}
@@ -3900,10 +3955,13 @@ int HAMLIB_API rig_set_split_freq_mode(RIG *rig,
{
retcode = caps->set_split_freq_mode(rig, vfo, tx_freq, tx_mode, tx_width);
retcode2 = rig_get_split_freq(rig, vfo, &tfreq);
+
if (tfreq != tx_freq)
{
- rig_debug(RIG_DEBUG_ERR, "%s: txfreq!=tfreq %.0f!=%.0f, retry=%d, rc1=%d, rc2=%d\n", __func__, tx_freq, tfreq, retry, retcode, retcode2);
- hl_usleep(50*1000); // 50ms sleep may help here
+ rig_debug(RIG_DEBUG_ERR,
+ "%s: txfreq!=tfreq %.0f!=%.0f, retry=%d, rc1=%d, rc2=%d\n", __func__, tx_freq,
+ tfreq, retry, retcode, retcode2);
+ hl_usleep(50 * 1000); // 50ms sleep may help here
}
}
while (tfreq != tx_freq && retry-- > 0 && retcode == RIG_OK
@@ -4027,7 +4085,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
vfo = vfo_fixup(rig, vfo);
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
retcode = caps->set_split_vfo(rig, vfo, split, tx_vfo);
@@ -4142,7 +4200,7 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig,
*tx_vfo = rig->state.tx_vfo;
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
retcode = caps->get_split_vfo(rig, vfo, split, tx_vfo);
rig->state.cache.split = *split;
@@ -4498,7 +4556,7 @@ int HAMLIB_API rig_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->set_ts(rig, vfo, ts));
}
@@ -4565,7 +4623,7 @@ int HAMLIB_API rig_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->get_ts(rig, vfo, ts));
}
@@ -4831,12 +4889,12 @@ int HAMLIB_API rig_mW2power(RIG *rig,
if (!rig || !rig->caps || !power || mwpower == 0)
{
- return(-RIG_EINVAL);
+ return (-RIG_EINVAL);
}
if (rig->caps->mW2power != NULL)
{
- return(rig->caps->mW2power(rig, power, mwpower, freq, mode));
+ return (rig->caps->mW2power(rig, power, mwpower, freq, mode));
}
txrange = rig_get_range(rig->state.tx_range_list, freq, mode);
@@ -4846,13 +4904,13 @@ int HAMLIB_API rig_mW2power(RIG *rig,
/*
* freq is not on the tx range!
*/
- return(-RIG_ECONF); /* could be RIG_EINVAL ? */
+ return (-RIG_ECONF); /* could be RIG_EINVAL ? */
}
if (txrange->high_power == 0)
{
*power = 0.0;
- return(RIG_OK);
+ return (RIG_OK);
}
*power = (float)mwpower / txrange->high_power;
@@ -4862,7 +4920,7 @@ int HAMLIB_API rig_mW2power(RIG *rig,
*power = 1.0;
}
- return(mwpower > txrange->high_power ? RIG_OK : -RIG_ETRUNC);
+ return (mwpower > txrange->high_power ? RIG_OK : -RIG_ETRUNC);
}
@@ -5134,7 +5192,7 @@ int HAMLIB_API rig_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->vfo_op(rig, vfo, op));
}
@@ -5233,7 +5291,7 @@ int HAMLIB_API rig_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->scan(rig, vfo, scan, ch));
}
@@ -5300,7 +5358,7 @@ int HAMLIB_API rig_send_dtmf(RIG *rig, vfo_t vfo, const char *digits)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->send_dtmf(rig, vfo, digits));
}
@@ -5368,7 +5426,7 @@ int HAMLIB_API rig_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->recv_dtmf(rig, vfo, digits, length));
}
@@ -5435,7 +5493,7 @@ int HAMLIB_API rig_send_morse(RIG *rig, vfo_t vfo, const char *msg)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->send_morse(rig, vfo, msg));
}
@@ -5493,7 +5551,7 @@ int HAMLIB_API rig_stop_morse(RIG *rig, vfo_t vfo)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->stop_morse(rig, vfo));
}
@@ -5583,7 +5641,7 @@ int HAMLIB_API rig_wait_morse(RIG *rig, vfo_t vfo)
caps = rig->caps;
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(wait_morse_ptt(rig, vfo));
}
@@ -5650,7 +5708,7 @@ int HAMLIB_API rig_send_voice_mem(RIG *rig, vfo_t vfo, int ch)
}
if (vfo == RIG_VFO_CURR
- || vfo == rig->state.current_vfo)
+ || vfo == rig->state.current_vfo)
{
RETURNFUNC(caps->send_voice_mem(rig, vfo, ch));
}
@@ -5705,18 +5763,18 @@ const freq_range_t *HAMLIB_API rig_get_range(const freq_range_t *range_list,
{
if (range_list[i].startf == 0 && range_list[i].endf == 0)
{
- return(NULL);
+ return (NULL);
}
if (freq >= range_list[i].startf && freq <= range_list[i].endf &&
(range_list[i].modes & mode))
{
const freq_range_t *f = &range_list[i];
- return(f);
+ return (f);
}
}
- return(NULL);
+ return (NULL);
}
/**
@@ -5753,15 +5811,15 @@ const char *HAMLIB_API rig_get_info(RIG *rig)
{
if (CHECK_RIG_ARG(rig))
{
- return(NULL);
+ return (NULL);
}
if (rig->caps->get_info == NULL)
{
- return(NULL);
+ return (NULL);
}
- return(rig->caps->get_info(rig));
+ return (rig->caps->get_info(rig));
}
/**
@@ -5796,16 +5854,19 @@ int HAMLIB_API rig_get_vfo_info(RIG *rig, vfo_t vfo, freq_t *freq,
if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; }
- // we can't use the cached values as some clients may only call this function
+ // we can't use the cached values as some clients may only call this function
// like Log4OM which mostly does polling
retval = rig_get_freq(rig, vfo, freq);
- if (retval != RIG_OK) RETURNFUNC(retval);
+
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
retval = rig_get_mode(rig, vfo, mode, width);
- if (retval != RIG_OK) RETURNFUNC(retval);
+
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
retval = rig_get_split(rig, vfo, split);
- if (retval != RIG_OK) RETURNFUNC(retval);
+
+ if (retval != RIG_OK) { RETURNFUNC(retval); }
RETURNFUNC(RIG_OK);
}
diff --git a/src/serial.c b/src/serial.c
index b314cc351..af7aa518f 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -887,13 +887,13 @@ int HAMLIB_API ser_get_rts(hamlib_port_t *p, int *state)
// cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
}
retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_RTS) == TIOCM_RTS;
- return(retcode < 0 ? -RIG_EIO : RIG_OK);
+ return (retcode < 0 ? -RIG_EIO : RIG_OK);
}
@@ -973,18 +973,18 @@ int HAMLIB_API ser_get_dtr(hamlib_port_t *p, int *state)
if (p->fd == uh_ptt_fd)
{
*state = uh_get_ptt();
- return(RIG_OK);
+ return (RIG_OK);
}
if (p->fd == uh_radio_fd)
{
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
}
retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_DTR) == TIOCM_DTR;
- return(retcode < 0 ? -RIG_EIO : RIG_OK);
+ return (retcode < 0 ? -RIG_EIO : RIG_OK);
}
@@ -999,14 +999,14 @@ int HAMLIB_API ser_set_brk(hamlib_port_t *p, int state)
// ignore this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{
- return(RIG_OK);
+ return (RIG_OK);
}
#if defined(TIOCSBRK) && defined(TIOCCBRK)
- return(IOCTL(p->fd, state ? TIOCSBRK : TIOCCBRK, 0) < 0 ?
- -RIG_EIO : RIG_OK);
+ return (IOCTL(p->fd, state ? TIOCSBRK : TIOCCBRK, 0) < 0 ?
+ -RIG_EIO : RIG_OK);
#else
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
#endif
}
@@ -1024,13 +1024,13 @@ int HAMLIB_API ser_get_car(hamlib_port_t *p, int *state)
// cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
}
retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_CAR) == TIOCM_CAR;
- return(retcode < 0 ? -RIG_EIO : RIG_OK);
+ return (retcode < 0 ? -RIG_EIO : RIG_OK);
}
@@ -1047,13 +1047,13 @@ int HAMLIB_API ser_get_cts(hamlib_port_t *p, int *state)
// cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
}
retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_CTS) == TIOCM_CTS;
- return(retcode < 0 ? -RIG_EIO : RIG_OK);
+ return (retcode < 0 ? -RIG_EIO : RIG_OK);
}
@@ -1070,13 +1070,13 @@ int HAMLIB_API ser_get_dsr(hamlib_port_t *p, int *state)
// cannot do this for microHam ports
if (p->fd == uh_ptt_fd || p->fd == uh_radio_fd)
{
- return(-RIG_ENIMPL);
+ return (-RIG_ENIMPL);
}
retcode = IOCTL(p->fd, TIOCMGET, &y);
*state = (y & TIOCM_DSR) == TIOCM_DSR;
- return(retcode < 0 ? -RIG_EIO : RIG_OK);
+ return (retcode < 0 ? -RIG_EIO : RIG_OK);
}
/** @} */
diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c
index 3e37a5ef1..337201557 100644
--- a/tests/dumpcaps.c
+++ b/tests/dumpcaps.c
@@ -340,7 +340,8 @@ int dumpcaps(RIG *rig, FILE *fout)
fprintf(fout, "Extra functions:\n");
rig_ext_func_foreach(rig, print_ext, fout);
- rig_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_get_level, caps->level_gran);
+ rig_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_get_level,
+ caps->level_gran);
fprintf(fout, "Get level: %s\n", prntbuf);
if ((caps->has_get_level & RIG_LEVEL_SQLSTAT))
@@ -359,7 +360,8 @@ int dumpcaps(RIG *rig, FILE *fout)
backend_warnings++;
}
- rig_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_set_level, caps->level_gran);
+ rig_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_set_level,
+ caps->level_gran);
fprintf(fout, "Set level: %s\n", prntbuf);
if (caps->has_set_level & RIG_LEVEL_READONLY_LIST)
@@ -371,10 +373,12 @@ int dumpcaps(RIG *rig, FILE *fout)
fprintf(fout, "Extra levels:\n");
rig_ext_level_foreach(rig, print_ext, fout);
- rig_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_get_parm, caps->parm_gran);
+ rig_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_get_parm,
+ caps->parm_gran);
fprintf(fout, "Get parameters: %s\n", prntbuf);
- rig_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_set_parm, caps->parm_gran);
+ rig_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_set_parm,
+ caps->parm_gran);
fprintf(fout, "Set parameters: %s\n", prntbuf);
if (caps->has_set_parm & RIG_PARM_READONLY_LIST)
diff --git a/tests/dumpcaps_rot.c b/tests/dumpcaps_rot.c
index c164b823b..52dadda0b 100644
--- a/tests/dumpcaps_rot.c
+++ b/tests/dumpcaps_rot.c
@@ -166,7 +166,8 @@ int dumpcaps_rot(ROT *rot, FILE *fout)
fprintf(fout, "Extra functions:\n");
rot_ext_func_foreach(rot, print_ext, fout);
- rot_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_get_level, caps->level_gran);
+ rot_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_get_level,
+ caps->level_gran);
fprintf(fout, "Get level: %s\n", prntbuf);
if ((caps->has_get_level & RIG_LEVEL_SQLSTAT))
@@ -175,7 +176,8 @@ int dumpcaps_rot(ROT *rot, FILE *fout)
backend_warnings++;
}
- rot_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_set_level, caps->level_gran);
+ rot_sprintf_level_gran(prntbuf, sizeof(prntbuf), caps->has_set_level,
+ caps->level_gran);
fprintf(fout, "Set level: %s\n", prntbuf);
if (caps->has_set_level & ROT_LEVEL_READONLY_LIST)
@@ -187,10 +189,12 @@ int dumpcaps_rot(ROT *rot, FILE *fout)
fprintf(fout, "Extra levels:\n");
rot_ext_level_foreach(rot, print_ext, fout);
- rot_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_get_parm, caps->parm_gran);
+ rot_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_get_parm,
+ caps->parm_gran);
fprintf(fout, "Get parameters: %s\n", prntbuf);
- rot_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_set_parm, caps->parm_gran);
+ rot_sprintf_parm_gran(prntbuf, sizeof(prntbuf), caps->has_set_parm,
+ caps->parm_gran);
fprintf(fout, "Set parameters: %s\n", prntbuf);
if (caps->has_set_parm & ROT_PARM_READONLY_LIST)
diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c
index 0beeb9220..ebb8eb1b3 100644
--- a/tests/rigctl_parse.c
+++ b/tests/rigctl_parse.c
@@ -4223,7 +4223,8 @@ declare_proto_rig(dump_state)
fprintf(fout, "%d\n", 0);
#endif
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(rs->rx_range_list[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(rs->rx_range_list[i]); i++)
{
fprintf(fout,
"%"FREQFMT" %"FREQFMT" 0x%"PRXll" %d %d 0x%x 0x%x\n",
@@ -4238,7 +4239,8 @@ declare_proto_rig(dump_state)
fprintf(fout, "0 0 0 0 0 0 0\n");
- for (i = 0; i < HAMLIB_FRQRANGESIZ && !RIG_IS_FRNG_END(rs->tx_range_list[i]); i++)
+ for (i = 0; i < HAMLIB_FRQRANGESIZ
+ && !RIG_IS_FRNG_END(rs->tx_range_list[i]); i++)
{
fprintf(fout,
"%"FREQFMT" %"FREQFMT" 0x%"PRXll" %d %d 0x%x 0x%x\n",
@@ -4387,7 +4389,7 @@ declare_proto_rig(get_ant)
fprintf(fout, "%s: ", cmd->arg1);
}
- rig_sprintf_ant(antbuf, sizeof(antbuf), ant_curr);
+ rig_sprintf_ant(antbuf, sizeof(antbuf), ant_curr);
fprintf(fout, "%s%c", antbuf, resp_sep);
//fprintf(fout, "%d%c", rig_setting2idx(ant_curr)+1, resp_sep);
@@ -4469,7 +4471,7 @@ declare_proto_rig(send_voice_mem)
}
declare_proto_rig(send_dtmf)
-{
+{
ENTERFUNC;
RETURNFUNC(rig_send_dtmf(rig, vfo, arg1));
diff --git a/tests/testcache.c b/tests/testcache.c
index 853f009a1..3eb922091 100644
--- a/tests/testcache.c
+++ b/tests/testcache.c
@@ -129,31 +129,40 @@ int main(int argc, char *argv[])
if (widthC != 3000) { printf("widthC = %d\n", (int)widthC); exit(1); }
printf("PTT ON\n");
- rig_set_ptt(my_rig,RIG_VFO_CURR,RIG_PTT_ON);
+ rig_set_ptt(my_rig, RIG_VFO_CURR, RIG_PTT_ON);
ptt_t ptt;
printf("PTT get ptt ON\n");
- rig_get_ptt(my_rig,RIG_VFO_CURR,&ptt);
+ rig_get_ptt(my_rig, RIG_VFO_CURR, &ptt);
+
if (ptt != RIG_PTT_ON) { printf("ptt != ON\n"); exit(1); }
- hl_usleep(1000*1000);
- rig_get_ptt(my_rig,RIG_VFO_CURR,&ptt);
+
+ hl_usleep(1000 * 1000);
+ rig_get_ptt(my_rig, RIG_VFO_CURR, &ptt);
printf("PTT get ptt ON\n");
+
if (ptt != RIG_PTT_ON) { printf("ptt != ON\n"); exit(1); }
+
printf("PTT ptt OFF\n");
- rig_set_ptt(my_rig,RIG_VFO_CURR,RIG_PTT_OFF);
+ rig_set_ptt(my_rig, RIG_VFO_CURR, RIG_PTT_OFF);
+
if (ptt != RIG_PTT_ON) { printf("ptt != ON\n"); exit(1); }
- rig_get_ptt(my_rig,RIG_VFO_CURR,&ptt);
+
+ rig_get_ptt(my_rig, RIG_VFO_CURR, &ptt);
printf("PTT get ptt OFF\n");
vfo_t tx_vfo;
split_t split;
- rig_get_split_vfo(my_rig,RIG_VFO_A,&split, &tx_vfo);
+ rig_get_split_vfo(my_rig, RIG_VFO_A, &split, &tx_vfo);
printf("split=%d, tx_vfo=%s\n", split, rig_strvfo(tx_vfo));
- if (split !=0 || tx_vfo != RIG_VFO_A) { printf("split#1 failed\n"); exit(1); }
- rig_set_split_vfo(my_rig,RIG_VFO_A,RIG_SPLIT_ON,RIG_VFO_B);
- hl_usleep(1000*1000);
- rig_get_split_vfo(my_rig,RIG_VFO_A,&split,&tx_vfo);
+
+ if (split != 0 || tx_vfo != RIG_VFO_A) { printf("split#1 failed\n"); exit(1); }
+
+ rig_set_split_vfo(my_rig, RIG_VFO_A, RIG_SPLIT_ON, RIG_VFO_B);
+ hl_usleep(1000 * 1000);
+ rig_get_split_vfo(my_rig, RIG_VFO_A, &split, &tx_vfo);
printf("split=%d, tx_vfo=%s\n", split, rig_strvfo(tx_vfo));
- if (split != RIG_SPLIT_ON || tx_vfo != RIG_VFO_B) { printf("split#2 failed\n"); exit(1); }
+
+ if (split != RIG_SPLIT_ON || tx_vfo != RIG_VFO_B) { printf("split#2 failed\n"); exit(1); }
printf("All OK\n");
rig_close(my_rig);