Speed up Malachite normal operations with 125ms post write requirement instead of 400ms

400ms needs for band changes on Malachite
Fix BUILTINFUNC calls to compile correctly -- this is for debugging only
pull/1315/head
Mike Black W9MDB 2023-06-08 17:34:39 -05:00
rodzic 6100bfdc11
commit 224d68d1ac
4 zmienionych plików z 73 dodań i 18 usunięć

Wyświetl plik

@ -2914,17 +2914,29 @@ extern HAMLIB_EXPORT(void)
rig_lock(RIG *rig, int lock);
#if BUILTINFUNC
#define rig_set_freq(r,v, f) rig_set_vfo(r,v,f,__builtin_FUNCTION())
#define rig_set_freq(r,v,f) rig_set_freq(r,v,f,__builtin_FUNCTION())
extern HAMLIB_EXPORT(int)
rig_set_freq HAMLIB_PARAMS((RIG *rig,
vfo_t vfo,
freq_t freq, const char*));
#else
extern HAMLIB_EXPORT(int)
rig_set_freq HAMLIB_PARAMS((RIG *rig,
vfo_t vfo,
freq_t freq));
#endif
#if BUILTINFUNC
#define rig_get_freq(r,v,f) rig_get_freq(r,v,f,__builtin_FUNCTION())
extern HAMLIB_EXPORT(int)
rig_get_freq HAMLIB_PARAMS((RIG *rig,
vfo_t vfo,
freq_t *freq, const char*));
#else
extern HAMLIB_EXPORT(int)
rig_get_freq HAMLIB_PARAMS((RIG *rig,
vfo_t vfo,
freq_t *freq));
#endif
extern HAMLIB_EXPORT(int)
rig_set_mode HAMLIB_PARAMS((RIG *rig,

Wyświetl plik

@ -1874,6 +1874,9 @@ int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
if (RIG_OK != err) { RETURNFUNC2(err); }
}
// Malchite is so slow we don't do the get_freq
if (!RIG_IS_MALACHITE)
{
rig_get_freq(rig, tvfo, &tfreq);
if (tfreq == freq)
@ -1881,6 +1884,7 @@ int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_debug(RIG_DEBUG_TRACE, "%s: no freq change needed\n", __func__);
RETURNFUNC2(RIG_OK);
}
}
switch (tvfo)
{

Wyświetl plik

@ -31,6 +31,7 @@
#include "misc.h"
#include "token.h"
#include "kenwood.h"
#include "cache.h"
#define TS480_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_RTTYR)
#define SDRUNO_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTUSB)
@ -2022,21 +2023,34 @@ int malachite_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
int malachite_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int post_write_delay_save = rig->state.post_write_delay;
ENTERFUNC;
rig->state.post_write_delay = 0;
int retval = kenwood_get_freq(rig, vfo, freq);
rig->state.post_write_delay = post_write_delay_save;
return retval;
RETURNFUNC(retval);
}
int malachite_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
// Malachite has a bug where it takes two freq set to make it work
// under some band changes -- so we just do this all the time
retval = kenwood_set_freq(rig, vfo, freq + 1);
ENTERFUNC;
if (retval != RIG_OK) { RETURNFUNC(retval); }
rig_debug(RIG_DEBUG_TRACE, "%s: freqMainA=%g, freq=%g\n", __func__,
rig->state.cache.freqMainA, freq);
if ((rig->state.cache.freqMainA < 400000000 && freq >= 400000000)
|| (rig->state.cache.freqMainA >= 400000000 && freq < 400000000)
|| rig->state.cache.freqMainA == 0)
{
// Malachite has a bug where it takes two freq set to make it work
// under band changes -- so we just do this all the time
retval = kenwood_set_freq(rig, vfo, freq + 1);
hl_usleep(300 *
1000); // we need a bit over 400ms so the 125ms default plus this works
if (retval != RIG_OK) { RETURNFUNC(retval); }
}
retval = kenwood_set_freq(rig, vfo, freq);
@ -2066,13 +2080,15 @@ const struct rig_caps malachite_caps =
.serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0,
.post_write_delay = 400,
// Malchite needs 125ms unless going from low to high band -- see malachite_set_freq
// Do not change this without checking the 300ms delay in malachite_set_freq
.post_write_delay = 125,
.timeout = 3000,
.retry = 3,
.preamp = {0, RIG_DBLST_END,},
.attenuator = {0, RIG_DBLST_END,},
.max_ifshift = Hz(0),
.targetable_vfo = RIG_TARGETABLE_FREQ,
// .targetable_vfo = RIG_TARGETABLE_FREQ,
.transceive = RIG_TRN_POLL,

