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
|
||||
*
|
||||
* 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 {
|
||||
int timeout_ms; // the cache timeout for invalidating itself
|
||||
|
@ -2550,7 +2551,6 @@ struct rig_cache {
|
|||
struct timespec time_ptt;
|
||||
struct timespec time_split;
|
||||
int satmode; // if rig is in satellite mode
|
||||
double swr; // keep swr
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <math.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <serial.h>
|
||||
|
@ -51,7 +52,7 @@
|
|||
RIG_MODE_FM | RIG_MODE_WFM | RIG_MODE_FMN | RIG_MODE_PKTFM |\
|
||||
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)
|
||||
|
||||
|
@ -138,7 +139,7 @@ const struct rig_caps flrig_caps =
|
|||
RIG_MODEL(RIG_MODEL_FLRIG),
|
||||
.model_name = "FLRig",
|
||||
.mfg_name = "FLRig",
|
||||
.version = "20231010.0",
|
||||
.version = "20231108.0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.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);
|
||||
}
|
||||
|
||||
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
|
||||
* 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_SWR: cmd = "rig.get_swrmeter"; break;
|
||||
|
||||
case RIG_LEVEL_RFPOWER: cmd = "rig.get_power"; break;
|
||||
|
||||
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
|
||||
switch (level)
|
||||
{
|
||||
case RIG_LEVEL_SWR:
|
||||
{
|
||||
val->f = interpolateSWR(atoi(value));
|
||||
break;
|
||||
}
|
||||
case RIG_LEVEL_STRENGTH:
|
||||
val->i = atoi(value) - 54;
|
||||
//if (val->i > 0) val->i /= 10;
|
||||
|
|
|
@ -94,7 +94,8 @@ static struct kenwood_priv_caps powersdr_priv_caps =
|
|||
{
|
||||
.cmdtrm = EOM_KEN,
|
||||
.mode_table = powersdr_mode_table,
|
||||
.if_len = 37
|
||||
.if_len = 37,
|
||||
.swr = 0
|
||||
};
|
||||
|
||||
#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:
|
||||
{
|
||||
// if not PTT we'll return the last SWR value
|
||||
// seems desirable to able to see this always
|
||||
ptt_t ptt;
|
||||
rig_get_ptt(rig, RIG_VFO_TX, &ptt);
|
||||
if (!ptt) { val->f = rig->state.cache.swr; return RIG_OK; }
|
||||
double forward=0, reverse=0;
|
||||
cmd = "ZZRM5"; // get forward power
|
||||
struct kenwood_priv_caps *priv = kenwood_caps(rig);
|
||||
ptt_t ptt = 0;
|
||||
rig_get_ptt(rig, RIG_VFO_CURR, &ptt);
|
||||
if (ptt == RIG_PTT_OFF) { val->f = priv->swr; return RIG_OK;}
|
||||
cmd = "ZZRM8"; // get SWR
|
||||
len = 5;
|
||||
ans = 4;
|
||||
retval = kenwood_safe_transaction(rig, cmd, lvlbuf, sizeof(lvlbuf), len + ans);
|
||||
if (retval != RIG_OK) { val->f = 0; return RIG_OK;};
|
||||
sscanf(lvlbuf,"ZZRM5%lg", &forward);
|
||||
if (forward == 0) { val->f = 1.0; return RIG_OK;}
|
||||
cmd = "ZZRM7";
|
||||
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));
|
||||
ans = 8;
|
||||
retval = kenwood_transaction(rig, cmd, lvlbuf, sizeof(lvlbuf));
|
||||
if (retval != RIG_OK) { val->f = priv->swr; return RIG_OK;};
|
||||
sscanf(lvlbuf,"ZZRM8%lg", &priv->swr);
|
||||
val->f = priv->swr;
|
||||
rig_debug(RIG_DEBUG_ERR, "%s(%d) swr=%.1f\n", __func__, __LINE__, val->f);
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
@ -1350,7 +1345,7 @@ const struct rig_caps powersdr_caps =
|
|||
RIG_MODEL(RIG_MODEL_POWERSDR),
|
||||
.model_name = "PowerSDR/Thetis",
|
||||
.mfg_name = "FlexRadio/ANAN",
|
||||
.version = "20231104.0",
|
||||
.version = "20231107.0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.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_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 */
|
||||
double swr;
|
||||
};
|
||||
|
||||
struct kenwood_priv_data
|
||||
|
|
|
@ -1952,7 +1952,7 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
|||
cfp->u.n.step);
|
||||
break;
|
||||
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.max,
|
||||
cfp->u.n.step);
|
||||
|
@ -3287,7 +3287,7 @@ declare_proto_rig(set_level)
|
|||
break;
|
||||
|
||||
case RIG_CONF_NUMERIC:
|
||||
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
|
||||
CHKSCN1ARG(sscanf(arg2, "%g", &val.f));
|
||||
break;
|
||||
|
||||
case RIG_CONF_STRING:
|
||||
|
@ -3393,7 +3393,7 @@ declare_proto_rig(get_level)
|
|||
break;
|
||||
|
||||
case RIG_CONF_NUMERIC:
|
||||
fprintf(fout, "%f%c", val.f, resp_sep);
|
||||
fprintf(fout, "%g%c", val.f, resp_sep);
|
||||
break;
|
||||
|
||||
case RIG_CONF_INT:
|
||||
|
@ -3445,7 +3445,7 @@ declare_proto_rig(get_level)
|
|||
|
||||
if (RIG_LEVEL_IS_FLOAT(level))
|
||||
{
|
||||
fprintf(fout, "%f%c", val.f, resp_sep);
|
||||
fprintf(fout, "%g%c", val.f, resp_sep);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3629,7 +3629,7 @@ declare_proto_rig(set_parm)
|
|||
break;
|
||||
|
||||
case RIG_CONF_NUMERIC:
|
||||
CHKSCN1ARG(sscanf(arg2, "%f", &val.f));
|
||||
CHKSCN1ARG(sscanf(arg2, "%g", &val.f));
|
||||
break;
|
||||
|
||||
case RIG_CONF_STRING:
|
||||
|
@ -3747,7 +3747,7 @@ declare_proto_rig(get_parm)
|
|||
break;
|
||||
|
||||
case RIG_CONF_NUMERIC:
|
||||
fprintf(fout, "%f%c", val.f, resp_sep);
|
||||
fprintf(fout, "%g%c", val.f, resp_sep);
|
||||
break;
|
||||
|
||||
case RIG_CONF_STRING:
|
||||
|
@ -4442,7 +4442,7 @@ int dump_chan(FILE *fout, RIG *rig, channel_t *chan)
|
|||
break;
|
||||
|
||||
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;
|
||||
|
||||
case RIG_CONF_CHECKBUTTON:
|
||||
|
|
Ładowanie…
Reference in New Issue