From 83249fb36a365863ff71ec0d535b13d32e934711 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Sun, 26 Jul 2020 15:07:52 -0500 Subject: [PATCH] Fix FT1000MP RIT read for negative numbers Fix FT1000MP debug statement https://github.com/Hamlib/Hamlib/issues/353 https://github.com/Hamlib/Hamlib/issues/352 --- rigs/yaesu/ft1000mp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index e7ab1097b..b4608d877 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -711,8 +711,6 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) struct ft1000mp_priv_data *p; unsigned char *cmd; /* points to sequence to send */ int cmd_index = 0; - // cppcheck-suppress * - char *fmt = "%s: requested freq after conversion = %"PRIll" Hz\n"; rig_debug(RIG_DEBUG_TRACE, "%s: ft1000mp_set_freq called\n", __func__); @@ -756,7 +754,10 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) to_bcd(p->p_cmd, freq / 10, 8); /* store bcd format in in p_cmd */ /* TODO -- fix 10Hz resolution -- FS */ - rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(p->p_cmd, 8) * 10); + // cppcheck-suppress * + rig_debug(RIG_DEBUG_TRACE, + "%s: requested freq after conversion = %"PRIll" Hz\n", __func__, + (int64_t)from_bcd(p->p_cmd, 8) * 10); cmd = p->p_cmd; /* get native sequence */ write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); @@ -1231,12 +1232,11 @@ int ft1000mp_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) p = &priv->update_data[FT1000MP_SUMO_VFO_A_CLAR]; /* CURR_VFO has VFOA offset */ } - /* big endian integer, kinda */ - f = ((p[0] & 0x7f) << 8) + p[1]; + f = (p[0] << 8) + p[1]; if (p[0] & 0x80) { - f *= -1; + f = ~(f - 1) & 0x7fff; // two's complement } f = f * 10 / 16;