kopia lustrzana https://github.com/Hamlib/Hamlib
Fix Barret 950 set_freq
Change Barrett 950 to use channels 441-450 for 10-band memory This will minimize EEPROM writes https://github.com/Hamlib/Hamlib/issues/483pull/494/head
rodzic
08792f9295
commit
b1f01708ed
|
@ -49,17 +49,40 @@
|
||||||
static int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
static int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||||
|
|
||||||
static int barrett950_get_level(RIG *rig, vfo_t vfo, setting_t level,
|
static int barrett950_get_level(RIG *rig, vfo_t vfo, setting_t level,
|
||||||
value_t *val);
|
value_t *val);
|
||||||
|
|
||||||
static const char *barrett950_get_info(RIG *rig);
|
static const char *barrett950_get_info(RIG *rig);
|
||||||
|
|
||||||
|
// 10 band channel from 441 to 450
|
||||||
|
#define CHANNEL_BASE 441
|
||||||
|
|
||||||
|
struct chan_map_s
|
||||||
|
{
|
||||||
|
float lo, hi;
|
||||||
|
int chan_offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Our 10 bands
|
||||||
|
struct chan_map_s chan_map[] =
|
||||||
|
{
|
||||||
|
{ 1.8, 2.0, 0},
|
||||||
|
{ 3.5, 4.0, 1},
|
||||||
|
{ 5.3, 5.4, 2},
|
||||||
|
{ 7.0, 7.3, 3},
|
||||||
|
{ 10.1, 10.15, 4},
|
||||||
|
{ 14.0, 14.35, 5},
|
||||||
|
{ 18.068, 18.168, 6},
|
||||||
|
{ 21.0, 21.45, 7},
|
||||||
|
{ 24.89, 24.99, 8},
|
||||||
|
{ 28.0, 29.7, 9}
|
||||||
|
};
|
||||||
|
|
||||||
const struct rig_caps barrett950_caps =
|
const struct rig_caps barrett950_caps =
|
||||||
{
|
{
|
||||||
RIG_MODEL(RIG_MODEL_BARRETT_950),
|
RIG_MODEL(RIG_MODEL_BARRETT_950),
|
||||||
.model_name = "950",
|
.model_name = "950",
|
||||||
.mfg_name = "Barrett",
|
.mfg_name = "Barrett",
|
||||||
.version = BACKEND_VER ".0",
|
.version = BACKEND_VER "/20210105",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_BETA,
|
.status = RIG_STATUS_BETA,
|
||||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||||
|
@ -130,50 +153,79 @@ int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
char cmd_buf[MAXCMDLEN];
|
char cmd_buf[MAXCMDLEN];
|
||||||
int retval;
|
int retval;
|
||||||
struct barrett_priv_data *priv = rig->state.priv;
|
int i;
|
||||||
|
int chan;
|
||||||
|
freq_t freq_rx, freq_tx;
|
||||||
|
freq_t freq_MHz;
|
||||||
|
char *response = NULL;
|
||||||
|
//struct barrett_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s freq=%.0f\n", __func__,
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s freq=%.0f\n", __func__,
|
||||||
rig_strvfo(vfo), freq);
|
rig_strvfo(vfo), freq);
|
||||||
|
|
||||||
// If we are not explicitly asking for VFO_B then we'll set the receive side also
|
// 950 can only set freq via memory channel
|
||||||
if (vfo != RIG_VFO_B)
|
// So we make a 10-channel memory from 441-450 by band
|
||||||
|
// And we don't care about VFO -- we set TX=RX to avoid doing split freq changes
|
||||||
|
// Trying to minimize writes to EEPROM
|
||||||
|
|
||||||
|
// What band is being requested?
|
||||||
|
freq_MHz = freq / 1e6;
|
||||||
|
|
||||||
|
for (i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
char *response = NULL;
|
if (freq_MHz >= chan_map[i].lo && freq_MHz <= chan_map[i].hi)
|
||||||
sprintf((char *) cmd_buf, "PR%08.0f", freq);
|
|
||||||
retval = barrett_transaction(rig, cmd_buf, 0, &response);
|
|
||||||
|
|
||||||
if (retval < 0)
|
|
||||||
{
|
{
|
||||||
return retval;
|
chan = CHANNEL_BASE + chan_map[i].chan_offset;
|
||||||
}
|
|
||||||
|
|
||||||
//dump_hex((unsigned char *)response, strlen(response));
|
|
||||||
|
|
||||||
if (strncmp(response, "OK", 2) != 0)
|
|
||||||
{
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Expected OK, got '%s'\n", __func__, response);
|
|
||||||
return -RIG_EPROTO;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->split == 0
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: using chan %d for freq %.0f \n", __func__,
|
||||||
|| vfo == RIG_VFO_B) // if we aren't in split mode we have to set the TX VFO too
|
chan, freq);
|
||||||
|
|
||||||
|
// Set the channel
|
||||||
|
sprintf((char *) cmd_buf, "XC%04d", chan);
|
||||||
|
retval = barrett_transaction(rig, cmd_buf, 0, &response);
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
char *response = NULL;
|
// Read the current channel for the requested freq to see if it needs changing
|
||||||
sprintf((char *) cmd_buf, "PT%08.0f", freq);
|
sprintf((char *) cmd_buf, "IDC%04d", chan);
|
||||||
retval = barrett_transaction(rig, cmd_buf, 0, &response);
|
retval = barrett_transaction(rig, cmd_buf, 0, &response);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(response, "OK", 2) != 0)
|
if (sscanf(response, "%4d%8lf%8lf", &chan, &freq_rx, &freq_tx) != 2)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Expected OK, got '%s'\n", __func__, response);
|
rig_debug(RIG_DEBUG_ERR, "%s: unable to parse chan/freq from %s\n", __func__,
|
||||||
return -RIG_EPROTO;
|
response);
|
||||||
}
|
return -RIG_EPROTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: got chan %d, freq_rx=%.0f, freq_tx=%.0f",
|
||||||
|
__func__, chan,
|
||||||
|
freq_rx, freq_tx);
|
||||||
|
|
||||||
|
if (freq_rx == freq && freq_tx == freq)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: no freq change needed\n", __func__);
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// New freq so let's update the channel
|
||||||
|
// We do not support split mode -- too many writes to EEPROM to support it
|
||||||
|
sprintf((char *) cmd_buf, "PC%04dR%08.0lfT%08.0lf", chan, freq, freq);
|
||||||
|
retval = barrett_transaction(rig, cmd_buf, 0, &response);
|
||||||
|
|
||||||
|
if (strncmp(response, "OK", 2) != 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: Expected OK, got '%s'\n", __func__, response);
|
||||||
|
return -RIG_EPROTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
|
|
Ładowanie…
Reference in New Issue