Fix vfo_fixup link error

Make vfo_fixup a HAMLIB function so it can be used elsewhere
https://github.com/Hamlib/Hamlib/issues/299
pull/345/head
Michael Black W9MDB 2020-06-12 08:28:05 -05:00
rodzic 7cdaa0efd1
commit 1317bb8034
4 zmienionych plików z 62 dodań i 58 usunięć
include/hamlib

Wyświetl plik

@ -2741,6 +2741,7 @@ extern HAMLIB_EXPORT(int) rig_set_cache_timeout_ms(RIG *rig, cache_t selection,
extern HAMLIB_EXPORT(int) rig_set_vfo_opt(RIG *rig, int status);
// cppcheck-suppress *
#include <unistd.h>
extern HAMLIB_EXPORT(int) hl_usleep(useconds_t msec);

Wyświetl plik

@ -1318,6 +1318,65 @@ int HAMLIB_API rig_set_cache_timeout_ms(RIG *rig, cache_t selection, int ms)
return RIG_OK;
}
vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo)
{
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
if (vfo == RIG_VFO_CURR)
{
rig_debug(RIG_DEBUG_TRACE, "%s: Leaving currVFO alone\n", __func__);
return vfo; // don't modify vfo for RIG_VFO_CURR
}
if (vfo == RIG_VFO_RX)
{
vfo = RIG_VFO_A;
if (VFO_HAS_MAIN_SUB_ONLY) { vfo = RIG_VFO_MAIN; }
if (VFO_HAS_MAIN_SUB_A_B_ONLY) { vfo = RIG_VFO_MAIN; }
}
if (vfo == RIG_VFO_TX)
{
int retval;
split_t split = 0;
// get split if we can -- it will default to off otherwise
// maybe split/satmode/vfo/freq/mode can be cached for rigs
// that don't have read capability or get_vfo like Icom?
// Icom's lack of get_vfo is problematic in this respect
// If we cache vfo or others than twiddling the rig may cause problems
retval = rig_get_split(rig, vfo, &split);
if (retval != RIG_OK)
{
split = rig->state.cache.split;
}
int satmode = rig->state.cache.satmode;
vfo = RIG_VFO_A;
if (split) { vfo = RIG_VFO_B; }
if (VFO_HAS_MAIN_SUB_ONLY && !split && !satmode) { vfo = RIG_VFO_MAIN; }
if (VFO_HAS_MAIN_SUB_ONLY && (split || satmode)) { vfo = RIG_VFO_SUB; }
if (VFO_HAS_MAIN_SUB_A_B_ONLY && split) { vfo = RIG_VFO_B; }
if (VFO_HAS_MAIN_SUB_A_B_ONLY && satmode) { vfo = RIG_VFO_SUB; }
rig_debug(RIG_DEBUG_TRACE,
"%s: RIG_VFO_TX changed to %s, split=%d, satmode=%d\n", __func__,
rig_strvfo(vfo), split, satmode);
}
rig_debug(RIG_DEBUG_TRACE, "%s: final vfo=%s\n", __func__, rig_strvfo(vfo));
return vfo;
}
//! @endcond
/** @} */

Wyświetl plik

@ -104,6 +104,8 @@ extern HAMLIB_EXPORT(int) hl_usleep(useconds_t usec);
extern HAMLIB_EXPORT(double) elapsed_ms(struct timespec *start, int start_flag);
extern HAMLIB_EXPORT(vfo_t) vfo_fixup(RIG *rig, vfo_t vfo);
#ifdef PRId64
/** \brief printf(3) format to be used for long long (64bits) type */
# define PRIll PRId64

Wyświetl plik

@ -189,64 +189,6 @@ static const char *rigerror_table[] =
#define ERROR_TBL_SZ (sizeof(rigerror_table)/sizeof(char *))
static vfo_t vfo_fixup(RIG *rig, vfo_t vfo)
{
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
if (vfo == RIG_VFO_CURR)
{
rig_debug(RIG_DEBUG_TRACE, "%s: Leaving currVFO alone\n", __func__);
return vfo; // don't modify vfo for RIG_VFO_CURR
}
if (vfo == RIG_VFO_RX)
{
vfo = RIG_VFO_A;
if (VFO_HAS_MAIN_SUB_ONLY) { vfo = RIG_VFO_MAIN; }
if (VFO_HAS_MAIN_SUB_A_B_ONLY) { vfo = RIG_VFO_MAIN; }
}
if (vfo == RIG_VFO_TX)
{
int retval;
split_t split = 0;
// get split if we can -- it will default to off otherwise
// maybe split/satmode/vfo/freq/mode can be cached for rigs
// that don't have read capability or get_vfo like Icom?
// Icom's lack of get_vfo is problematic in this respect
// If we cache vfo or others than twiddling the rig may cause problems
retval = rig_get_split(rig, vfo, &split);
if (retval != RIG_OK)
{
split = rig->state.cache.split;
}
int satmode = rig->state.cache.satmode;
vfo = RIG_VFO_A;
if (split) { vfo = RIG_VFO_B; }
if (VFO_HAS_MAIN_SUB_ONLY && !split && !satmode) { vfo = RIG_VFO_MAIN; }
if (VFO_HAS_MAIN_SUB_ONLY && (split || satmode)) { vfo = RIG_VFO_SUB; }
if (VFO_HAS_MAIN_SUB_A_B_ONLY && split) { vfo = RIG_VFO_B; }
if (VFO_HAS_MAIN_SUB_A_B_ONLY && satmode) { vfo = RIG_VFO_SUB; }
rig_debug(RIG_DEBUG_TRACE,
"%s: RIG_VFO_TX changed to %s, split=%d, satmode=%d\n", __func__,
rig_strvfo(vfo), split, satmode);
}
rig_debug(RIG_DEBUG_TRACE, "%s: final vfo=%s\n", __func__, rig_strvfo(vfo));
return vfo;
}
/*
* track which rig is opened (with rig_open)
* needed at least for transceive mode