diff --git a/NEWS b/NEWS index 079863a40..f674a7c5c 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,7 @@ Version 5.x -- future * Change FT1000MP Mark V model names to align with FT1000MP Version 4.6 + * Add offset_vfoa and offset_vfob applying to rig_set_freq * Fix K4 to put it in K40 mode when requesting ID * 2023-11-XX -- Planned for Nov 2023 * Fixes for M2 Rotors diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 17fe3cb56..361d7d369 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2592,6 +2592,8 @@ struct rig_state { powerstat_t powerstat; /*caps; rs = &rig->state; @@ -244,7 +254,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_WRITE_DELAY: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -254,7 +264,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_POST_WRITE_DELAY: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -264,7 +274,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_TIMEOUT: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -274,7 +284,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_RETRY: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -289,7 +299,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) return -RIG_EINVAL; } - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -304,7 +314,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) return -RIG_EINVAL; } - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -319,7 +329,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) return -RIG_EINVAL; } - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -453,7 +463,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_RANGE_SELECTED: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -555,7 +565,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_PTT_BITNUM: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL;//value format error } @@ -643,7 +653,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_AUTO_POWER_ON: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -652,7 +662,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_AUTO_POWER_OFF: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -661,7 +671,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_AUTO_DISABLE_SCREENSAVER: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -670,7 +680,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_DISABLE_YAESU_BANDSELECT: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -679,7 +689,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_PTT_SHARE: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -688,7 +698,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_FLUSHX: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -697,7 +707,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_TWIDDLE_TIMEOUT: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -706,7 +716,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_TWIDDLE_RIT: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -715,7 +725,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) break; case TOK_ASYNC: - if (1 != sscanf(val, "%d", &val_i)) + if (1 != sscanf(val, "%ld", &val_i)) { return -RIG_EINVAL; //value format error } @@ -727,6 +737,27 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) rs->tuner_control_pathname = strdup(val); // yeah -- need to free it break; + case TOK_OFFSET_VFOA: + if (1 != sscanf(val, "%ld", &val_i)) + { + return -RIG_EINVAL; //value format error + } + + rs->offset_vfoa = val_i; + rig_debug(RIG_DEBUG_VERBOSE, "%s: offset_vfoa=%ld\n", __func__, val_i); + break; + + case TOK_OFFSET_VFOB: + if (1 != sscanf(val, "%ld", &val_i)) + { + return -RIG_EINVAL; //value format error + } + + rs->offset_vfob = val_i; + rig_debug(RIG_DEBUG_VERBOSE, "%s: offset_vfob=%ld\n", __func__, val_i); + break; + + default: return -RIG_EINVAL; diff --git a/src/rig.c b/src/rig.c index 5fcc74d4d..9b22e346c 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1778,6 +1778,8 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f\n", __func__, rig_strvfo(vfo), freq); #endif + if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) freq += rig->state.offset_vfoa; + else if (vfo == RIG_VFO_B || vfo == RIG_VFO_SUB) freq += rig->state.offset_vfob; if (CHECK_RIG_ARG(rig)) { @@ -2055,7 +2057,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) // we ignore get_freq for the uplink VFO for gpredict to behave better if ((rig->state.uplink == 1 && vfo == RIG_VFO_SUB) - || (rig->state.uplink == 2 && vfo == RIG_VFO_MAIN)) + || (rig->state.uplink == 2 && vfo == RIG_VFO_MAIN) + || (vfo == RIG_VFO_TX && rig->state.cache.ptt == 0)) { rig_debug(RIG_DEBUG_TRACE, "%s: uplink=%d, ignoring get_freq\n", __func__, rig->state.uplink); diff --git a/src/token.h b/src/token.h index 186f9b1ed..41bd7ab2f 100644 --- a/src/token.h +++ b/src/token.h @@ -125,6 +125,8 @@ #define TOK_TWIDDLE_TIMEOUT TOKEN_FRONTEND(128) /** \brief rig: Supporess get_freq on VFOB for satellite RIT tuning */ #define TOK_TWIDDLE_RIT TOKEN_FRONTEND(129) +#define TOK_OFFSET_VFOA TOKEN_FRONTEND(130) +#define TOK_OFFSET_VFOB TOKEN_FRONTEND(131) /* * rotator specific tokens * (strictly, should be documented as rotator_internal)