Add rig_test_2038 to rig_init so it will show on all systems

https://github.com/Hamlib/Hamlib/issues/1478
pull/1488/head
Mike Black W9MDB 2024-01-24 15:48:05 -06:00
rodzic d8a9968fac
commit fabfe61a45
3 zmienionych plików z 104 dodań i 22 usunięć

Wyświetl plik

@ -3042,6 +3042,30 @@ int rig_get_band_rig(RIG *rig, freq_t freq, const char *band)
return 0; // just give a value for now of the 1st band -- this should be an error return 0; // just give a value for now of the 1st band -- this should be an error
} }
// Returns RIG_OK if 2038 time routines pass tests
int rig_test_2038(RIG *rig)
{
time_t x;
x = (time_t)((1U << 31) - 1);
char *s = ctime(&x);
if (!strstr(s, "2038")) { return 1; }
x += 1;
s = ctime(&x);
if (!strstr(s, "2038")) { return 1; }
x += 1;
s = ctime(&x);
if (!strstr(s, "2038")) { return 1; }
return 0;
}
//! @endcond //! @endcond
/** @} */ /** @} */

Wyświetl plik

@ -216,6 +216,8 @@ extern HAMLIB_EXPORT(hamlib_band_t) rig_get_band(RIG *rig, freq_t freq, int band
extern HAMLIB_EXPORT(const char*) rig_get_band_str(RIG *rig, hamlib_band_t band, int which); extern HAMLIB_EXPORT(const char*) rig_get_band_str(RIG *rig, hamlib_band_t band, int which);
extern HAMLIB_EXPORT(int) rig_get_band_rig(RIG *rig, freq_t freq, const char *band); extern HAMLIB_EXPORT(int) rig_get_band_rig(RIG *rig, freq_t freq, const char *band);
extern HAMLIB_EXPORT(int) rig_test_2038(RIG *rig);
__END_DECLS __END_DECLS
#endif /* _MISC_H */ #endif /* _MISC_H */

Wyświetl plik

@ -521,6 +521,16 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
hamlib_port_t *rp, *pttp, *dcdp; hamlib_port_t *rp, *pttp, *dcdp;
int i; int i;
if (rig_test_2038(NULL))
{
rig_debug(RIG_DEBUG_WARN,
"%s: 2038 time test failed....some time values may be incorrect\n", __func__);
}
else
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: 2038 time test passed\n", __func__);
}
rig_check_rig_caps(); rig_check_rig_caps();
rig_check_backend(rig_model); rig_check_backend(rig_model);
@ -2732,7 +2742,9 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
pbwidth_t cache_width; pbwidth_t cache_width;
int cache_ms_freq, cache_ms_mode, cache_ms_width; int cache_ms_freq, cache_ms_mode, cache_ms_width;
rig_get_cache(rig, vfo, &cache_freq, &cache_ms_freq, &cache_mode, &cache_ms_mode, &cache_width, &cache_ms_width); rig_get_cache(rig, vfo, &cache_freq, &cache_ms_freq, &cache_mode,
&cache_ms_mode, &cache_width, &cache_ms_width);
if (cache_mode == mode) if (cache_mode == mode)
{ {
rig_debug(RIG_DEBUG_TRACE, "%s: mode not changing, so ignoring\n", rig_debug(RIG_DEBUG_TRACE, "%s: mode not changing, so ignoring\n",
@ -2743,7 +2755,8 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
} }
} }
rig_debug(RIG_DEBUG_TRACE, "%s: mode is not targetable, VFO swapping needed\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s: mode is not targetable, VFO swapping needed\n",
__func__);
if (!caps->set_vfo) if (!caps->set_vfo)
{ {
@ -2849,6 +2862,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
curr_vfo = rig->state.current_vfo; curr_vfo = rig->state.current_vfo;
vfo = vfo_fixup(rig, vfo, rig->state.cache.split); vfo = vfo_fixup(rig, vfo, rig->state.cache.split);
if (vfo == RIG_VFO_CURR) { vfo = curr_vfo; } if (vfo == RIG_VFO_CURR) { vfo = curr_vfo; }
*mode = RIG_MODE_NONE; *mode = RIG_MODE_NONE;
@ -4502,13 +4516,17 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect. // Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo; tx_vfo = rs->tx_vfo;
if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE || tx_vfo == RIG_VFO_CURR) if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE
|| tx_vfo == RIG_VFO_CURR)
{ {
// Turn split on if not enabled already // Turn split on if not enabled already
retcode = rig_set_split_vfo(rig, rs->current_vfo, RIG_SPLIT_ON, vfo_fixup(rig, RIG_VFO_OTHER, RIG_SPLIT_OFF)); retcode = rig_set_split_vfo(rig, rs->current_vfo, RIG_SPLIT_ON, vfo_fixup(rig,
RIG_VFO_OTHER, RIG_SPLIT_OFF));
if (retcode != RIG_OK) if (retcode != RIG_OK)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: error turning split on: result=%d\n", __func__, retcode); rig_debug(RIG_DEBUG_ERR, "%s: error turning split on: result=%d\n", __func__,
retcode);
ELAPSED2; ELAPSED2;
RETURNFUNC2(retcode); RETURNFUNC2(retcode);
} }
@ -4532,10 +4550,12 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = caps->set_split_freq(rig, tx_vfo, tx_freq); retcode = caps->set_split_freq(rig, tx_vfo, tx_freq);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_freq(rig, tx_vfo, tx_freq); rig_set_cache_freq(rig, tx_vfo, tx_freq);
} }
RETURNFUNC2(retcode); RETURNFUNC2(retcode);
} }
@ -4685,7 +4705,8 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect. // Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo; tx_vfo = rs->tx_vfo;
if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE || tx_vfo == RIG_VFO_CURR) if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE
|| tx_vfo == RIG_VFO_CURR)
{ {
// Split frequency not available if split is off // Split frequency not available if split is off
*tx_freq = 0; *tx_freq = 0;
@ -4699,10 +4720,12 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = caps->get_split_freq(rig, tx_vfo, tx_freq); retcode = caps->get_split_freq(rig, tx_vfo, tx_freq);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_freq(rig, tx_vfo, *tx_freq); rig_set_cache_freq(rig, tx_vfo, *tx_freq);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -4712,10 +4735,12 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = caps->get_freq(rig, tx_vfo, tx_freq); retcode = caps->get_freq(rig, tx_vfo, tx_freq);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_freq(rig, tx_vfo, *tx_freq); rig_set_cache_freq(rig, tx_vfo, *tx_freq);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -4856,13 +4881,17 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect. // Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo; tx_vfo = rs->tx_vfo;
if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE || tx_vfo == RIG_VFO_CURR) if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE
|| tx_vfo == RIG_VFO_CURR)
{ {
// Turn split on if not enabled already // Turn split on if not enabled already
retcode = rig_set_split_vfo(rig, rs->current_vfo, RIG_SPLIT_ON, vfo_fixup(rig, RIG_VFO_OTHER, RIG_SPLIT_OFF)); retcode = rig_set_split_vfo(rig, rs->current_vfo, RIG_SPLIT_ON, vfo_fixup(rig,
RIG_VFO_OTHER, RIG_SPLIT_OFF));
if (retcode != RIG_OK) if (retcode != RIG_OK)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: error turning split on: result=%d\n", __func__, retcode); rig_debug(RIG_DEBUG_ERR, "%s: error turning split on: result=%d\n", __func__,
retcode);
ELAPSED2; ELAPSED2;
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -4882,7 +4911,8 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
if (tx_mode == RIG_MODE_NONE) if (tx_mode == RIG_MODE_NONE)
{ {
// Get TX VFO mode from cache to avoid extra VFO swapping // Get TX VFO mode from cache to avoid extra VFO swapping
rig_get_cache(rig, tx_vfo, &cache_freq, &cache_ms_freq, &cache_mode, &cache_ms_mode, &cache_width, &cache_ms_width); rig_get_cache(rig, tx_vfo, &cache_freq, &cache_ms_freq, &cache_mode,
&cache_ms_mode, &cache_width, &cache_ms_width);
tx_mode = cache_mode; tx_mode = cache_mode;
} }
@ -4892,10 +4922,12 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = caps->set_split_mode(rig, tx_vfo, tx_mode, tx_width); retcode = caps->set_split_mode(rig, tx_vfo, tx_mode, tx_width);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width); rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -4911,10 +4943,12 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = caps->set_mode(rig, tx_vfo, tx_mode, tx_width); retcode = caps->set_mode(rig, tx_vfo, tx_mode, tx_width);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width); rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -4933,11 +4967,14 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
__LINE__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); __LINE__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo));
// If mode is not targetable, we will reuse cached mode/passband instead of trying to set them again // If mode is not targetable, we will reuse cached mode/passband instead of trying to set them again
rig_get_cache(rig, tx_vfo, &cache_freq, &cache_ms_freq, &cache_mode, &cache_ms_mode, &cache_width, &cache_ms_width); rig_get_cache(rig, tx_vfo, &cache_freq, &cache_ms_freq, &cache_mode,
&cache_ms_mode, &cache_width, &cache_ms_width);
if ((tx_mode == cache_mode || tx_mode == RIG_MODE_NONE) && (tx_width == cache_width || tx_width == RIG_PASSBAND_NOCHANGE)) if ((tx_mode == cache_mode || tx_mode == RIG_MODE_NONE)
&& (tx_width == cache_width || tx_width == RIG_PASSBAND_NOCHANGE))
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): mode=%s and width=%ld already set for vfo=%s, ignoring\n", rig_debug(RIG_DEBUG_VERBOSE,
"%s(%d): mode=%s and width=%ld already set for vfo=%s, ignoring\n",
__func__, __LINE__, rig_strrmode(tx_mode), tx_width, rig_strvfo(tx_vfo)); __func__, __LINE__, rig_strrmode(tx_mode), tx_width, rig_strvfo(tx_vfo));
ELAPSED2; ELAPSED2;
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
@ -4955,10 +4992,12 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
// special handling for netrigctl to avoid set_vfo // special handling for netrigctl to avoid set_vfo
retcode = caps->set_split_mode(rig, tx_vfo, tx_mode, tx_width); retcode = caps->set_split_mode(rig, tx_vfo, tx_mode, tx_width);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width); rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -5078,7 +5117,8 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect. // Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo; tx_vfo = rs->tx_vfo;
if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE || tx_vfo == RIG_VFO_CURR) if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE
|| tx_vfo == RIG_VFO_CURR)
{ {
// Split mode and filter width are not available if split is off // Split mode and filter width are not available if split is off
*tx_mode = RIG_MODE_NONE; *tx_mode = RIG_MODE_NONE;
@ -5093,10 +5133,12 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = caps->get_split_mode(rig, tx_vfo, tx_mode, tx_width); retcode = caps->get_split_mode(rig, tx_vfo, tx_mode, tx_width);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_mode(rig, tx_vfo, *tx_mode, *tx_width); rig_set_cache_mode(rig, tx_vfo, *tx_mode, *tx_width);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -5106,10 +5148,12 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
HAMLIB_TRACE; HAMLIB_TRACE;
retcode = caps->get_mode(rig, tx_vfo, tx_mode, tx_width); retcode = caps->get_mode(rig, tx_vfo, tx_mode, tx_width);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_mode(rig, tx_vfo, *tx_mode, *tx_width); rig_set_cache_mode(rig, tx_vfo, *tx_mode, *tx_width);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -5232,13 +5276,17 @@ int HAMLIB_API rig_set_split_freq_mode(RIG *rig,
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect. // Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo; tx_vfo = rs->tx_vfo;
if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE || tx_vfo == RIG_VFO_CURR) if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE
|| tx_vfo == RIG_VFO_CURR)
{ {
// Turn split on if not enabled already // Turn split on if not enabled already
retcode = rig_set_split_vfo(rig, rs->current_vfo, RIG_SPLIT_ON, vfo_fixup(rig, RIG_VFO_OTHER, RIG_SPLIT_OFF)); retcode = rig_set_split_vfo(rig, rs->current_vfo, RIG_SPLIT_ON, vfo_fixup(rig,
RIG_VFO_OTHER, RIG_SPLIT_OFF));
if (retcode != RIG_OK) if (retcode != RIG_OK)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: error turning split on: result=%d\n", __func__, retcode); rig_debug(RIG_DEBUG_ERR, "%s: error turning split on: result=%d\n", __func__,
retcode);
ELAPSED2; ELAPSED2;
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -5289,11 +5337,13 @@ int HAMLIB_API rig_set_split_freq_mode(RIG *rig,
#endif #endif
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_freq(rig, tx_vfo, tx_freq); rig_set_cache_freq(rig, tx_vfo, tx_freq);
rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width); rig_set_cache_mode(rig, tx_vfo, tx_mode, tx_width);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
else else
@ -5372,7 +5422,8 @@ int HAMLIB_API rig_get_split_freq_mode(RIG *rig,
// Always use the previously selected TX VFO for split. The targeted VFO will have no effect. // Always use the previously selected TX VFO for split. The targeted VFO will have no effect.
tx_vfo = rs->tx_vfo; tx_vfo = rs->tx_vfo;
if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE || tx_vfo == RIG_VFO_CURR) if (rs->cache.split == RIG_SPLIT_OFF || tx_vfo == RIG_VFO_NONE
|| tx_vfo == RIG_VFO_CURR)
{ {
// Split frequency, mode and filter width are not available if split is off // Split frequency, mode and filter width are not available if split is off
*tx_freq = 0; *tx_freq = 0;
@ -5386,11 +5437,13 @@ int HAMLIB_API rig_get_split_freq_mode(RIG *rig,
{ {
retcode = caps->get_split_freq_mode(rig, tx_vfo, tx_freq, tx_mode, tx_width); retcode = caps->get_split_freq_mode(rig, tx_vfo, tx_freq, tx_mode, tx_width);
ELAPSED2; ELAPSED2;
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig_set_cache_freq(rig, tx_vfo, *tx_freq); rig_set_cache_freq(rig, tx_vfo, *tx_freq);
rig_set_cache_mode(rig, tx_vfo, *tx_mode, *tx_width); rig_set_cache_mode(rig, tx_vfo, *tx_mode, *tx_width);
} }
RETURNFUNC(retcode); RETURNFUNC(retcode);
} }
@ -5504,7 +5557,8 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
} }
} }
rig_debug(RIG_DEBUG_TRACE, "%s: rig supports satmode, not fixing up vfos: rx=%s tx=%s\n", rig_debug(RIG_DEBUG_TRACE,
"%s: rig supports satmode, not fixing up vfos: rx=%s tx=%s\n",
__func__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); __func__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo));
} }
else else
@ -5567,6 +5621,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
// Only update cache on success // Only update cache on success
rs->rx_vfo = rs->current_vfo; rs->rx_vfo = rs->current_vfo;
rs->cache.split = split; rs->cache.split = split;
if (split == RIG_SPLIT_OFF) if (split == RIG_SPLIT_OFF)
{ {
rs->tx_vfo = rs->current_vfo; rs->tx_vfo = rs->current_vfo;
@ -5625,6 +5680,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
{ {
// Only update cache on success // Only update cache on success
rs->cache.split = split; rs->cache.split = split;
if (split == RIG_SPLIT_OFF) if (split == RIG_SPLIT_OFF)
{ {
if (caps->targetable_vfo & RIG_TARGETABLE_FREQ) if (caps->targetable_vfo & RIG_TARGETABLE_FREQ)