kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'hamlib-multicast-4' into streamline-vfo-targeting-and-split-functionality
commit
82f2b10275
|
@ -2477,6 +2477,7 @@ typedef enum {
|
||||||
* \brief Rig cache data
|
* \brief Rig cache data
|
||||||
*
|
*
|
||||||
* This struct contains all the items we cache at the highest level
|
* This struct contains all the items we cache at the highest level
|
||||||
|
* DO NOT MODIFY THIS STRUCTURE AT ALL -- we need a new cache that is a pointer rather than a structure
|
||||||
*/
|
*/
|
||||||
struct rig_cache {
|
struct rig_cache {
|
||||||
int timeout_ms; // the cache timeout for invalidating itself
|
int timeout_ms; // the cache timeout for invalidating itself
|
||||||
|
@ -2550,7 +2551,6 @@ struct rig_cache {
|
||||||
struct timespec time_ptt;
|
struct timespec time_ptt;
|
||||||
struct timespec time_split;
|
struct timespec time_split;
|
||||||
int satmode; // if rig is in satellite mode
|
int satmode; // if rig is in satellite mode
|
||||||
double swr; // keep swr
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h> /* String function definitions */
|
#include <string.h> /* String function definitions */
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include <hamlib/rig.h>
|
#include <hamlib/rig.h>
|
||||||
#include <serial.h>
|
#include <serial.h>
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
RIG_MODE_FM | RIG_MODE_WFM | RIG_MODE_FMN | RIG_MODE_PKTFM |\
|
RIG_MODE_FM | RIG_MODE_WFM | RIG_MODE_FMN | RIG_MODE_PKTFM |\
|
||||||
RIG_MODE_C4FM)
|
RIG_MODE_C4FM)
|
||||||
|
|
||||||
#define FLRIG_LEVELS (RIG_LEVEL_AF | RIG_LEVEL_RF | RIG_LEVEL_MICGAIN | RIG_LEVEL_STRENGTH | RIG_LEVEL_RFPOWER_METER | RIG_LEVEL_RFPOWER_METER_WATTS | RIG_LEVEL_RFPOWER)
|
#define FLRIG_LEVELS (RIG_LEVEL_AF | RIG_LEVEL_RF | RIG_LEVEL_MICGAIN | RIG_LEVEL_STRENGTH | RIG_LEVEL_RFPOWER_METER | RIG_LEVEL_RFPOWER_METER_WATTS | RIG_LEVEL_RFPOWER | RIG_LEVEL_SWR)
|
||||||
|
|
||||||
#define FLRIG_PARM (TOK_FLRIG_VERIFY_FREQ|TOK_FLRIG_VERIFY_PTT)
|
#define FLRIG_PARM (TOK_FLRIG_VERIFY_FREQ|TOK_FLRIG_VERIFY_PTT)
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ const struct rig_caps flrig_caps =
|
||||||
RIG_MODEL(RIG_MODEL_FLRIG),
|
RIG_MODEL(RIG_MODEL_FLRIG),
|
||||||
.model_name = "FLRig",
|
.model_name = "FLRig",
|
||||||
.mfg_name = "FLRig",
|
.mfg_name = "FLRig",
|
||||||
.version = "20231010.0",
|
.version = "20231108.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
@ -2111,6 +2112,39 @@ static int flrig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
RETURNFUNC(RIG_OK);
|
RETURNFUNC(RIG_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float mtr;
|
||||||
|
float swr;
|
||||||
|
} swrpair;
|
||||||
|
|
||||||
|
static swrpair swrtbl[] = {
|
||||||
|
{0.0, 1.0},
|
||||||
|
{10.5, 1.5},
|
||||||
|
{23.0, 2.0},
|
||||||
|
{35.0, 2.5},
|
||||||
|
{48.0, 3.0},
|
||||||
|
{100.0, 10.0 } // assuming 10.0 is infinity for FLRig
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function to interpolate SWR from MTR
|
||||||
|
float interpolateSWR(float mtr) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < sizeof(swrtbl)/sizeof(swrpair) - 1; i++) {
|
||||||
|
if (mtr == swrtbl[i].mtr) {
|
||||||
|
// Exact match
|
||||||
|
return swrtbl[i].swr;
|
||||||
|
}
|
||||||
|
if (mtr < swrtbl[i + 1].mtr) {
|
||||||
|
// Perform linear interpolation
|
||||||
|
float slope = (swrtbl[i + 1].swr - swrtbl[i].swr) / (swrtbl[i + 1].mtr - swrtbl[i].mtr);
|
||||||
|
float swr = round((swrtbl[i].swr + slope * (mtr - swrtbl[i].mtr))*10)/10.0;
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE,"%s: swr=%f\n", __func__, swr);
|
||||||
|
return swr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If mtr is not within the range of values in the table, you could choose to return an error or extrapolate
|
||||||
|
return 10; // Example er
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* flrig_get_level
|
* flrig_get_level
|
||||||
* Assumes rig!=NULL, rig->state.priv!=NULL, val!=NULL
|
* Assumes rig!=NULL, rig->state.priv!=NULL, val!=NULL
|
||||||
|
@ -2137,6 +2171,8 @@ static int flrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||||
|
|
||||||
case RIG_LEVEL_STRENGTH: cmd = "rig.get_smeter"; break;
|
case RIG_LEVEL_STRENGTH: cmd = "rig.get_smeter"; break;
|
||||||
|
|
||||||
|
case RIG_LEVEL_SWR: cmd = "rig.get_swrmeter"; 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_WATTS:
|
||||||
|
@ -2159,6 +2195,11 @@ static int flrig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||||
// most levels are 0-100 -- may have to allow for different ranges
|
// most levels are 0-100 -- may have to allow for different ranges
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
|
case RIG_LEVEL_SWR:
|
||||||
|
{
|
||||||
|
val->f = interpolateSWR(atoi(value));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case RIG_LEVEL_STRENGTH:
|
case RIG_LEVEL_STRENGTH:
|
||||||
val->i = atoi(value) - 54;
|
val->i = atoi(value) - 54;
|
||||||
//if (val->i > 0) val->i /= 10;
|
//if (val->i > 0) val->i /= 10;
|
||||||
|
|
|
@ -94,7 +94,8 @@ static struct kenwood_priv_caps powersdr_priv_caps =
|
||||||
{
|
{
|
||||||
.cmdtrm = EOM_KEN,
|
.cmdtrm = EOM_KEN,
|
||||||
.mode_table = powersdr_mode_table,
|
.mode_table = powersdr_mode_table,
|
||||||
.if_len = 37
|
.if_len = 37,
|
||||||
|
.swr = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DSP_BW_NUM 8
|
#define DSP_BW_NUM 8
|
||||||
|
@ -839,24 +840,18 @@ int powersdr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||||
|
|
||||||
case RIG_LEVEL_SWR:
|
case RIG_LEVEL_SWR:
|
||||||
{
|
{
|
||||||
// if not PTT we'll return the last SWR value
|
struct kenwood_priv_caps *priv = kenwood_caps(rig);
|
||||||
// seems desirable to able to see this always
|
ptt_t ptt = 0;
|
||||||
ptt_t ptt;
|
rig_get_ptt(rig, RIG_VFO_CURR, &ptt);
|
||||||
rig_get_ptt(rig, RIG_VFO_TX, &ptt);
|
if (ptt == RIG_PTT_OFF) { val->f = priv->swr; return RIG_OK;}
|
||||||
if (!ptt) { val->f = rig->state.cache.swr; return RIG_OK; }
|
cmd = "ZZRM8"; // get SWR
|
||||||
double forward=0, reverse=0;
|
|
||||||
cmd = "ZZRM5"; // get forward power
|
|
||||||
len = 5;
|
len = 5;
|
||||||
ans = 4;
|
ans = 8;
|
||||||
retval = kenwood_safe_transaction(rig, cmd, lvlbuf, sizeof(lvlbuf), len + ans);
|
retval = kenwood_transaction(rig, cmd, lvlbuf, sizeof(lvlbuf));
|
||||||
if (retval != RIG_OK) { val->f = 0; return RIG_OK;};
|
if (retval != RIG_OK) { val->f = priv->swr; return RIG_OK;};
|
||||||
sscanf(lvlbuf,"ZZRM5%lg", &forward);
|
sscanf(lvlbuf,"ZZRM8%lg", &priv->swr);
|
||||||
if (forward == 0) { val->f = 1.0; return RIG_OK;}
|
val->f = priv->swr;
|
||||||
cmd = "ZZRM7";
|
rig_debug(RIG_DEBUG_ERR, "%s(%d) swr=%.1f\n", __func__, __LINE__, val->f);
|
||||||
retval = kenwood_safe_transaction(rig, cmd, lvlbuf, sizeof(lvlbuf), len + ans);
|
|
||||||
if (retval != RIG_OK) { val->f = 0; return RIG_OK;};
|
|
||||||
sscanf(lvlbuf,"ZZRM7%lg", &reverse);
|
|
||||||
rig->state.cache.swr = val->f = (1.0 + sqrt(reverse/forward)) / (1.0 - sqrt(reverse/forward));
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1350,7 +1345,7 @@ const struct rig_caps powersdr_caps =
|
||||||
RIG_MODEL(RIG_MODEL_POWERSDR),
|
RIG_MODEL(RIG_MODEL_POWERSDR),
|
||||||
.model_name = "PowerSDR/Thetis",
|
.model_name = "PowerSDR/Thetis",
|
||||||
.mfg_name = "FlexRadio/ANAN",
|
.mfg_name = "FlexRadio/ANAN",
|
||||||
.version = "20231104.0",
|
.version = "20231107.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
|
|
@ -135,6 +135,7 @@ struct kenwood_priv_caps
|
||||||
struct kenwood_filter_width *filter_width; /* Last entry should have value == -1 and width_hz == -1 */
|
struct kenwood_filter_width *filter_width; /* Last entry should have value == -1 and width_hz == -1 */
|
||||||
struct kenwood_slope_filter *slope_filter_high; /* Last entry should have value == -1 and frequency_hz == -1 */
|
struct kenwood_slope_filter *slope_filter_high; /* Last entry should have value == -1 and frequency_hz == -1 */
|
||||||
struct kenwood_slope_filter *slope_filter_low; /* Last entry should have value == -1 and frequency_hz == -1 */
|
struct kenwood_slope_filter *slope_filter_low; /* Last entry should have value == -1 and frequency_hz == -1 */
|
||||||
|
double swr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct kenwood_priv_data
|
struct kenwood_priv_data
|
||||||
|
|
|
@ -1952,7 +1952,7 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
||||||
cfp->u.n.step);
|
cfp->u.n.step);
|
||||||
break;
|
break;
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
printf("\tRange: %.1f..%.1f, step %.1f\n",
|
printf("\tRange: %g..%g, step %.1f\n",
|
||||||
cfp->u.n.min,
|
cfp->u.n.min,
|
||||||
cfp->u.n.max,
|
cfp->u.n.max,
|
||||||
cfp->u.n.step);
|
cfp->u.n.step);
|
||||||
|
@ -3287,7 +3287,7 @@ declare_proto_rig(set_level)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
|
CHKSCN1ARG(sscanf(arg2, "%g", &val.f));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_STRING:
|
case RIG_CONF_STRING:
|
||||||
|
@ -3393,7 +3393,7 @@ declare_proto_rig(get_level)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
fprintf(fout, "%f%c", val.f, resp_sep);
|
fprintf(fout, "%g%c", val.f, resp_sep);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_INT:
|
case RIG_CONF_INT:
|
||||||
|
@ -3445,7 +3445,7 @@ declare_proto_rig(get_level)
|
||||||
|
|
||||||
if (RIG_LEVEL_IS_FLOAT(level))
|
if (RIG_LEVEL_IS_FLOAT(level))
|
||||||
{
|
{
|
||||||
fprintf(fout, "%f%c", val.f, resp_sep);
|
fprintf(fout, "%g%c", val.f, resp_sep);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3629,7 +3629,7 @@ declare_proto_rig(set_parm)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
|
CHKSCN1ARG(sscanf(arg2, "%g", &val.f));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_STRING:
|
case RIG_CONF_STRING:
|
||||||
|
@ -3747,7 +3747,7 @@ declare_proto_rig(get_parm)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
fprintf(fout, "%f%c", val.f, resp_sep);
|
fprintf(fout, "%g%c", val.f, resp_sep);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_STRING:
|
case RIG_CONF_STRING:
|
||||||
|
@ -4442,7 +4442,7 @@ int dump_chan(FILE *fout, RIG *rig, channel_t *chan)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_NUMERIC:
|
case RIG_CONF_NUMERIC:
|
||||||
SNPRINTF(lstr, sizeof(lstr), "%f", chan->ext_levels[idx].val.f);
|
SNPRINTF(lstr, sizeof(lstr), "%g", chan->ext_levels[idx].val.f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIG_CONF_CHECKBUTTON:
|
case RIG_CONF_CHECKBUTTON:
|
||||||
|
|
Ładowanie…
Reference in New Issue