[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. f1fd159b9a964328b3811
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-01-24 18:27:03
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via f1fd159b9a964328b3811181ea9354773c253686 (commit) via 2be172ac4ecfd5203d6ead8c172ee71343286a67 (commit) from c20125a264443133205aee0641647d8d01b0c50a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f1fd159b9a964328b3811181ea9354773c253686 Author: Michael Black W9MDB <mdb...@ya...> Date: Sun Jan 24 12:25:29 2021 -0600 Prevent ftdx101d from setting frequency on the non-tx vfo when in split mode diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 3d9c04ea..e0773367 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -775,6 +775,15 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) target_vfo = 'A' == c ? '0' : '1'; + // some rigs like FTDX101D cannot change non-TX vfo freq + // but they can change the TX vfo + if (is_ftdx101 && rig->state.cache.ptt == RIG_PTT_ON) + { + // then we can't change freq on the non-tx VFO + rig_debug(RIG_DEBUG_TRACE, "%s: ftdx101 check vfo OK, vfo=%s, tx_vfo=%s\n", __func__, rig_strvfo(vfo), rig_strvfo(rig->state.tx_vfo)); + if (vfo != rig->state.tx_vfo) return -RIG_ENTARGET; + } + if (rig->state.cache.ptt == RIG_PTT_ON) // we have a few rigs that can't set TX VFO while PTT_ON { @@ -6687,6 +6696,7 @@ ncboolean newcat_is_rig(RIG *rig, rig_model_t model) /* * newcat_set_tx_vfo does not set priv->curr_vfo + * does set rig->state.tx_vfo */ int newcat_set_tx_vfo(RIG *rig, vfo_t tx_vfo) { @@ -6762,9 +6772,10 @@ int newcat_set_tx_vfo(RIG *rig, vfo_t tx_vfo) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", command, p1, cat_term); - rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str); + rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s, vfo=%s\n", priv->cmd_str, rig_strvfo(tx_vfo)); + + rig->state.tx_vfo = tx_vfo; - /* Set TX VFO */ RETURNFUNC(newcat_set_cmd(rig)); } diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index bf6005ae..ba2e5096 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20210123" +#define NEWCAT_VER "20210124" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 commit 2be172ac4ecfd5203d6ead8c172ee71343286a67 Author: Michael Black W9MDB <mdb...@ya...> Date: Sun Jan 24 10:51:19 2021 -0600 Improve robustness of rigctld Now retries opening indefinitely Improved client side too Error message should now show timeout if rig disappears diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index 5e2d661f..9c452cc7 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -541,6 +541,11 @@ static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value, if (retval != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: write_transaction error=%d\n", __func__, retval); + + // if we get RIG_EIO the socket has probably disappeared + // so bubble up the error so port can re re-opened + if (retval == -RIG_EIO) { return retval; } + hl_usleep(50 * 1000); // 50ms sleep if error } diff --git a/rigs/dummy/flrig.h b/rigs/dummy/flrig.h index 10f2dda1..70c84b0d 100644 --- a/rigs/dummy/flrig.h +++ b/rigs/dummy/flrig.h @@ -28,7 +28,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20210117" +#define BACKEND_VER "20210123" #define EOM "\r" #define TRUE 1 diff --git a/src/rig.c b/src/rig.c index 451617a4..735ddc8f 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1653,12 +1653,16 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo)); +#if 0 // don't think we really need this check + if (CHECK_RIG_ARG(rig) || !freq) { rig_debug(RIG_DEBUG_TRACE, "%s: rig or freq ptr invalid\n", __func__); RETURNFUNC(-RIG_EINVAL); } +#endif + curr_vfo = rig->state.current_vfo; // save vfo for restore later vfo = vfo_fixup(rig, vfo); diff --git a/tests/rigctl.c b/tests/rigctl.c index a23d0696..799e5250 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -615,6 +615,23 @@ int main(int argc, char *argv[]) { exitcode = 2; } + + rig_debug(RIG_DEBUG_ERR, "%s: XXXXXXXXX#1 retcode=%d\n", __func__, retcode); + if (retcode == -RIG_EIO || retcode == 2) + { + rig_debug(RIG_DEBUG_ERR, "%s: i/o error\n", __func__) + + do + { + retcode = rig_close(my_rig); + hl_usleep(1000 * 1000); + rig_debug(RIG_DEBUG_ERR, "%s: rig_close retcode=%d\n", __func__, retcode); + retcode = rig_open(my_rig); + rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d\n", __func__, retcode); + } + while (retcode != RIG_OK); + + } } while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL); diff --git a/tests/rigctld.c b/tests/rigctld.c index 4739e41b..7e74f03b 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -969,6 +969,31 @@ int main(int argc, char *argv[]) return 0; } +static FILE*get_fsockout(struct handle_data *handle_data_arg) +{ +#ifdef __MINGW32__ + return _fdopen(sock_osfhandle, "wb"); +#else + return fdopen(handle_data_arg->sock, "wb"); +#endif +} + +static FILE* get_fsockin(struct handle_data *handle_data_arg) +{ +#ifdef __MINGW32__ + int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY); + + if (sock_osfhandle == -1) + { + rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno)); + goto handle_exit; + } + + return _fdopen(sock_osfhandle, "rb"); +#else + return fdopen(handle_data_arg->sock, "rb"); +#endif +} /* * This is the function run by the threads @@ -985,19 +1010,7 @@ void *handle_socket(void *arg) int ext_resp = 0; char resp_sep = '\n'; -#ifdef __MINGW32__ - int sock_osfhandle = _open_osfhandle(handle_data_arg->sock, _O_RDONLY); - - if (sock_osfhandle == -1) - { - rig_debug(RIG_DEBUG_ERR, "_open_osfhandle error: %s\n", strerror(errno)); - goto handle_exit; - } - - fsockin = _fdopen(sock_osfhandle, "rb"); -#else - fsockin = fdopen(handle_data_arg->sock, "rb"); -#endif + fsockin = get_fsockin(handle_data_arg); if (!fsockin) { @@ -1006,11 +1019,7 @@ void *handle_socket(void *arg) goto handle_exit; } -#ifdef __MINGW32__ - fsockout = _fdopen(sock_osfhandle, "wb"); -#else - fsockout = fdopen(handle_data_arg->sock, "wb"); -#endif + fsockout = get_fsockout(handle_data_arg); if (!fsockout) { @@ -1055,7 +1064,7 @@ void *handle_socket(void *arg) do { - rig_debug(RIG_DEBUG_TRACE, "%s: vfo_mode=%d\n", __func__, + rig_debug(RIG_DEBUG_TRACE, "%s: doing rigctl_parse vfo_mode=%d\n", __func__, handle_data_arg->vfo_mode); retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0, sync_callback, @@ -1063,24 +1072,42 @@ void *handle_socket(void *arg) if (retcode != 0) { rig_debug(RIG_DEBUG_ERR, "%s: rigctl_parse retcode=%d\n", __func__, retcode); } + +#if 0 // disabled -- don't think we need this + + // see https://github.com/Hamlib/Hamlib/issues/516 if (retcode == -1) { //sleep(1); // probably don't need this delay - continue; + //continue; + } + +#endif + + // if socket error or rigctld gets RIG_EIO we'll try to reopen + if (ferror(fsockin)) + { + rig_debug(RIG_DEBUG_ERR, "%s: sockin err=%s\n", __func__, strerror(errno)); + RETURNFUNC(NULL); } - if (ferror(fsockin) || ferror(fsockout)) + if (ferror(fsockin) || ferror(fsockout) || retcode == 2) { + if (ferror(fsockout)) fsockout = get_fsockout(handle_data_arg); rig_debug(RIG_DEBUG_ERR, "%s: socket error in=%d, out=%d\n", __func__, ferror(fsockin), ferror(fsockout)); - retcode = rig_close(my_rig); - rig_debug(RIG_DEBUG_ERR, "%s: rig_close retcode=%d\n", __func__, retcode); - retcode = rig_open(my_rig); - rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d\n", __func__, retcode); + do + { + retcode = rig_close(my_rig); + hl_usleep(1000 * 1000); + rig_debug(RIG_DEBUG_ERR, "%s: rig_close retcode=%d\n", __func__, retcode); + retcode = rig_open(my_rig); + rig_debug(RIG_DEBUG_ERR, "%s: rig_open retcode=%d\n", __func__, retcode); + } + while (retcode != RIG_OK); } } - while (retcode == 0 || retcode == 2 || retcode == -RIG_ENAVAIL); #ifdef HAVE_PTHREAD ----------------------------------------------------------------------- Summary of changes: rigs/dummy/flrig.c | 5 ++++ rigs/dummy/flrig.h | 2 +- rigs/yaesu/newcat.c | 15 ++++++++-- rigs/yaesu/newcat.h | 2 +- src/rig.c | 4 +++ tests/rigctl.c | 17 ++++++++++++ tests/rigctld.c | 79 +++++++++++++++++++++++++++++++++++------------------ 7 files changed, 94 insertions(+), 30 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |