From 69fd5d2596b13b400b93f5f7268612553a6b6296 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 19 Oct 2014 22:46:25 +0100 Subject: [PATCH] Data mode support for the Icom IC-7700 --- icom/ic7700.c | 15 +++---- icom/icom.c | 116 +++++++++++++++++++++++++------------------------- 2 files changed, 65 insertions(+), 66 deletions(-) diff --git a/icom/ic7700.c b/icom/ic7700.c index 12a502255..3a8e87774 100644 --- a/icom/ic7700.c +++ b/icom/ic7700.c @@ -36,19 +36,16 @@ #include "misc.h" #include "bandplan.h" -/* - * TODO: PSK and PSKR - */ -#define IC7700_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM) -#define IC7700_1HZ_TS_MODES IC7700_ALL_RX_MODES -#define IC7700_OTHER_TX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM) +#define IC7700_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM) #define IC7700_AM_TX_MODES (RIG_MODE_AM) +#define IC7700_ALL_RX_MODES IC7700_OTHER_TX_MODES | IC7700_AM_TX_MODES +#define IC7700_1HZ_TS_MODES IC7700_ALL_RX_MODES #define IC7700_FUNCS (RIG_FUNC_FAGC|RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN|RIG_FUNC_NR|RIG_FUNC_MON|RIG_FUNC_MN|RIG_FUNC_ANF|RIG_FUNC_VSC|RIG_FUNC_LOCK) #define IC7700_LEVELS (RIG_LEVEL_PREAMP|RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_COMP|RIG_LEVEL_BKINDL|RIG_LEVEL_BALANCE|RIG_LEVEL_NR|RIG_LEVEL_PBT_IN|RIG_LEVEL_PBT_OUT|RIG_LEVEL_CWPITCH|RIG_LEVEL_RFPOWER|RIG_LEVEL_MICGAIN|RIG_LEVEL_KEYSPD|RIG_LEVEL_NOTCHF|RIG_LEVEL_SQL|RIG_LEVEL_RAWSTR|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_APF|RIG_LEVEL_VOXGAIN|RIG_LEVEL_VOXDELAY|RIG_LEVEL_SWR|RIG_LEVEL_ALC) -#define IC7700_VFOS (RIG_VFO_MAIN|RIG_VFO_SUB|RIG_VFO_MEM) +#define IC7700_VFOS (RIG_VFO_A|RIG_VFO_B|RIG_VFO_MEM) #define IC7700_PARMS (RIG_PARM_ANN|RIG_PARM_BACKLIGHT) #define IC7700_VFO_OPS (RIG_OP_CPY|RIG_OP_XCHG|RIG_OP_FROM_VFO|RIG_OP_TO_VFO|RIG_OP_MCL|RIG_OP_TUNE) @@ -193,8 +190,8 @@ const struct rig_caps ic7700_caps = { .set_freq = icom_set_freq, .get_freq = icom_get_freq, -.set_mode = icom_set_mode, -.get_mode = icom_get_mode, +.set_mode = icom_set_mode_with_data, +.get_mode = icom_get_mode_with_data, .set_vfo = icom_set_vfo, .set_ant = icom_set_ant, .get_ant = icom_get_ant, diff --git a/icom/icom.c b/icom/icom.c index d2170f97c..33839d7fc 100644 --- a/icom/icom.c +++ b/icom/icom.c @@ -639,29 +639,31 @@ int icom_set_mode_with_data (RIG * rig, vfo_t vfo, rmode_t mode, pbwidth_t width if (RIG_OK == retval) { if (RIG_MODE_PKTUSB == mode || RIG_MODE_PKTLSB == mode || RIG_MODE_PKTFM == mode) - { - datamode = 0x01; - } + { + datamode = 0x01; /* some rigs (e.g. IC-7700 & IC-7800) + have D1/2/3 but we cannot know + which to set so just set D1 */ + } else - { - datamode = 0x00; - } + { + datamode = 0x00; + } retval = icom_transaction (rig, C_CTL_MEM, S_MEM_DATA_MODE, &datamode, 1, - ackbuf, &ack_len); + ackbuf, &ack_len); if (retval != RIG_OK) - { - rig_debug(RIG_DEBUG_ERR,"%s: protocol error (%#.2x), " - "len=%d\n", __FUNCTION__,ackbuf[0],ack_len); - } + { + rig_debug(RIG_DEBUG_ERR,"%s: protocol error (%#.2x), " + "len=%d\n", __FUNCTION__,ackbuf[0],ack_len); + } else - { - if (ack_len != 1 || ackbuf[0] != ACK) - { - rig_debug(RIG_DEBUG_ERR,"%s: command not supported ? (%#.2x), " - "len=%d\n", __FUNCTION__,ackbuf[0],ack_len); - } - } + { + if (ack_len != 1 || ackbuf[0] != ACK) + { + rig_debug(RIG_DEBUG_ERR,"%s: command not supported ? (%#.2x), " + "len=%d\n", __FUNCTION__,ackbuf[0],ack_len); + } + } } return retval; @@ -687,12 +689,12 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) priv_caps = (const struct icom_priv_caps *) rig->caps->priv; if (priv_caps->r2i_mode != NULL) { /* call priv code if defined */ - err = priv_caps->r2i_mode(rig, mode, width, - &icmode, &icmode_ext); + err = priv_caps->r2i_mode(rig, mode, width, + &icmode, &icmode_ext); } else { /* else call default */ err = rig2icom_mode(rig, mode, width, - &icmode, &icmode_ext); + &icmode, &icmode_ext); } if (err < 0) @@ -707,24 +709,24 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) icmode_ext = -1; retval = icom_transaction (rig, C_SET_MODE, icmode, (unsigned char *) &icmode_ext, - (icmode_ext == -1 ? 0 : 1), ackbuf, &ack_len); + (icmode_ext == -1 ? 0 : 1), ackbuf, &ack_len); if (retval != RIG_OK) return retval; if (ack_len != 1 || ackbuf[0] != ACK) { rig_debug(RIG_DEBUG_ERR,"icom_set_mode: ack NG (%#.2x), " - "len=%d\n", ackbuf[0],ack_len); + "len=%d\n", ackbuf[0],ack_len); return -RIG_ERJCTED; } #if 0 - /* Tentative DSP filter setting ($1A$03), but not supported by every rig, - * and some models like IC910/Omni VI Plus have a different meaning for - * this subcommand - */ + /* Tentative DSP filter setting ($1A$03), but not supported by every rig, + * and some models like IC910/Omni VI Plus have a different meaning for + * this subcommand + */ if ( (rig->caps->rig_model != RIG_MODEL_IC910) && - (rig->caps->rig_model != RIG_MODEL_OMNIVIP) ) - icom_set_dsp_flt(rig, mode, width); + (rig->caps->rig_model != RIG_MODEL_OMNIVIP) ) + icom_set_dsp_flt(rig, mode, width); #endif return RIG_OK; @@ -748,41 +750,41 @@ int icom_get_mode_with_data(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width * fetch data mode on/off */ retval = icom_transaction (rig, C_CTL_MEM, S_MEM_DATA_MODE, 0, 0, - databuf, &data_len); + databuf, &data_len); if (retval != RIG_OK) - { - rig_debug(RIG_DEBUG_ERR,"%s: protocol error (%#.2x), " - "len=%d\n", __FUNCTION__, databuf[0], data_len); - return -RIG_ERJCTED; - } + { + rig_debug(RIG_DEBUG_ERR,"%s: protocol error (%#.2x), " + "len=%d\n", __FUNCTION__, databuf[0], data_len); + return -RIG_ERJCTED; + } /* * databuf should contain Cn,Sc,D0[,D1] */ data_len -= 2; if (1 > data_len || data_len > 2) /* manual says 1 byte answer - but at least IC756 ProIII - sends 2 - second byte - appears to be same as - second byte from 04 command - which is filter preset - number, whatever it is we - ignore it */ - { - rig_debug(RIG_DEBUG_ERR,"%s: wrong frame len=%d\n", - __FUNCTION__, data_len); - return -RIG_ERJCTED; - } - if (0x01 == databuf[2]) /* 0x01 -> data mode, 0x00 -> not data mode */ - { - switch (*mode) - { - case RIG_MODE_USB: *mode = RIG_MODE_PKTUSB; break; - case RIG_MODE_LSB: *mode = RIG_MODE_PKTLSB; break; - case RIG_MODE_FM: *mode = RIG_MODE_PKTFM; break; - default: break; - } - } + but at least IC756 ProIII + sends 2 - second byte + appears to be same as + second byte from 04 command + which is filter preset + number, whatever it is we + ignore it */ + { + rig_debug(RIG_DEBUG_ERR,"%s: wrong frame len=%d\n", + __FUNCTION__, data_len); + return -RIG_ERJCTED; + } + if (databuf[2]) /* 0x01/0x02/0x03 -> data mode, 0x00 -> not data mode */ + { + switch (*mode) + { + case RIG_MODE_USB: *mode = RIG_MODE_PKTUSB; break; + case RIG_MODE_LSB: *mode = RIG_MODE_PKTLSB; break; + case RIG_MODE_FM: *mode = RIG_MODE_PKTFM; break; + default: break; + } + } } return retval; }