From 547bd0fb555503cb30f5d2dad77d4de2b8e2c13a Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 22 Aug 2021 16:40:48 -0500 Subject: [PATCH] Fix ANT get/set for IC756Pro series https://github.com/Hamlib/Hamlib/issues/774 --- rigs/icom/ic756.c | 10 +++++----- rigs/icom/icom.c | 4 ++-- rigs/icom/icom.h | 2 +- tests/simicom.c | 23 ++++++++++++++++++++++- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/rigs/icom/ic756.c b/rigs/icom/ic756.c index bcdb0baaf..64e8243f8 100644 --- a/rigs/icom/ic756.c +++ b/rigs/icom/ic756.c @@ -127,7 +127,7 @@ static const struct icom_priv_caps ic756_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .r2i_mode = r2i_mode, .agc_levels_present = 1, @@ -291,7 +291,7 @@ static const struct icom_priv_caps ic756pro_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756pro_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .agc_levels_present = 1, .agc_levels = { @@ -461,7 +461,7 @@ static const struct icom_priv_caps ic756pro2_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756pro_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .agc_levels_present = 1, .agc_levels = { @@ -890,7 +890,7 @@ static const struct icom_priv_caps ic756pro3_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756pro_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .agc_levels_present = 1, .agc_levels = { @@ -976,7 +976,7 @@ const struct rig_caps ic756pro3_caps = RIG_MODEL(RIG_MODEL_IC756PROIII), .model_name = "IC-756PROIII", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index e6120c3ec..ba3607cea 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -7601,7 +7601,6 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) RETURNFUNC(retval); } - antopt_len = 0; rig_debug(RIG_DEBUG_TRACE, "%s: antack_len=%d so antopt_len=%d, antopt=0x%02x\n", __func__, priv_caps->antack_len, antopt_len, antopt[0]); @@ -7729,13 +7728,14 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, rig_debug(RIG_DEBUG_ERR, "%s: ackbuf= 0x%02x 0x%02x 0x%02x\n", __func__, ackbuf[0], ackbuf[1], ackbuf[2]); - *ant_curr = rig_idx2setting(ackbuf[1]); + *ant_curr = *ant_tx = *ant_rx = rig_idx2setting(ackbuf[1]); // Note: with IC756/IC-756Pro/IC-7800 and more, ackbuf[2] deals with [RX ANT] // Hopefully any ack_len=3 can fit in the option field if (ack_len == 3) { option->i = ackbuf[2]; + *ant_rx = rig_idx2setting(ackbuf[2]); } RETURNFUNC(RIG_OK); diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 606e271c9..c937844c1 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20210812" +#define BACKEND_VER "20210822" #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) diff --git a/tests/simicom.c b/tests/simicom.c index 509fc54b1..7e7be7134 100644 --- a/tests/simicom.c +++ b/tests/simicom.c @@ -27,6 +27,8 @@ mode_t modeA = RIG_MODE_CW; mode_t modeB = RIG_MODE_USB; pbwidth_t widthA = 0; pbwidth_t widthB = 1; +ant_t ant_curr = 0; +int ant_option = 0; void dumphex(unsigned char *buf, int n) { @@ -159,6 +161,25 @@ void frameParse(int fd, unsigned char *frame, int len) write(fd, frame, 6); break; + case 0x12: // we're simulating the 3-byte version -- not the 2-byte + if (frame[5] != 0xfd) + { + printf("Set ant %d\n", -1); + ant_curr = frame[5]; + ant_option = frame[6]; + dump_hex(frame,8); + } + else { + printf("Get ant\n"); + } + frame[5] = ant_curr; + frame[6] = ant_option; + frame[7]=0xfd; + printf("write 8 bytes\n"); + dump_hex(frame,8); + write(fd, frame, 8); + break; + case 0x1a: // miscellaneous things switch (frame[5]) { @@ -173,7 +194,7 @@ void frameParse(int fd, unsigned char *frame, int len) break; -#if 0 +#if 1 case 0x25: if (frame[6] == 0xfd) {