Wyświetl plik

@ -560,6 +560,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
pthread_mutex_init(&rs->mutex_set_transaction, NULL);
#endif
rs->rig_model = caps->rig_model;
rs->priv = NULL;
rs->async_data_enabled = 1;
rs->rigport.fd = -1;
@ -1793,9 +1794,10 @@ static int twiddling(RIG *rig)
*/
#if BUILTINFUNC
#undef rig_set_freq
int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq, const char *func)
int rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq, const char *func)
#define rig_set_freq(r,v,f) rig_set_freq(r,v,f,__builtin_FUNCTION())
#else
int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
#endif
{
const struct rig_caps *caps;
@ -1901,6 +1903,9 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
HAMLIB_TRACE;
retcode = caps->set_freq(rig, vfo, freq);
// disabling the freq check as of 2023-06-02
// seems unnecessary and slows down rigs unnecessarily
tfreq = freq;
// some rig will return -RIG_ENTARGET if cannot set ptt while transmitting
// we will just return RIG_OK and the frequency set will be ignored
@ -1996,15 +2001,22 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// verify our freq to ensure HZ mods are seen
// some rigs truncate or round e.g. 1,2,5,10,20,100Hz intervals
// we'll try this all the time and if it works out OK eliminate the #else
if ((unsigned long long)freq % 100 != 0 // only need to do if < 100Hz interval
|| freq > 100e6 // or if we are in the VHF and up range
if (((unsigned long long)freq % 100 != 0 // only need to do if < 100Hz interval
|| freq > 100e6) // or if we are in the VHF and up range
#if 0
// do we need to only do this when cache is turned on? 2020-07-02 W9MDB
&& rig->state.cache.timeout_ms > 0
#endif
)
{
// some rigs we can skip this check for speed sake
if (rig->state.rig_model == RIG_MODEL_MALACHITE)
{
rig_set_cache_freq(rig, vfo, freq);
ELAPSED2;
LOCK(0);
RETURNFUNC(RIG_OK);
}
// Unidirectional rigs do not reset cache
if (rig->caps->rig_model != RIG_MODEL_FT736R)
{
@ -2012,6 +2024,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
}
HAMLIB_TRACE;
retcode = rig_get_freq(rig, vfo, &freq_new);
if (retcode != RIG_OK)
@ -2064,7 +2077,13 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
*
* \sa rig_set_freq()
*/
#if BUILTINFUNC
#undef rig_get_freq
int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq, const char *func)
#define rig_get_freq(r,v,f) rig_get_freq(r,v,f,__builtin_FUNCTION())
#else
int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
#endif
{
const struct rig_caps *caps;
int retcode;
@ -2073,6 +2092,14 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
pbwidth_t width;
ENTERFUNC;
#if BUILTINFUNC
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, called from %s\n",
__func__,
rig_strvfo(vfo), func);
#else
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__,
rig_strvfo(vfo));
#endif
if (CHECK_RIG_ARG(rig))
{
@ -2850,6 +2877,7 @@ pbwidth_t HAMLIB_API rig_passband_wide(RIG *rig, rmode_t mode)
#if BUILTINFUNC
#undef rig_set_vfo
int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo, const char *func)
#define rig_set_vfo(r,v) rig_set_vfo(r,v,__builtin_FUNCTION())
#else
int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo)
#endif
@ -5144,12 +5172,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
if ((!(caps->targetable_vfo & RIG_TARGETABLE_FREQ))
&& (!(rig->caps->rig_model == RIG_MODEL_NETRIGCTL)))
#if BUILTINFUNC
rig_set_vfo(rig, rx_vfo, __builtin_FUNCTION());
#else
rig_set_vfo(rig, rx_vfo);
#endif
if (rx_vfo == RIG_VFO_CURR
|| rx_vfo == rig->state.current_vfo)