From abf6be0b5e80b3d2376ac873ccf2602ad8e8199f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A3=B0=E7=BA=B3?= <1595220980@qq.com> Date: Sat, 28 Jun 2025 10:22:26 +0800 Subject: [PATCH] Fix compilation errors in GUOHETEC drivers - Remove duplicate function declarations in pmr171_send - Remove duplicate code blocks in pmr171_set_mode - Remove duplicate pmr171_send calls in pmr171_set_ptt - Add missing from_be function implementation - Fix syntax errors that were causing CI failures --- rigs/guohetec/guohetec.c | 20 ++++++++++++++++++ rigs/guohetec/pmr171.c | 45 ---------------------------------------- 2 files changed, 20 insertions(+), 45 deletions(-) diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index 414bc42ae..64e9be3d8 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -96,6 +96,26 @@ uint16_t CRC16Check(const unsigned char *buf, int len) return data; } + /** + * Convert from big-endian byte order + * @param data Data pointer + * @param byte_len Byte length + * @return Converted value + */ + unsigned long long from_be(const unsigned char data[], unsigned int byte_len) + { + unsigned long long result = 0; + int i; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + for (i = 0; i < byte_len; i++) + { + result = (result << 8) | data[i]; + } + + return result; + } // Common response validation functions diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index e3ca96877..386c71ff5 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -321,7 +321,6 @@ static int pmr171_open(RIG *rig) /* ---------------------------------------------------------------------- */ static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) - static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) { hamlib_port_t *rp = RIGPORT(rig); int retry = 5; @@ -644,16 +643,6 @@ static int pmr171_open(RIG *rig) unsigned char reply[10]; unsigned char i = rmode2guohe(mode, pmr171_modes); - if (vfo == RIG_VFO_B) - { - cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes); - cmd[7] = i; - } - else - { - cmd[6] = i; - cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, pmr171_modes); - } if (vfo == RIG_VFO_B) { cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes); @@ -695,39 +684,6 @@ static int pmr171_open(RIG *rig) dump_hex(reply, reply[4] + 5); - // Update cache - CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); - CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); - int crc = CRC16Check(&cmd[4], 4); - cmd[8] = crc >> 8; - cmd[9] = crc & 0xff; - rig_flush(rp); - write_block(rp, cmd, 10); - - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); - } - - // Validate data length - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); - } - - // Validate mode field index won't overflow - if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); - } - - dump_hex(reply, reply[4] + 5); - // Update cache CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); @@ -751,7 +707,6 @@ static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) unsigned char reply[9]; pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); CACHE(rig)->ptt = ptt;