[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. d1c824be5ca38efd9ca68
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-09-03 15:44:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via d1c824be5ca38efd9ca68e2ef5febe567cb2f686 (commit) via 820e4d43103b0b5cda944d496701adc15c16c822 (commit) via 6de4588335619e6ed3aae6dd36b32a5b4afa2de8 (commit) via 7a5834a9a370c37e76302b2bd438602edc2128dc (commit) via acac64c1162b0b0ec3f329b8160cf2b5a7d08769 (commit) via 3e3436bdce4bf966e15c32eb5b167f39d7568fc2 (commit) via ee566880036474fd3ad5a65b09730fad860ae41c (commit) via 9fad079730de45874e87d81beac75a71f80212f0 (commit) via 2ed6142851e9a75488afa26bfd15ce7325e9fe9d (commit) via 261825fa27a086fed5eb0ff7e6132d69dc050ca6 (commit) from fe789607d098c10eee559596ba0191361c8935f8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d1c824be5ca38efd9ca68e2ef5febe567cb2f686 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Sep 3 10:17:51 2021 -0500 Add simple.c example of rig_get_rig_info call diff --git a/tests/simple.c b/tests/simple.c new file mode 100644 index 00000000..165f4ec5 --- /dev/null +++ b/tests/simple.c @@ -0,0 +1,45 @@ +// Example of rig_get_rig_info +// gcc -o simple simple.s -lhamlib + +#include <hamlib/rig.h> + +int main(int argc, char *argv[]) +{ + rig_model_t model = 1; + RIG *rig; + + rig_set_debug_level(RIG_DEBUG_WARN); + rig = rig_init(model); + + if (rig == NULL) + { + fprintf(stderr, "rig_init failed\n"); + return 1; + } + + int retcode = rig_open(rig); + + if (retcode != RIG_OK) + { + fprintf(stderr, "rig_open failed: %s\n", rigerror(retcode)); + return 1; + } + + char riginfo[1024]; + retcode = rig_get_rig_info(rig, riginfo, sizeof(riginfo)); + + if (retcode != RIG_OK) + { + fprintf(stderr, "rig_get_rig_info failed: %s\n", rigerror(retcode)); + return 1; + } + + char vfo[16]; + char mode[16]; + double freq; + sscanf(riginfo, "VFO=%s Freq=%lf Mode=%s", vfo, &freq, mode); + printf("VFO=%s Freq=%.0f Mode=%s\n", vfo, freq, mode); + printf("=========================\nEntire response:\n%s", riginfo); + rig_close(rig); + return 0; +} commit 820e4d43103b0b5cda944d496701adc15c16c822 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Sep 2 17:08:10 2021 -0500 Fix compilation of misc.c with gmtime_r replacement function for mingw https://github.com/Hamlib/Hamlib/issues/784 diff --git a/src/misc.c b/src/misc.c index bc679198..76121037 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2346,6 +2346,27 @@ uint32_t CRC32_function(uint8_t *buf, uint32_t len) return crc ^ 0xFFFFFFFF; } +#if defined(_WIN32) +// gmtime_r can be defined by mingw +#ifndef gmtime_r +static struct tm *gmtime_r(const time_t *t, struct tm *r) +{ + // gmtime is threadsafe in windows because it uses TLS + struct tm *theTm = gmtime(t); + + if (theTm) + { + *r = *theTm; + return r; + } + else + { + return 0; + } +} +#endif // gmtime_r +#endif // _WIN32 + //! @cond Doxygen_Suppress char *date_strget(char *buf, int buflen) { commit 6de4588335619e6ed3aae6dd36b32a5b4afa2de8 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Sep 1 12:45:29 2021 -0500 Do not do vfo_fixup on satmode rigs https://github.com/Hamlib/Hamlib/issues/782 diff --git a/src/rig.c b/src/rig.c index dba18783..bec62059 100644 --- a/src/rig.c +++ b/src/rig.c @@ -4549,8 +4549,12 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, RETURNFUNC(-RIG_ENAVAIL); } - rx_vfo = vfo_fixup(rig, rx_vfo, split); - tx_vfo = vfo_fixup(rig, tx_vfo, split); + // We fix up vfos for non-satmode rigs + if (!(rig->caps->has_get_func & RIG_FUNC_SATMODE)) + { + rx_vfo = vfo_fixup(rig, rx_vfo, split); + tx_vfo = vfo_fixup(rig, tx_vfo, split); + } // set rig to the the requested RX VFO TRACE; commit 7a5834a9a370c37e76302b2bd438602edc2128dc Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Sep 1 09:11:00 2021 -0500 Fix bogus sscanf in kpa_get_powerstat -- function would not work diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c index dc066de6..fa0ed55a 100644 --- a/amplifiers/elecraft/kpa.c +++ b/amplifiers/elecraft/kpa.c @@ -505,7 +505,7 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status) int retval; int operate; int ampon; - int nargs = sscanf(responsebuf, "^ON%d", &on); + int nargs; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -518,6 +518,8 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status) if (retval != RIG_OK) { return retval; } + nargs = sscanf(responsebuf, "^ON%d", &on); + if (nargs != 1) { rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^ON response='%s'\n", __func__, diff --git a/amplifiers/elecraft/kpa1500.c b/amplifiers/elecraft/kpa1500.c index 65724a4f..ea3b2775 100644 --- a/amplifiers/elecraft/kpa1500.c +++ b/amplifiers/elecraft/kpa1500.c @@ -65,7 +65,7 @@ const struct amp_caps kpa1500_amp_caps = AMP_MODEL(AMP_MODEL_ELECRAFT_KPA1500), .model_name = "KPA1500", .mfg_name = "Elecraft", - .version = "20200112.0", + .version = "20210901.0", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .amp_type = AMP_TYPE_OTHER, commit acac64c1162b0b0ec3f329b8160cf2b5a7d08769 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Sep 1 09:08:13 2021 -0500 Really fix icom_set_func so that it can also turn off DUAL_WATCH diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 6f3e187c..7d1d7eb9 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -6579,7 +6579,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) case RIG_FUNC_DUAL_WATCH: fct_cn = C_SET_VFO; - fct_sc = S_DUAL; + fct_sc = status ? S_DUAL_ON : S_DUAL_OFF; break; case RIG_FUNC_SATMODE: commit 3e3436bdce4bf966e15c32eb5b167f39d7568fc2 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Sep 1 09:06:23 2021 -0500 Fix gp2000_get_mode bogus sscanf -- potential seg fault function would not work diff --git a/rigs/rs/gp2000.c b/rigs/rs/gp2000.c index cfc34e3b..f2b7e402 100644 --- a/rigs/rs/gp2000.c +++ b/rigs/rs/gp2000.c @@ -237,7 +237,7 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int buf_len, retval; int nmode; char *pmode = "UNKNOWN"; - int n = sscanf(buf, "%*cI%d", &nmode); + int n; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo)); @@ -252,8 +252,11 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return retval; } + n = sscanf(buf, "%*cI%d", &nmode); + if (n != 1) { + rig_debug(RIG_DEBUG_ERR, "%s: unable to parse mode from '%s'\n", __func__, buf); return -RIG_EPROTO; } diff --git a/rigs/rs/gp2000.h b/rigs/rs/gp2000.h index 13ff3874..848f1ca0 100644 --- a/rigs/rs/gp2000.h +++ b/rigs/rs/gp2000.h @@ -25,7 +25,7 @@ #define _XK2000_H 1 #undef BACKEND_VER -#define BACKEND_VER "20180307" +#define BACKEND_VER "20210901" #include <hamlib/rig.h> commit ee566880036474fd3ad5a65b09730fad860ae41c Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Sep 1 09:00:56 2021 -0500 Fix icom_set_func so that it can also turn off DUAL_WATCH In ic756.c remove ic756_set_func and use icom_set_func instead diff --git a/rigs/icom/ic756.c b/rigs/icom/ic756.c index 64e8243f..cee4dc2a 100644 --- a/rigs/icom/ic756.c +++ b/rigs/icom/ic756.c @@ -88,8 +88,6 @@ struct cmdparams ic756pro_cmdparms[] = { 247 ,60 } \ } } -int ic756_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); - /* * This function deals with the older type radios with only 2 filter widths * (0 - normal, 1 - narrow) @@ -144,7 +142,7 @@ const struct rig_caps ic756_caps = RIG_MODEL(RIG_MODEL_IC756), .model_name = "IC-756", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -260,7 +258,7 @@ const struct rig_caps ic756_caps = .decode_event = icom_decode_event, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -307,7 +305,7 @@ const struct rig_caps ic756pro_caps = RIG_MODEL(RIG_MODEL_IC756PRO), .model_name = "IC-756PRO", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -422,7 +420,7 @@ const struct rig_caps ic756pro_caps = .decode_event = icom_decode_event, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -544,7 +542,7 @@ const struct rig_caps ic756pro2_caps = RIG_MODEL(RIG_MODEL_IC756PROII), .model_name = "IC-756PROII", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -662,7 +660,7 @@ const struct rig_caps ic756pro2_caps = .get_parm = icom_get_parm, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -1105,7 +1103,7 @@ const struct rig_caps ic756pro3_caps = .get_parm = icom_get_parm, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -1130,37 +1128,3 @@ const struct rig_caps ic756pro3_caps = .set_ext_parm = ic756pro2_set_ext_parm, .get_ext_parm = ic756pro2_get_ext_parm, }; - -int ic756_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) -{ - unsigned char fctbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; - int fct_len = 0, acklen, retval; - int fct_cn, fct_sc; /* Command Number, Subcommand */ - - switch (func) - { - case RIG_FUNC_DUAL_WATCH: - fct_cn = C_SET_VFO; - fct_sc = status ? S_DUAL_ON : S_DUAL_OFF; - break; - - default: - return icom_set_func(rig, vfo, func, status); - } - - retval = icom_transaction(rig, fct_cn, fct_sc, fctbuf, fct_len, ackbuf, - &acklen); - - if (retval != RIG_OK) - { - return retval; - } - - if (acklen != 1) - { - rig_debug(RIG_DEBUG_ERR, "%s: wrong frame len=%d\n", __func__, acklen); - return -RIG_EPROTO; - } - - return RIG_OK; -} diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index d13f9d65..6c6e3d42 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20210828" +#define BACKEND_VER "20210901" #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) commit 9fad079730de45874e87d81beac75a71f80212f0 Merge: fe789607 2ed61428 Author: Michael Black <mdb...@ya...> Date: Wed Sep 1 06:06:12 2021 -0500 Merge pull request #780 from wutje/yeasu_cmmd_indirection_removal Yaesu cmnd indirection removal commit 2ed6142851e9a75488afa26bfd15ce7325e9fe9d Author: Wouter van Gulik <pa...@gm...> Date: Mon Aug 30 22:42:51 2021 +0200 Drop pointless rig_s assignment from Yeasu code. rig_s was assigned once and use once, better use rig->state direct; it gives less code to read. Also dramatically shrinked send_priv_cmd for ft1000mp, ft100, ft600, ft747 and ft847 by simply using ncmd direct instead of via a variabel. diff --git a/rigs/yaesu/ft100.c b/rigs/yaesu/ft100.c index 98871fad..2919f836 100644 --- a/rigs/yaesu/ft100.c +++ b/rigs/yaesu/ft100.c @@ -386,19 +386,12 @@ int ft100_close(RIG *rig) static int ft100_send_priv_cmd(RIG *rig, unsigned char cmd_index) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - rig_debug(RIG_DEBUG_VERBOSE, "%s called (%d)\n", __func__, cmd_index); if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - - cmd = (unsigned char *) &ncmd[cmd_index].nseq; /* get native sequence */ - - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) &ncmd[cmd_index].nseq, + YAESU_CMD_LENGTH); } static int ft100_read_status(RIG *rig) @@ -463,14 +456,11 @@ static int ft100_read_flags(RIG *rig) int ft100_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft100: requested freq = %"PRIfreq" Hz \n", freq); cmd_index = FT100_NATIVE_CAT_SET_FREQ; @@ -481,7 +471,7 @@ int ft100_set_freq(RIG *rig, vfo_t vfo, freq_t freq) freq = (int)freq / 10; to_bcd(p_cmd, freq, 8); /* store bcd format in in p_cmd */ - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) @@ -1045,13 +1035,10 @@ int ft100_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift) */ int ft100_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ int pcode; - rig_s = &rig->state; - for (pcode = 0; pcode < 104 && ft100_dcs_list[pcode] != 0; pcode++) { if (ft100_dcs_list[pcode] == code) @@ -1075,7 +1062,7 @@ int ft100_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) p_cmd[3] = (char)pcode; - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft100_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) @@ -1102,7 +1089,6 @@ int ft100_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) */ int ft100_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ int ptone; @@ -1121,8 +1107,6 @@ int ft100_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "%s = %.1f Hz, n=%d\n", __func__, (float)tone / 10, ptone); @@ -1132,7 +1116,7 @@ int ft100_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) p_cmd[3] = (char)ptone; - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft100_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index 9329273a..15029354 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -2332,7 +2332,6 @@ int ft1000d_get_vfo(RIG *rig, vfo_t *vfo) int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) { struct ft1000d_priv_data *priv; - struct rig_state *rig_s; unsigned char mdata[YAESU_CMD_LENGTH]; int err; @@ -2375,8 +2374,7 @@ int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) return err; } - rig_s = &rig->state; - err = read_block(&rig_s->rigport, (char *) mdata, FT1000D_READ_METER_LENGTH); + err = read_block(&rig->state.rigport, (char *) mdata, FT1000D_READ_METER_LENGTH); if (err < 0) { @@ -3267,7 +3265,7 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) return -RIG_EINVAL; } - n = read_block(&rig_s->rigport, p, rl); + n = read_block(&rig->state.rigport, p, rl); } while (n < 0 && retry-- >= 0); @@ -3300,7 +3298,6 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) */ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3311,8 +3308,6 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -3320,7 +3315,7 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3328,7 +3323,7 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } @@ -3349,7 +3344,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft1000d_priv_data *priv; int err; @@ -3375,7 +3369,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[3] = p1; @@ -3383,7 +3376,7 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[1] = p3; priv->p_cmd[0] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3391,7 +3384,7 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } @@ -3409,7 +3402,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, */ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft1000d_priv_data *priv; int err; // cppcheck-suppress * @@ -3434,8 +3426,6 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -3445,7 +3435,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT1000D_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3453,7 +3443,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } @@ -3471,7 +3461,6 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { struct ft1000d_priv_data *priv; - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3485,7 +3474,6 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) rig_debug(RIG_DEBUG_TRACE, "%s: passed rit = %li Hz\n", __func__, rit); priv = (struct ft1000d_priv_data *) rig->state.priv; - rig_s = &rig->state; if (ncmd[ci].ncomp) { @@ -3513,7 +3501,7 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) // Store bcd format into privat command storage area to_bcd(priv->p_cmd, labs(rit) / 10, FT1000D_BCD_RIT); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3521,7 +3509,7 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index 61f28ae7..09c95396 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -703,7 +703,7 @@ int ft1000mp_open(RIG *rig) /* send PACING cmd to rig */ cmd = p->p_cmd; - write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); ft1000mp_get_vfo(rig, &rig->state.current_vfo); /* TODO */ @@ -715,7 +715,6 @@ int ft1000mp_open(RIG *rig) int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; struct ft1000mp_priv_data *p; unsigned char *cmd; /* points to sequence to send */ int cmd_index = 0; @@ -724,8 +723,6 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) p = (struct ft1000mp_priv_data *)rig->state.priv; - rig_s = &rig->state; - rig_debug(RIG_DEBUG_TRACE, "%s: requested freq = %"PRIfreq" Hz \n", __func__, freq); @@ -768,7 +765,7 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) (freq_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); + write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); RETURNFUNC(RIG_OK); } @@ -1560,21 +1557,19 @@ int ft1000mp_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int ft1000mp_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft1000mp_priv_data *p; int n; /* for read_ */ ENTERFUNC; p = (struct ft1000mp_priv_data *)rig->state.priv; - rig_s = &rig->state; // timeout retries are done in read_block now // based on rig backed retry value /* send UPDATE command to fetch data*/ ft1000mp_send_priv_cmd(rig, ci); - n = read_block(&rig_s->rigport, (char *) p->update_data, rl); + n = read_block(&rig->state.rigport, (char *) p->update_data, rl); if (n == -RIG_ETIMEOUT) { @@ -1594,26 +1589,15 @@ static int ft1000mp_get_update_data(RIG *rig, unsigned char ci, static int ft1000mp_send_priv_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - unsigned char cmd_index; /* index of sequence to send */ - ENTERFUNC; - rig_s = &rig->state; - - cmd_index = ci; /* get command */ - - if (! ncmd[cmd_index].ncomp) + if (! ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: attempt to send incomplete sequence\n", __func__); RETURNFUNC(-RIG_EINVAL); } - - cmd = (unsigned char *) ncmd[cmd_index].nseq; /* get native sequence */ - rig_flush(&rig_s->rigport); - write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); RETURNFUNC(RIG_OK); diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c index 78dc7808..43755559 100644 --- a/rigs/yaesu/ft600.c +++ b/rigs/yaesu/ft600.c @@ -298,19 +298,11 @@ int ft600_close(RIG *rig) static int ft600_send_priv_cmd(RIG *rig, unsigned char cmd_index) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - rig_debug(RIG_DEBUG_VERBOSE, "%s called (%d)\n", __func__, cmd_index); if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - - cmd = (unsigned char *) &ncmd[cmd_index].nseq; /* get native sequence */ - - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) &ncmd[cmd_index].nseq, YAESU_CMD_LENGTH); } static int ft600_read_status(RIG *rig) @@ -386,14 +378,11 @@ int ft600_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int ft600_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft600: requested freq = %"PRIfreq" Hz \n", freq); cmd_index = FT600_NATIVE_CAT_SET_FREQ; @@ -403,7 +392,7 @@ int ft600_set_freq(RIG *rig, vfo_t vfo, freq_t freq) freq = (int)freq / 10; to_bcd(p_cmd, freq, 8); /* store bcd format in in p_cmd */ - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft600_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) diff --git a/rigs/yaesu/ft747.c b/rigs/yaesu/ft747.c index 7793420c..1d6ff267 100644 --- a/rigs/yaesu/ft747.c +++ b/rigs/yaesu/ft747.c @@ -372,7 +372,7 @@ int ft747_open(RIG *rig) /* send PACING cmd to rig, once for all */ - ret = write_block(&rig_s->rigport, (char *)p->p_cmd, YAESU_CMD_LENGTH); + ret = write_block(&rig->state.rigport, (char *)p->p_cmd, YAESU_CMD_LENGTH); if (ret < 0) { @@ -407,7 +407,6 @@ int ft747_close(RIG *rig) int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; struct ft747_priv_data *p; unsigned char *cmd; /* points to sequence to send */ // cppcheck-suppress * @@ -415,8 +414,6 @@ int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) p = (struct ft747_priv_data *)rig->state.priv; - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft747: requested freq = %"PRIfreq" Hz \n", freq); /* @@ -435,7 +432,7 @@ int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) rig_force_cache_timeout(&p->status_tv); cmd = p->p_cmd; /* get native sequence */ - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); } @@ -909,24 +906,14 @@ static int ft747_get_update_data(RIG *rig) static int ft747_send_priv_cmd(RIG *rig, unsigned char ci) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - unsigned char cmd_index; /* index of sequence to send */ - - rig_s = &rig->state; - - cmd_index = ci; /* get command */ - - if (! ft747_ncmd[cmd_index].ncomp) + if (! ft747_ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_VERBOSE, "%s: attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - cmd = (unsigned char *) ft747_ncmd[cmd_index].nseq; /* get native sequence */ - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) ft747_ncmd[ci].nseq, YAESU_CMD_LENGTH); } diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index c381217d..5e9f573b 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@ -1697,7 +1697,6 @@ static int ft840_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft840_priv_data *priv; int n, err; /* for read_ */ @@ -1709,7 +1708,6 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft840_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft840_send_static_cmd(rig, ci); @@ -1718,7 +1716,7 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *) priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *) priv->update_data, rl); if (n < 0) { @@ -1745,7 +1743,6 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft840_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1755,8 +1752,6 @@ static int ft840_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -1764,7 +1759,7 @@ static int ft840_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1794,7 +1789,6 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft840_priv_data *priv; int err; @@ -1819,7 +1813,6 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -1827,7 +1820,7 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1855,7 +1848,6 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft840_priv_data *priv; int err; // cppcheck-suppress * @@ -1880,8 +1872,6 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -1891,7 +1881,7 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT840_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1924,7 +1914,6 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) #ifdef USE_FT840_SET_RIT static int ft840_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft840_priv_data *priv; unsigned char p1; unsigned char p2; @@ -1949,8 +1938,6 @@ static int ft840_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -1976,7 +1963,7 @@ static int ft840_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) diff --git a/rigs/yaesu/ft847.c b/rigs/yaesu/ft847.c index 69242e70..addef755 100644 --- a/rigs/yaesu/ft847.c +++ b/rigs/yaesu/ft847.c @@ -645,15 +645,6 @@ int ft847_close(RIG *rig) static int ft847_send_priv_cmd(RIG *rig, int cmd_index) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - - if (!rig) - { - return -RIG_EINVAL; - } - if (! ncmd[cmd_index].ncomp) { rig_debug(RIG_DEBUG_VERBOSE, "%s: attempt to send incomplete sequence\n", @@ -661,11 +652,7 @@ static int ft847_send_priv_cmd(RIG *rig, int cmd_index) return -RIG_EINVAL; } - rig_s = &rig->state; - - cmd = (unsigned char *) ncmd[cmd_index].nseq; /* get native sequence */ - - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) ncmd[cmd_index].nseq, YAESU_CMD_LENGTH); } @@ -717,7 +704,6 @@ static int opcode_vfo(RIG *rig, unsigned char *cmd, int cmd_index, vfo_t vfo) int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; /* sequence to send */ int ret; // cppcheck-suppress * @@ -728,8 +714,6 @@ int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft847: requested freq = %"PRIfreq" Hz, vfo=%s\n", freq, rig_strvfo(vfo)); @@ -761,7 +745,7 @@ int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } } - return write_block(&rig_s->rigport, (char *)p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *)p_cmd, YAESU_CMD_LENGTH); } #define MD_LSB 0x00 diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c index 0ef0e00e..5c1b63e4 100644 --- a/rigs/yaesu/ft890.c +++ b/rigs/yaesu/ft890.c @@ -1636,7 +1636,6 @@ static int ft890_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft890_priv_data *priv; int n, err; /* for read_ */ @@ -1648,7 +1647,6 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft890_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft890_send_static_cmd(rig, ci); @@ -1657,7 +1655,7 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *) priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *) priv->update_data, rl); if (n < 0) { @@ -1684,7 +1682,6 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft890_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1694,8 +1691,6 @@ static int ft890_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -1703,7 +1698,7 @@ static int ft890_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1733,7 +1728,6 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft890_priv_data *priv; int err; @@ -1758,7 +1752,6 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -1766,7 +1759,7 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1794,7 +1787,6 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft890_priv_data *priv; int err; // cppcheck-suppress * @@ -1819,8 +1811,6 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -1830,7 +1820,7 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT890_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1862,7 +1852,6 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft890_priv_data *priv; unsigned char p1; unsigned char p2; @@ -1887,8 +1876,6 @@ static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -1914,7 +1901,7 @@ static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) diff --git a/rigs/yaesu/ft900.c b/rigs/yaesu/ft900.c index 63571919..72f561a6 100644 --- a/rigs/yaesu/ft900.c +++ b/rigs/yaesu/ft900.c @@ -1638,10 +1638,9 @@ static int ft900_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft900_priv_data *priv; - int n, err; /* for read_ */ - + int err; + int n; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (!rig) @@ -1650,7 +1649,6 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft900_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft900_send_static_cmd(rig, ci); @@ -1659,7 +1657,7 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *) priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *) priv->update_data, rl); if (n < 0) { @@ -1686,7 +1684,6 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft900_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1696,8 +1693,6 @@ static int ft900_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -1705,7 +1700,7 @@ static int ft900_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1735,7 +1730,6 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft900_priv_data *priv; int err; @@ -1760,7 +1754,6 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -1768,7 +1761,7 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1796,7 +1789,6 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft900_priv_data *priv; int err; // cppcheck-suppress * @@ -1821,8 +1813,6 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -1832,7 +1822,7 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT900_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1864,7 +1854,6 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) static int ft900_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft900_priv_data *priv; unsigned char p1; unsigned char p2; @@ -1889,8 +1878,6 @@ static int ft900_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -1916,7 +1903,7 @@ static int ft900_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c index d44fe552..900cbc2f 100644 --- a/rigs/yaesu/ft920.c +++ b/rigs/yaesu/ft920.c @@ -453,7 +453,7 @@ static int ft920_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s: read pacing = %i\n", __func__, priv->pacing); - err = write_block(&rig_s->rigport, (char *) priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { @@ -2350,7 +2350,6 @@ static int ft920_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft920_priv_data *priv; int n; /* for read_ */ int err; @@ -2363,7 +2362,6 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft920_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft920_send_static_cmd(rig, ci); @@ -2372,7 +2370,7 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *)priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *)priv->update_data, rl); if (n < 0) { @@ -2399,7 +2397,6 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft920_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -2409,7 +2406,6 @@ static int ft920_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; /* * If we've been passed a command index (ci) that is marked * as dynamic (0), then bail out. @@ -2421,7 +2417,7 @@ static int ft920_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -2451,7 +2447,6 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft920_priv_data *priv; int err; @@ -2481,7 +2476,6 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -2489,7 +2483,7 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { @@ -2516,7 +2510,6 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft920_priv_data *priv; int err; // cppcheck-suppress * @@ -2545,8 +2538,6 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -2556,7 +2547,7 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT920_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { @@ -2587,7 +2578,6 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft920_priv_data *priv; unsigned char p1; unsigned char p2; @@ -2616,8 +2606,6 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -2642,7 +2630,7 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index 41cec45d..4c59dae0 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -2281,7 +2281,6 @@ int ft990_get_vfo(RIG *rig, vfo_t *vfo) int ft990_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) { struct ft990_priv_data *priv; - struct rig_state *rig_s; unsigned char mdata[YAESU_CMD_LENGTH]; int err; @@ -2324,8 +2323,7 @@ int ft990_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) return err; } - rig_s = &rig->state; - err = read_block(&rig_s->rigport, (char *) mdata, FT990_READ_METER_LENGTH); + err = read_block(&rig->state.rigport, (char *) mdata, FT990_READ_METER_LENGTH); if (err < 0) { @@ -3124,7 +3122,6 @@ int ft990_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) */ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) { - struct rig_state *rig_s; struct ft990_priv_data *priv; int n; int err; @@ -3142,7 +3139,6 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) } priv = (struct ft990_priv_data *)rig->state.priv; - rig_s = &rig->state; if (ci == FT990_NATIVE_UPDATE_MEM_CHNL_DATA) // P4 = 0x01 to 0x5a for channel 1 - 90 @@ -3194,7 +3190,7 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) return -RIG_EINVAL; } - n = read_block(&rig_s->rigport, p, rl); + n = read_block(&rig->state.rigport, p, rl); if (n < 0) { @@ -3224,7 +3220,6 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) */ int ft990_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3234,8 +3229,6 @@ int ft990_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -3243,7 +3236,7 @@ int ft990_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3271,7 +3264,6 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft990_priv_data *priv; int err; @@ -3296,7 +3288,6 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[3] = p1; @@ -3304,7 +3295,7 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[1] = p3; priv->p_cmd[0] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3330,7 +3321,6 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, */ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft990_priv_data *priv; int err; // cppcheck-suppress * @@ -3355,8 +3345,6 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -3366,7 +3354,7 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT990_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3391,7 +3379,6 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { struct ft990_priv_data *priv; - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3405,7 +3392,6 @@ int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) rig_debug(RIG_DEBUG_TRACE, "%s: passed rit = %li Hz\n", __func__, rit); priv = (struct ft990_priv_data *) rig->state.priv; - rig_s = &rig->state; if (ncmd[ci].ncomp) { @@ -3433,7 +3419,7 @@ int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) // Store bcd format into privat command storage area to_bcd(priv->p_cmd, labs(rit) / 10, FT990_BCD_RIT); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) commit 261825fa27a086fed5eb0ff7e6132d69dc050ca6 Author: Wouter van Gulik <pa...@gm...> Date: Mon Aug 30 21:48:59 2021 +0200 Stop copying table to private data, use table direct. The table is never written so there is no point makeing the copy; it only adds confusion for a programmer. diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index 8d801cd9..9329273a 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -135,7 +135,6 @@ struct ft1000d_priv_data vfo_t split_vfo; /* TX VFO in split mode Added on 16 Dec 2016 to include FT1000D function */ split_t split; /* split active or not Added on 16 Dec 2016 to include FT1000D function */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of CAT cmd */ - yaesu_cmd_set_t pcs[FT1000D_NATIVE_SIZE]; /* private cmd set */ ft1000d_update_data_t update_data; /* returned data */ }; @@ -325,9 +324,6 @@ int ft1000d_init(RIG *rig) priv = rig->state.priv; -// Copy native cmd set to private cmd storage area - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - // Set default pacing value priv->pacing = FT1000D_PACING_DEFAULT_VALUE; @@ -3297,7 +3293,7 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -3305,7 +3301,6 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft1000d_priv_data *priv; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3316,17 +3311,16 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - priv = (struct ft1000d_priv_data *)rig->state.priv; rig_s = &rig->state; - if (!priv->pcs[ci].ncomp) + if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) priv->pcs[ci].nseq, + err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3345,7 +3339,7 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, @@ -3374,7 +3368,7 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, priv = (struct ft1000d_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -3408,7 +3402,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct * freq freq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -3434,7 +3427,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) priv = (struct ft1000d_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -3469,7 +3462,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * change the rit frequency. * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * rit shortfreq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -3494,7 +3487,7 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv = (struct ft1000d_priv_data *) rig->state.priv; rig_s = &rig->state; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index 260150a1..61f28ae7 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -206,7 +206,6 @@ struct ft1000mp_priv_data unsigned int read_update_delay; /* depends on pacing value */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ - yaesu_cmd_set_t pcs[FT1000MP_NATIVE_SIZE]; /* private cmd set */ unsigned char update_data[2 * FT1000MP_STATUS_UPDATE_LENGTH]; /* returned data--max value, some are less */ }; @@ -642,11 +641,6 @@ int ft1000mp_init(RIG *rig) priv = rig->state.priv; - /* - * Copy native cmd set to private cmd storage area - */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - /* TODO: read pacing from preferences */ priv->pacing = FT1000MP_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ @@ -1601,25 +1595,23 @@ static int ft1000mp_get_update_data(RIG *rig, unsigned char ci, static int ft1000mp_send_priv_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft1000mp_priv_data *p; unsigned char *cmd; /* points to sequence to send */ unsigned char cmd_index; /* index of sequence to send */ ENTERFUNC; - p = (struct ft1000mp_priv_data *)rig->state.priv; rig_s = &rig->state; cmd_index = ci; /* get command */ - if (! p->pcs[cmd_index].ncomp) + if (! ncmd[cmd_index].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: attempt to send incomplete sequence\n", __func__); RETURNFUNC(-RIG_EINVAL); } - cmd = (unsigned char *) p->pcs[cmd_index].nseq; /* get native sequence */ + cmd = (unsigned char *) ncmd[cmd_index].nseq; /* get native sequence */ rig_flush(&rig_s->rigport); write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index c4cb1b1b..c381217d 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@... [truncated message content] |