Fix unidirectional rig cached frequency (e.g. FT736R)

https://github.com/Hamlib/Hamlib/issues/1187
Hamlib-4.5.2
Mike Black W9MDB 2022-12-18 09:01:27 -06:00
rodzic ce8f50d04c
commit ac882ee896
4 zmienionych plików z 50 dodań i 5 usunięć

Wyświetl plik

@ -3396,6 +3396,7 @@ extern HAMLIB_EXPORT(int) rig_set_vfo_opt(RIG *rig, int status);
extern HAMLIB_EXPORT(int) rig_get_vfo_info(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width, split_t *split, int *satmode);
extern HAMLIB_EXPORT(int) rig_get_rig_info(RIG *rig, char *response, int max_response_len);
extern HAMLIB_EXPORT(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);
extern HAMLIB_EXPORT(int) rig_get_cache_freq(RIG *rig, vfo_t vfo, freq_t *freq, int * cache_ms_freq);
extern HAMLIB_EXPORT(int) rig_set_clock(RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset);
extern HAMLIB_EXPORT(int) rig_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset);

Wyświetl plik

@ -31,6 +31,7 @@
#include "misc.h"
#include "yaesu.h"
#include "tones.h"
#include "cache.h"
@ -99,7 +100,7 @@ const struct rig_caps ft736_caps =
RIG_MODEL(RIG_MODEL_FT736R),
.model_name = "FT-736R",
.mfg_name = "Yaesu",
.version = "20221214.0",
.version = "20221218.0",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -270,6 +271,7 @@ int ft736_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
unsigned char cmd[YAESU_CMD_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x01};
struct ft736_priv_data *priv = (struct ft736_priv_data *)rig->state.priv;
int retval;
// we will assume requesting to set VFOB is split mode
if (vfo == RIG_VFO_B) { return rig_set_split_freq(rig, vfo, freq); }
@ -288,8 +290,11 @@ int ft736_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
cmd[0] = (cmd[0] & 0x0f) | 0xc0;
}
/* Frequency set */
return write_block(&rig->state.rigport, cmd, YAESU_CMD_LENGTH);
retval = write_block(&rig->state.rigport, cmd, YAESU_CMD_LENGTH);
if (retval == RIG_OK) { rig_set_cache_freq(rig, vfo, freq); }
return retval;
}
int ft736_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
@ -297,7 +302,7 @@ int ft736_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__);
if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) { *freq = rig->state.cache.freqMainA; }
else { *freq = rig->state.cache.freqMainB; }
else { rig_get_cache_freq(rig, vfo, freq, NULL); }
return RIG_OK;
}

Wyświetl plik

@ -442,6 +442,41 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq,
return RIG_OK;
}
/**
* \brief get cached values for a VFO
* \param rig The rig handle
* \param vfo The VFO to get information from
* \param freq The frequency is stored here
* \param cache_ms_freq The age of the last frequency update in ms -- NULL if you don't want it
* Use this to query the frequency cache and then determine to actually fetch data from
* the rig.
*
* \return RIG_OK if the operation has been successful, otherwise
* a negative value if an error occurred (in which case, cause is
* set appropriately).
*
*/
int rig_get_cache_freq(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq_p)
{
rmode_t mode;
int cache_ms_freq;
int cache_ms_mode;
pbwidth_t width;
int cache_ms_width;
int retval;
retval = rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode,
&width, &cache_ms_width);
if (retval == RIG_OK)
{
if (cache_ms_freq_p) { *cache_ms_freq_p = cache_ms_freq; }
}
return retval;
}
void rig_cache_show(RIG *rig, const char *func, int line)
{
rig_debug(RIG_DEBUG_CACHE,

Wyświetl plik

@ -1808,7 +1808,11 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
if (retcode != RIG_OK) { RETURNFUNC(retcode); }
rig_set_cache_freq(rig, vfo, (freq_t)0);
// Unidirectional rigs do not reset cache
if (rig->caps->rig_model != RIG_MODEL_FT736R)
{
rig_set_cache_freq(rig, vfo, (freq_t)0);
}
#if 0 // this verification seems to be causing bad behavior on some rigs