From ca9a45c93e36566a5a44b31664281cbfd2ad4966 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 4 Oct 2021 17:34:09 -0500 Subject: [PATCH] Reduce icom auto_power_on timeout from 15 seconds to just over 5 seconds https://github.com/Hamlib/Hamlib/issues/815 --- rigs/icom/icom.c | 23 ++++++++++------------- rigs/icom/icom.h | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index bfc65a8de..93b044030 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -7604,13 +7604,18 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) int fe_max = 175; unsigned char fe_buf[fe_max]; // for FE's to power up int i; - int retry; + int retry, retry_save; struct rig_state *rs = &rig->state; struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called status=%d\n", __func__, (int) status); + // elimininate retries to speed this up + // especially important when rig is not turned on + retry_save = rs->rigport.retry; + rs->rigport.retry = 0; + switch (status) { case RIG_POWER_ON: @@ -7628,40 +7633,31 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) // we'll try 0x18 0x01 now -- should work on STBY rigs too pwr_sc = S_PWR_ON; fe_buf[0] = 0; - retry = rs->rigport.retry; - rs->rigport.retry = 0; priv->serial_USB_echo_off = 1; retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len); - rs->rigport.retry = retry; - // why was this sleep here? We'll try without it - //hl_usleep(3000 * 1000); // give it 3 seconds to wake up break; default: pwr_sc = S_PWR_OFF; fe_buf[0] = 0; - retry = rs->rigport.retry; - rs->rigport.retry = 0; retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len); - rs->rigport.retry = retry; } i = 0; - retry = 3; + retry = 2; if (status == RIG_POWER_ON) // wait for wakeup only { - for (i = 0; i < retry; ++i) // up to 10 attempts { freq_t freq; - sleep(1); // need to see if echo is on or not first // until such time as rig is awake we don't know - icom_get_usb_echo_off(rig); + retval = icom_get_usb_echo_off(rig); + if (retval == -RIG_ETIMEOUT) continue; // Use get_freq as all rigs should repond to this retval = rig_get_freq(rig, RIG_VFO_CURR, &freq); @@ -7680,6 +7676,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) __func__, i + 1, retry); } } + rs->rigport.retry = retry_save; if (i == retry) { diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 36200b0d4..ad352eef7 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20211002" +#define BACKEND_VER "20211004" #define ICOM_IS_SECONDARY_VFO(vfo) ((vfo) & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B)) #define ICOM_GET_VFO_NUMBER(vfo) (ICOM_IS_SECONDARY_VFO(vfo) ? 0x01 : 0x00)