commit cf858bfa3c8a36eda749c5078ef6f53a119fb285
Author: Michael Black W9MDB <mdblack98@yahoo.com>
Date:   Fri Jan 8 12:04:25 2021 -0600

    Change rig.c to return RIG_ENAVAIL instead of RIG_ENTARGET when set_vfo==NULL
    Add IC706* to rigs that don't do dsp settings
    Remove dynamic detection of transceive status in icom/frame.c
    https://github.com/Hamlib/Hamlib/issues/490

diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c
index 2f96d6db..fe1131c2 100644
--- a/rigs/icom/frame.c
+++ b/rigs/icom/frame.c
@@ -226,6 +226,9 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
     buf[0] = 0;
     frm_len = read_icom_frame(&rs->rigport, buf, sizeof(buf));
 
+#if 0
+    // this was causing rigctld to fail on IC706 and WSJT-X
+    // This dynamic detection is therefore disabled for now
     if (memcmp(buf, sendbuf, frm_len) == 0 && priv->serial_USB_echo_off)
     {
         // Hmmm -- got an echo back when not expected so let's change
@@ -233,6 +236,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
         // And try again
         frm_len = read_icom_frame(&rs->rigport, buf, sizeof(buf));
     }
+#endif
 
     Unhold_Decode(rig);
 
@@ -269,6 +273,7 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
     if (NAK == buf[frm_len - 2]) { return -RIG_ERJCTED; }
 
     *data_len = frm_len - (ACKFRMLEN - 1);
+    rig_debug(RIG_DEBUG_TRACE, "%s: data_len=%d, frm_len=%d\n", __func__, *data_len, frm_len);
     memcpy(data, buf + 4, *data_len);
 
     /*
diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c
index d61b10a2..f50429b7 100644
--- a/rigs/icom/icom.c
+++ b/rigs/icom/icom.c
@@ -1886,7 +1886,7 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
 
     retval = icom_transaction(rig, C_RD_MODE, -1, NULL, 0, modebuf, &mode_len);
 
-    if (mode_len == 3)
+    if (--mode_len == 3)
     {
         priv_data->filter = modebuf[2];
         rig_debug(RIG_DEBUG_TRACE,
@@ -1933,8 +1933,12 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
      * not ask for DSP filter settings */
     /* Likewise, don't ask if we happen to be an Omni VI Plus */
     /* Likewise, don't ask if we happen to be an IC-R30 */
+    /* Likewise, don't ask if we happen to be an IC-706* */
     if ((rig->caps->rig_model == RIG_MODEL_IC910) ||
             (rig->caps->rig_model == RIG_MODEL_OMNIVIP) ||
+            (rig->caps->rig_model == RIG_MODEL_IC706) ||
+            (rig->caps->rig_model == RIG_MODEL_IC706MKII) ||
+            (rig->caps->rig_model == RIG_MODEL_IC706MKIIG) ||
             (rig->caps->rig_model == RIG_MODEL_ICR30))
     {
         return RIG_OK;
diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h
index 3a680edc..413d2c98 100644
--- a/rigs/icom/icom.h
+++ b/rigs/icom/icom.h
@@ -30,7 +30,7 @@
 #include <sys/time.h>
 #endif
 
-#define BACKEND_VER "20210106"
+#define BACKEND_VER "20210107"
 
 /*
  * defines used by comp_cal_str in rig.c
diff --git a/src/rig.c b/src/rig.c
index bcd8377d..188d813a 100644
--- a/src/rig.c
+++ b/src/rig.c
@@ -1448,7 +1448,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
 
         if (!caps->set_vfo)
         {
-            return -RIG_ENTARGET;
+            return -RIG_ENAVAIL;
         }
 
         if (twiddling(rig))
@@ -1767,7 +1767,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
 
         if (!caps->set_vfo)
         {
-            return -RIG_ENTARGET;
+            return -RIG_ENAVAIL;
         }
 
         curr_vfo = rig->state.current_vfo;
@@ -1877,7 +1877,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
 
         if (!caps->set_vfo)
         {
-            return -RIG_ENTARGET;
+            return -RIG_ENAVAIL;
         }
 
         curr_vfo = rig->state.current_vfo;
@@ -2300,7 +2300,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
 
             if (!caps->set_vfo)
             {
-                return -RIG_ENTARGET;
+                return -RIG_ENAVAIL;
             }
 
             curr_vfo = rig->state.current_vfo;
@@ -2519,7 +2519,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
 
         if (!caps->set_vfo)
         {
-            return -RIG_ENTARGET;
+            return -RIG_ENAVAIL;
         }
 
         curr_vfo = rig->state.current_vfo;
@@ -2729,7 +2729,7 @@ int HAMLIB_API rig_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
 
         if (!caps->set_vfo)
         {
-            return -RIG_ENTARGET;
+            return -RIG_ENAVAIL;
         }
 
         curr_vfo = rig->state.current_vfo;
@@ -2831,7 +2831,7 @@ int HAMLIB_API rig_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -2899,7 +2899,7 @@ int HAMLIB_API rig_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -2967,7 +2967,7 @@ int HAMLIB_API rig_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -3035,7 +3035,7 @@ int HAMLIB_API rig_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -3694,7 +3694,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig,
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -3804,7 +3804,7 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig,
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
 #if 0 // why were we doing this?  Shouldn't need to set_vfo to figure out tx_vfo
@@ -3885,7 +3885,7 @@ int HAMLIB_API rig_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -3953,7 +3953,7 @@ int HAMLIB_API rig_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4021,7 +4021,7 @@ int HAMLIB_API rig_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4089,7 +4089,7 @@ int HAMLIB_API rig_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4157,7 +4157,7 @@ int HAMLIB_API rig_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4225,7 +4225,7 @@ int HAMLIB_API rig_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4298,7 +4298,7 @@ int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4373,7 +4373,7 @@ int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4797,7 +4797,7 @@ int HAMLIB_API rig_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4897,7 +4897,7 @@ int HAMLIB_API rig_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -4965,7 +4965,7 @@ int HAMLIB_API rig_send_dtmf(RIG *rig, vfo_t vfo, const char *digits)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -5034,7 +5034,7 @@ int HAMLIB_API rig_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -5102,7 +5102,7 @@ int HAMLIB_API rig_send_morse(RIG *rig, vfo_t vfo, const char *msg)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -5161,7 +5161,7 @@ int HAMLIB_API rig_stop_morse(RIG *rig, vfo_t vfo)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -5252,7 +5252,7 @@ int HAMLIB_API rig_wait_morse(RIG *rig, vfo_t vfo)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
@@ -5320,7 +5320,7 @@ int HAMLIB_API rig_send_voice_mem(RIG *rig, vfo_t vfo, int ch)
 
     if (!caps->set_vfo)
     {
-        return -RIG_ENTARGET;
+        return -RIG_ENAVAIL;
     }
 
     curr_vfo = rig->state.current_vfo;
