[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 41de3425d24edcbd448e0
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2024-04-01 19:36:13
|
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 41de3425d24edcbd448e0231692eeacc58909521 (commit) via a4cd6deb9ddcbbf3f259a52937c0b2e1d094009a (commit) via de719760445da30809786a6e7f096d29594ba805 (commit) via 59fca440a537e5b858e92e67e5b8c6fd8e240aef (commit) via 7b8f263b213da1649750fc4b38324096f769766f (commit) via 0353fdcae07f9c5d4eb87f700da86d6042c019de (commit) via e2b5a3bcb5170662460180742c329c13fdd994f7 (commit) via 00dbd6a6df87733cbea105bf3d924ebe32ecebd2 (commit) via ce4e9bfdf06ae67da2fbb7fcee285e742e6d9c5c (commit) via 9f997d799d7c132b5d7c0d18f85785bad5141595 (commit) via 55d5f8b64a259664374778f2f1e7ef6eb24def8d (commit) via 0a0118b7977974d6fc5bdf951b0a216e4987540b (commit) via 295ad7475762ab2a4b0d8eb0923e3e255ae84500 (commit) via 2d0b8b807d220c10e49ba9c0f94b408ac3fd9d68 (commit) via 4b436479d1667f1ee3f9f50db07a2a3fc9bdb7e4 (commit) via 406b947134502996a1eca14a98b53716b86b5cec (commit) via 53b01d829ed7ebaf1742353117db1646051a9330 (commit) via 896230beeda0bbda4f551a754d47dcd0e7683f80 (commit) via 8ebffd20b6afab1977729735947dcd1c6d40dfa6 (commit) from dc375c6d005c1c143a7088e5792d10d6638e29f0 (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 41de3425d24edcbd448e0231692eeacc58909521 Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Mar 31 12:22:02 2024 -0500 Fix hamlib_version in netrigctl_open and blank agc_levels from FLRig diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index 207ca9083..1a682a66d 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -889,6 +889,11 @@ static int netrigctl_open(RIG *rig) p = strtok(NULL, ";"); } } + else if (strcmp(setting, "hamlib_version") == 0) + { + printf("rigctld: %s\n", value); + } + else { diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 02ee83d7c..aa4c7de98 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -4705,7 +4705,7 @@ declare_proto_rig(dump_state) fprintf(fout, "rig_model=%d\n", rig->caps->rig_model); fprintf(fout, "rigctld_version=%s\n", hamlib_version2); rig_sprintf_agc_levels(rig, buf, sizeof(buf)); - fprintf(fout, "agc_levels=%s\n", buf); + if (strlen(buf) > 0) fprintf(fout, "agc_levels=%s\n", buf); if (rig->caps->ctcss_list) { commit a4cd6deb9ddcbbf3f259a52937c0b2e1d094009a Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Mar 31 12:21:55 2024 -0500 Update simic7000.c diff --git a/simulators/simic7000.c b/simulators/simic7000.c index 6f4b3ccc0..61808432e 100644 --- a/simulators/simic7000.c +++ b/simulators/simic7000.c @@ -132,6 +132,8 @@ void frameParse(int fd, unsigned char *frame, int len) { case 0x03: + if (frame[5] != 0xfd) + { //from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2); if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { @@ -149,6 +151,18 @@ void frameParse(int fd, unsigned char *frame, int len) if (powerstat) { n = write(fd, frame, 11); + dump_hex(frame, 11); + } + else + { + if (current_vfo==RIG_VFO_A) + freqA = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2); + else + freqB = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2); + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + } } break; @@ -410,8 +424,8 @@ void frameParse(int fd, unsigned char *frame, int len) { printf("0x05 0x00 0x92 received\n"); transceive = frame[8]; - frame[6] = 0xfb; - frame[7] = 0xfd; + frame[4] = 0xfb; + frame[5] = 0xfd; n = write(fd, frame, 8); } else commit de719760445da30809786a6e7f096d29594ba805 Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Mar 30 23:40:59 2024 -0500 Fix CPU usage with rigctlcom in sleep.c Hopefully doesn't affect other things too much diff --git a/src/sleep.c b/src/sleep.c index b3d2d34a2..bf1dc5454 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -62,7 +62,7 @@ int hl_usleep(rig_useconds_t usec) tv1.tv_sec = (time_t) delay; tv1.tv_nsec = (long)((delay - tv1.tv_sec) * 1e+9); tv2.tv_sec = 0; - tv2.tv_nsec = 10; + tv2.tv_nsec = 1000000; // rig_debug(RIG_DEBUG_CACHE,"usec=%ld, sleep_time=%f, tv1=%ld,%ld\n", usec, sleep_time, (long)tv1.tv_sec, // (long)tv1.tv_nsec); @@ -194,7 +194,7 @@ int main() { char buf[256]; time(&rawtime); - hl_usleep(1000000 * 1000); // test 1s sleep + hl_usleep(1000000); // test 1s sleep date_strget(buf, sizeof(buf), 0); printf("%s\n", buf); time(&rawtime); commit 59fca440a537e5b858e92e67e5b8c6fd8e240aef Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Mar 30 17:21:29 2024 -0500 Fix rigctld CPU usage when client impolitely disconnects diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 9dabe4dcd..02ee83d7c 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -575,6 +575,8 @@ static int scanfc(FILE *fin, const char *format, void *p) if (ret < 1) { rig_debug(RIG_DEBUG_TRACE, "%s: ret=%d\n", __func__, ret); } + if (errno == 22) return -22; + if (ferror(fin)) { rig_debug(RIG_DEBUG_ERR, "%s: errno=%d, %s\n", __func__, errno, strerror(errno)); } return ret; commit 7b8f263b213da1649750fc4b38324096f769766f Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Mar 30 10:06:08 2024 -0500 Reduce verbosity in netrigctl.c diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index d3b1e9b08..207ca9083 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -635,7 +635,7 @@ static int netrigctl_open(RIG *rig) ret = read_string(rp, (unsigned char *) buf, BUF_MAX, "\n", 1, 0, 1); strtok(buf, "\r\n"); // chop the EOL -rig_debug(RIG_DEBUG_ERR, "## %s\n", buf); + rig_debug(RIG_DEBUG_VERBOSE, "## %s\n", buf); if (ret <= 0) { RETURNFUNC((ret < 0) ? ret : -RIG_EPROTO); commit 0353fdcae07f9c5d4eb87f700da86d6042c019de Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Mar 29 22:23:36 2024 -0500 Reduce debug in flrig diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index ecdf3c0c1..a4c38d1b3 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -1831,7 +1831,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) if (strstr(p, "k")) { *width = *width * 1000; } - rig_debug(RIG_DEBUG_ERR, "%s: p=%s, *width=%d\n", __func__, p, (int)(*width)); + rig_debug(RIG_DEBUG_TRACE, "%s: p=%s, *width=%d\n", __func__, p, (int)(*width)); if (strcmp(p, "FIXED") == 0) { commit e2b5a3bcb5170662460180742c329c13fdd994f7 Merge: 00dbd6a6d ce4e9bfdf Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Mar 29 17:10:07 2024 -0500 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit 00dbd6a6df87733cbea105bf3d924ebe32ecebd2 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Mar 29 17:09:38 2024 -0500 Fix rigctlcom.s IF command for CW Skimmer use and others that might use IF command diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index cadcb6904..2716b98fe 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -224,7 +224,7 @@ int main(int argc, char *argv[]) char conf_parms[MAXCONFLEN] = ""; int status; - printf("rigctlcom Version 1.4\n"); + printf("rigctlcom Version 1.5\n"); while (1) { @@ -807,7 +807,7 @@ static int handle_ts2000(void *arg) char response[64]; char *fmt = // cppcheck-suppress * - "IF%011"PRIll" %1d%1d%1d%02d%1d%1"PRIll"%1d%1d%1d%1d%02d%1d;"; + "IF%011"PRIll"%04d %1d%1d%1d%02d%1d%1"PRIll"%1d%1d%1d%1d%02d%1d;"; if (retval != RIG_OK) { commit ce4e9bfdf06ae67da2fbb7fcee285e742e6d9c5c Merge: 55d5f8b64 9f997d799 Author: Michael Black <mdb...@ya...> Date: Thu Mar 28 15:46:13 2024 -0500 Merge pull request #1532 from GeoBaltz/rp8 More pointer conversions commit 9f997d799d7c132b5d7c0d18f85785bad5141595 Author: George Baltz N3GB <Geo...@gm...> Date: Thu Mar 28 16:26:21 2024 -0400 Fix incorrect port read for elevation Add missing port parameters for rotp2 Remove funky character(^B) from simrotorez.c so `file` and `more` think it is plain text. Dunno if this works on the real H/W, but at least the simulator can get and set az/el position without errors. diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index ec4e559ca..819675870 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -667,7 +667,7 @@ static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, //TODO: Should this be rotp or rotp2???? //err = read_block(&rs->rotport, (unsigned char *) az, AZ_READ_LEN); - err = read_block(rotp, (unsigned char *) az, AZ_READ_LEN); + err = read_block(rotp2, (unsigned char *) az, AZ_READ_LEN); if (err != AZ_READ_LEN) { diff --git a/simulators/simrotorez.c b/simulators/simrotorez.c index aa1ebc6ea..95f21262f 100644 --- a/simulators/simrotorez.c +++ b/simulators/simrotorez.c @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) int flag = 0; while (1) - { + { int bytes; if (!flag) bytes = getmyline(fd, buf); else bytes = getmyline(fd2, buf); diff --git a/src/rotator.c b/src/rotator.c index 166fe7a6a..5dd492b18 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -266,12 +266,12 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model) rotp2 = ROTPORT2(rot); rs->comm_state = 0; - rotp->type.rig = caps->port_type; /* default from caps */ + rotp->type.rig = rotp2->type.rig = caps->port_type; /* default from caps */ - rotp->write_delay = caps->write_delay; - rotp->post_write_delay = caps->post_write_delay; - rotp->timeout = caps->timeout; - rotp->retry = caps->retry; + rotp->write_delay = rotp2->write_delay = caps->write_delay; + rotp->post_write_delay = rotp2->post_write_delay = caps->post_write_delay; + rotp->timeout = rotp2->timeout = caps->timeout; + rotp->retry = rotp2->retry = caps->retry; switch (caps->port_type) { commit 55d5f8b64a259664374778f2f1e7ef6eb24def8d Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 26 16:59:57 2024 -0500 Really fix FLRig get_bwA return code diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index fc3080436..ecdf3c0c1 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -1769,10 +1769,11 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) cmdp = "rig.get_bwA"; retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); - if (strlen(value) == 0) + if (strlen(value) == 0) // sometimes we get a null reply here -- OK...deal with it { rig_debug(RIG_DEBUG_WARN, "%s: empty value return cached bandwidth\n", __func__); *width = rig->state.cache.widthMainA; + RETURNFUNC(RIG_OK); } if (retval == RIG_OK && strstr(value, "NONE")) commit 0a0118b7977974d6fc5bdf951b0a216e4987540b Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Mar 26 16:25:20 2024 -0500 Fix FLrig get_bwA and get_bwB to return cached value if FLRig returns empty value diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index f8992de77..fc3080436 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -1769,11 +1769,18 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) cmdp = "rig.get_bwA"; retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); + if (strlen(value) == 0) + { + rig_debug(RIG_DEBUG_WARN, "%s: empty value return cached bandwidth\n", __func__); + *width = rig->state.cache.widthMainA; + } + if (retval == RIG_OK && strstr(value, "NONE")) { priv->has_get_bwA = priv->has_get_bwB = 0; *width = 0; rig_debug(RIG_DEBUG_VERBOSE, "%s: does not have rig.get_bwA/B\n", __func__); + RETURNFUNC(RIG_OK); } if (retval != RIG_OK || strstr(value, "NONE")) @@ -1787,6 +1794,12 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) cmdp = "rig.get_bwB"; retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); + if (strlen(value) == 0) + { + rig_debug(RIG_DEBUG_WARN, "%s: empty value return cached bandwidth\n", __func__); + *width = rig->state.cache.widthMainA; + RETURNFUNC(RIG_OK); + } if (retval == RIG_OK && strlen(value) == 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: does not have rig.get_bwB\n", __func__); commit 295ad7475762ab2a4b0d8eb0923e3e255ae84500 Author: George Baltz N3GB <Geo...@gm...> Date: Tue Mar 26 02:04:53 2024 -0400 Add macros for amplifier and rotator state pointers. diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 7f3607bcf..9ecb99d46 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2491,6 +2491,8 @@ typedef hamlib_port_t port_t; #define ROTPORT(r) (&r->state.rotport) #define ROTPORT2(r) (&r->state.rotport2) #define STATE(r) (&r->state) +#define AMPSTATE(a) (&(a)->state) +#define ROTSTATE(r) (&(r)->state) /* Then when the rigport address is stored as a pointer somewhere else(say, * in the rig structure itself), the definition could be changed to * #define RIGPORT(r) r->somewhereelse @@ -2506,6 +2508,8 @@ typedef hamlib_port_t port_t; #define HAMLIB_ROTPORT(r) ((hamlib_port_t *)rot_data_pointer(r, RIG_PTRX_ROTPORT)) #define HAMLIB_ROTPORT2(r) ((hamlib_port_t *)rot_data_pointer(r, RIG_PTRX_ROTPORT2)) #define HAMLIB_STATE(r) ((struct rig_state *)rig_data_pointer(r, RIG_PTRX_STATE)) +#define HAMLIB_AMPSTATE(a) ((struct amp_state *)amp_data_pointer(a, RIG_PTRX_AMPSTATE)) +#define HAMLIB_ROTSTATE(r) ((struct rot_state *)rot_data_pointer(r, RIG_PTRX_ROTSTATE)) #endif typedef enum { @@ -2518,6 +2522,8 @@ typedef enum { RIG_PTRX_ROTPORT, RIG_PTRX_ROTPORT2, RIG_PTRX_STATE, + RIG_PTRX_AMPSTATE, + RIG_PTRX_ROTSTATE, // New entries go directly above this line==================== RIG_PTRX_MAXIMUM } rig_ptrx_t; diff --git a/src/amp_conf.c b/src/amp_conf.c index e6a734a5a..434c9e72d 100644 --- a/src/amp_conf.c +++ b/src/amp_conf.c @@ -44,7 +44,7 @@ /* - * Configuration options available in the amp->state struct. + * Configuration options available in the amp_state struct. */ static const struct confparams ampfrontend_cfg_params[] = { @@ -112,7 +112,7 @@ int frontamp_set_conf(AMP *amp, hamlib_token_t token, const char *val) hamlib_port_t *ampp = AMPPORT(amp); int val_i; - rs = &->state; + rs = AMPSTATE(amp); amp_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/src/amp_settings.c b/src/amp_settings.c index ffd399c23..749c42904 100644 --- a/src/amp_settings.c +++ b/src/amp_settings.c @@ -75,7 +75,7 @@ setting_t HAMLIB_API amp_has_set_level(AMP *amp, setting_t level) return 0; } - return (amp->state.has_set_level & level); + return (AMPSTATE(amp)->has_set_level & level); } /** @@ -108,7 +108,7 @@ setting_t HAMLIB_API amp_has_get_level(AMP *amp, setting_t level) return 0; } - return (amp->state.has_get_level & level); + return (AMPSTATE(amp)->has_get_level & level); } /*! @} */ diff --git a/src/amplifier.c b/src/amplifier.c index 896f71f9c..aa41d650c 100644 --- a/src/amplifier.c +++ b/src/amplifier.c @@ -65,7 +65,7 @@ #include "token.h" //! @cond Doxygen_Suppress -#define CHECK_AMP_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state) +#define CHECK_AMP_ARG(r) (!(r) || !(r)->caps || !AMPSTATE(r)->comm_state) //! @endcond /* @@ -224,7 +224,7 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model) /** * \todo Read the Preferences here! */ - rs = &->state; + rs = AMPSTATE(amp); //TODO allocate and link new ampport // For now, use the embedded one @@ -285,8 +285,8 @@ AMP *HAMLIB_API amp_init(amp_model_t amp_model) // Now we have to copy our new rig state hamlib_port structure to the deprecated one // Clients built on older 4.X versions will use the old structure // Clients built on newer 4.5 versions will use the new structure - memcpy(&->state.ampport_deprecated, ap, - sizeof(amp->state.ampport_deprecated)); + memcpy(&rs->ampport_deprecated, ap, + sizeof(rs->ampport_deprecated)); return amp; } @@ -324,7 +324,7 @@ int HAMLIB_API amp_open(AMP *amp) } caps = amp->caps; - rs = &->state; + rs = AMPSTATE(amp); if (rs->comm_state) { @@ -419,8 +419,8 @@ int HAMLIB_API amp_open(AMP *amp) if (status != RIG_OK) { - memcpy(&->state.ampport_deprecated, ap, - sizeof(amp->state.ampport_deprecated)); + memcpy(&rs->ampport_deprecated, ap, + sizeof(rs->ampport_deprecated)); return status; } } @@ -443,8 +443,8 @@ int HAMLIB_API amp_open(AMP *amp) ser_set_rts(ap, 0); } - memcpy(&->state.ampport_deprecated, ap, - sizeof(amp->state.ampport_deprecated)); + memcpy(&rs->ampport_deprecated, ap, + sizeof(rs->ampport_deprecated)); return RIG_OK; } @@ -488,7 +488,7 @@ int HAMLIB_API amp_close(AMP *amp) } caps = amp->caps; - rs = &->state; + rs = AMPSTATE(amp); if (!rs->comm_state) { @@ -571,7 +571,7 @@ int HAMLIB_API amp_cleanup(AMP *amp) /* * check if they forgot to close the amp */ - if (amp->state.comm_state) + if (AMPSTATE(amp)->comm_state) { amp_close(amp); } @@ -969,6 +969,8 @@ void * HAMLIB_API amp_data_pointer(AMP *amp, rig_ptrx_t idx) { case RIG_PTRX_AMPPORT: return AMPPORT(amp); + case RIG_PTRX_AMPSTATE: + return AMPSTATE(amp); default: amp_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx); return NULL; diff --git a/src/rot_conf.c b/src/rot_conf.c index 89a616382..6d96b4be9 100644 --- a/src/rot_conf.c +++ b/src/rot_conf.c @@ -45,7 +45,7 @@ /* - * Configuration options available in the rot->state struct. + * Configuration options available in the rot_state struct. */ static const struct confparams rotfrontend_cfg_params[] = { @@ -143,7 +143,7 @@ int frontrot_set_conf(ROT *rot, hamlib_token_t token, const char *val) hamlib_port_t *rotp = ROTPORT(rot); int val_i; - rs = &rot->state; + rs = ROTSTATE(rot); rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -412,7 +412,7 @@ int frontrot_get_conf(ROT *rot, hamlib_token_t token, char *val, int val_len) hamlib_port_t *rotp = ROTPORT(rot); const char *s; - rs = &rot->state; + rs = ROTSTATE(rot); rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/src/rot_settings.c b/src/rot_settings.c index a75c55844..bee4a8f29 100644 --- a/src/rot_settings.c +++ b/src/rot_settings.c @@ -47,7 +47,7 @@ #ifndef DOC_HIDDEN -# define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state) +# define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(ROTSTATE(r)->comm_state)) #endif /* !DOC_HIDDEN */ @@ -255,7 +255,7 @@ setting_t HAMLIB_API rot_has_get_level(ROT *rot, setting_t level) return 0; } - return (rot->state.has_get_level & level); + return (ROTSTATE(rot)->has_get_level & level); } @@ -293,7 +293,7 @@ setting_t HAMLIB_API rot_has_set_level(ROT *rot, setting_t level) return 0; } - return (rot->state.has_set_level & level); + return (ROTSTATE(rot)->has_set_level & level); } @@ -330,7 +330,7 @@ setting_t HAMLIB_API rot_has_get_parm(ROT *rot, setting_t parm) return 0; } - return (rot->state.has_get_parm & parm); + return (ROTSTATE(rot)->has_get_parm & parm); } @@ -367,7 +367,7 @@ setting_t HAMLIB_API rot_has_set_parm(ROT *rot, setting_t parm) return 0; } - return (rot->state.has_set_parm & parm); + return (ROTSTATE(rot)->has_set_parm & parm); } @@ -404,7 +404,7 @@ setting_t HAMLIB_API rot_has_get_func(ROT *rot, setting_t func) return 0; } - return (rot->state.has_get_func & func); + return (ROTSTATE(rot)->has_get_func & func); } @@ -440,7 +440,7 @@ setting_t HAMLIB_API rot_has_set_func(ROT *rot, setting_t func) return 0; } - return (rot->state.has_set_func & func); + return (ROTSTATE(rot)->has_set_func & func); } diff --git a/src/rotator.c b/src/rotator.c index b1db5c478..166fe7a6a 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -89,7 +89,7 @@ # define DEFAULT_PARALLEL_PORT "/dev/parport0" #endif -#define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state) +#define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(ROTSTATE(r)->comm_state)) /* @@ -258,7 +258,7 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model) /** * \todo Read the Preferences here! */ - rs = &rot->state; + rs = ROTSTATE(rot); //TODO Allocate new rotport[2] // For now, use the embedded ones @@ -345,8 +345,8 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model) // Now we have to copy our new rig state hamlib_port structure to the deprecated one // Clients built on older 4.X versions will use the old structure // Clients built on newer 4.5 versions will use the new structure - memcpy(&rot->state.rotport_deprecated, rotp, - sizeof(rot->state.rotport_deprecated)); + memcpy(&rs->rotport_deprecated, rotp, + sizeof(rs->rotport_deprecated)); return rot; } @@ -386,7 +386,7 @@ int HAMLIB_API rot_open(ROT *rot) } caps = rot->caps; - rs = &rot->state; + rs = ROTSTATE(rot); if (rs->comm_state) { @@ -520,8 +520,8 @@ int HAMLIB_API rot_open(ROT *rot) if (status != RIG_OK) { - memcpy(&rot->state.rotport_deprecated, rotp, - sizeof(rot->state.rotport_deprecated)); + memcpy(&rs->rotport_deprecated, rotp, + sizeof(rs->rotport_deprecated)); return status; } } @@ -544,8 +544,8 @@ int HAMLIB_API rot_open(ROT *rot) ser_set_rts(rotp, 0); } - memcpy(&rot->state.rotport_deprecated, rotp, - sizeof(rot->state.rotport_deprecated)); + memcpy(&rs->rotport_deprecated, rotp, + sizeof(rs->rotport_deprecated)); return RIG_OK; } @@ -580,7 +580,7 @@ int HAMLIB_API rot_close(ROT *rot) } caps = rot->caps; - rs = &rot->state; + rs = ROTSTATE(rot); if (!rs->comm_state) { @@ -632,8 +632,8 @@ int HAMLIB_API rot_close(ROT *rot) rs->comm_state = 0; - memcpy(&rot->state.rotport_deprecated, rotp, - sizeof(rot->state.rotport_deprecated)); + memcpy(&rs->rotport_deprecated, rotp, + sizeof(rs->rotport_deprecated)); return RIG_OK; } @@ -667,7 +667,7 @@ int HAMLIB_API rot_cleanup(ROT *rot) /* * check if they forgot to close the rot */ - if (rot->state.comm_state) + if (ROTSTATE(rot)->comm_state) { rot_close(rot); } @@ -726,11 +726,11 @@ int HAMLIB_API rot_set_position(ROT *rot, return -RIG_EINVAL; } - azimuth += rot->state.az_offset; - elevation += rot->state.el_offset; - caps = rot->caps; - rs = &rot->state; + rs = ROTSTATE(rot); + + azimuth += rs->az_offset; + elevation += rs->el_offset; rot_debug(RIG_DEBUG_VERBOSE, "%s: south_zero=%d \n", __func__, rs->south_zero); @@ -801,7 +801,7 @@ int HAMLIB_API rot_get_position(ROT *rot, } caps = rot->caps; - rs = &rot->state; + rs = ROTSTATE(rot); if (caps->get_position == NULL) { @@ -820,8 +820,8 @@ int HAMLIB_API rot_get_position(ROT *rot, rot_debug(RIG_DEBUG_VERBOSE, "%s: south adj to az=%.2f\n", __func__, az); } - *azimuth = az - rot->state.az_offset; - *elevation = el - rot->state.el_offset; + *azimuth = az - rs->az_offset; + *elevation = el - rs->el_offset; return RIG_OK; } @@ -1057,6 +1057,8 @@ void * HAMLIB_API rot_data_pointer(ROT *rot, rig_ptrx_t idx) return ROTPORT(rot); case RIG_PTRX_ROTPORT2: return ROTPORT2(rot); + case RIG_PTRX_ROTSTATE: + return ROTSTATE(rot); default: rot_debug(RIG_DEBUG_ERR, "%s: Invalid data index=%d\n", __func__, idx); return NULL; commit 2d0b8b807d220c10e49ba9c0f94b408ac3fd9d68 Author: George Baltz N3GB <Geo...@gm...> Date: Sun Mar 17 03:43:25 2024 -0400 Pointerize all state references in rigs/kenwood/* diff --git a/rigs/kenwood/ic10.c b/rigs/kenwood/ic10.c index 38d8fad08..ac57db4b8 100644 --- a/rigs/kenwood/ic10.c +++ b/rigs/kenwood/ic10.c @@ -67,7 +67,7 @@ int ic10_cmd_trim(char *data, int data_len) /** * ic10_transaction - * Assumes rig!=NULL rig->state!=NULL rig->caps!=NULL + * Assumes rig!=NULL STATE(rig)!=NULL rig->caps!=NULL **/ int ic10_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len) @@ -99,7 +99,7 @@ transaction: if (!data) { char buffer[50]; - const struct kenwood_priv_data *priv = rig->state.priv; + const struct kenwood_priv_data *priv = STATE(rig)->priv; if (RIG_OK != (retval = write_block(rp, (unsigned char *) priv->verify_cmd, strlen(priv->verify_cmd)))) @@ -451,7 +451,7 @@ int ic10_set_freq(RIG *rig, vfo_t vfo, freq_t freq) if (vfo == RIG_VFO_CURR) { - tvfo = rig->state.current_vfo; + tvfo = STATE(rig)->current_vfo; } else { diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 19b54fabe..2562e01fc 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -234,7 +234,7 @@ struct confparams kenwood_cfg_params[] = /** * kenwood_transaction - * Assumes rig!=NULL rig->state!=NULL rig->caps!=NULL + * Assumes rig!=NULL STATE(rig)!=NULL rig->caps!=NULL * * Parameters: * cmdstr: Command to be sent to the rig. cmdstr can also be NULL, @@ -262,7 +262,7 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, char *cmd; int len; int retry_read = 0; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); struct rig_state *rs; struct hamlib_port *rp; /* Pointer to rigport structure */ @@ -285,7 +285,7 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, RETURNFUNC2(-RIG_EINVAL); } - rs = &rig->state; + rs = STATE(rig); rp = RIGPORT(rig); rs->transaction_active = 1; @@ -396,7 +396,7 @@ transaction_write: if (!datasize && strncmp(cmdstr, "KY", 2) != 0) { - rig->state.transaction_active = 0; + rs->transaction_active = 0; // there are some commands that have problems with immediate follow-up // so we'll just ignore them @@ -749,7 +749,7 @@ int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf, // QRPLABS can't seem top decide if they give 37 or 38 bytes for IF command if (strncmp(cmd, "IF", 2) == 0 && rig->caps->rig_model == RIG_MODEL_QRPLABS) { break; } - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_ERR, "%s: wrong answer; len for cmd %s: expected = %d, got %d\n", @@ -809,14 +809,14 @@ int kenwood_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called, version %s/%s\n", __func__, BACKEND_VER, rig->caps->version); - rig->state.priv = calloc(1, sizeof(struct kenwood_priv_data)); + STATE(rig)->priv = calloc(1, sizeof(struct kenwood_priv_data)); - if (rig->state.priv == NULL) + if (STATE(rig)->priv == NULL) { RETURNFUNC2(-RIG_ENOMEM); } - priv = rig->state.priv; + priv = STATE(rig)->priv; memset(priv, 0x00, sizeof(struct kenwood_priv_data)); @@ -878,15 +878,15 @@ int kenwood_cleanup(RIG *rig) { ENTERFUNC; - free(rig->state.priv); - rig->state.priv = NULL; + free(STATE(rig)->priv); + STATE(rig)->priv = NULL; RETURNFUNC(RIG_OK); } int kenwood_open(RIG *rig) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); int err, i; char *idptr; @@ -900,7 +900,7 @@ int kenwood_open(RIG *rig) priv->question_mark_response_means_rejected = 0; - if (rig->state.auto_power_on) + if (STATE(rig)->auto_power_on) { // Ensure rig is on rig_set_powerstat(rig, 1); @@ -923,7 +923,7 @@ int kenwood_open(RIG *rig) err = rig_get_powerstat(rig, &powerstat); if (err == RIG_OK && powerstat == 0 && priv->poweron == 0 - && rig->state.auto_power_on) + && STATE(rig)->auto_power_on) { priv->has_ps = 1; rig_debug(RIG_DEBUG_TRACE, "%s: got PS0 so powerup\n", __func__); @@ -1074,7 +1074,7 @@ int kenwood_open(RIG *rig) __func__, kenwood_id_string_list[i].id); // current vfo is rx_vfo - rig_get_vfo(rig, &rig->state.rx_vfo); + rig_get_vfo(rig, &STATE(rig)->rx_vfo); if (kenwood_id_string_list[i].model == rig->caps->rig_model) { @@ -1138,7 +1138,7 @@ int kenwood_open(RIG *rig) int kenwood_close(RIG *rig) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; @@ -1151,7 +1151,7 @@ int kenwood_close(RIG *rig) it's not supported */ } - if (rig->state.auto_power_off) + if (STATE(rig)->auto_power_off) { rig_debug(RIG_DEBUG_TRACE, "%s: got PS1 so powerdown\n", __func__); rig_set_powerstat(rig, 0); @@ -1186,7 +1186,7 @@ int kenwood_get_id(RIG *rig, char *buf) */ int kenwood_get_if(RIG *rig) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); int retval; int post_write_delay_save = 0; @@ -1196,8 +1196,8 @@ int kenwood_get_if(RIG *rig) // Malachite has a 400ms delay but some get commands can work with no delay if (RIG_IS_MALACHITE) { - post_write_delay_save = rig->state.post_write_delay; - rig->state.post_write_delay = 0; + post_write_delay_save = STATE(rig)->post_write_delay; + STATE(rig)->post_write_delay = 0; } retval = kenwood_safe_transaction(rig, "IF", priv->info, @@ -1205,7 +1205,7 @@ int kenwood_get_if(RIG *rig) if (RIG_IS_MALACHITE) { - rig->state.post_write_delay = post_write_delay_save; + STATE(rig)->post_write_delay = post_write_delay_save; } RETURNFUNC(retval); @@ -1222,7 +1222,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) char cmdbuf[12]; int retval; char vfo_function; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; rig_debug(RIG_DEBUG_VERBOSE, @@ -1243,7 +1243,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) #if 0 - if (rig->state.current_vfo == vfo) + if (STATE(rig)->current_vfo == vfo) { rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo already is %s...skipping\n", __func__, rig_strvfo(vfo)); @@ -1267,19 +1267,19 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) break; case RIG_VFO_TX: - vfo_function = rig->state.tx_vfo == RIG_VFO_B ? '1' : '0'; + vfo_function = STATE(rig)->tx_vfo == RIG_VFO_B ? '1' : '0'; break; #if 0 // VFO_RX really should NOT be VFO_CURR as VFO_CURR could be either VFO case RIG_VFO_RX: - vfo_function = rig->state.rx_vfo == RIG_VFO_B ? '1' : '0'; + vfo_function = STATE(rig)->rx_vfo == RIG_VFO_B ? '1' : '0'; break; #endif case RIG_VFO_CURR: HAMLIB_TRACE; - rig->state.current_vfo = RIG_VFO_CURR; + STATE(rig)->current_vfo = RIG_VFO_CURR; RETURNFUNC2(RIG_OK); default: @@ -1344,7 +1344,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) } HAMLIB_TRACE; - rig->state.current_vfo = vfo; + STATE(rig)->current_vfo = vfo; /* if FN command then there's no FT or FR */ /* If split mode on, the don't change TxVFO */ @@ -1473,7 +1473,7 @@ int kenwood_get_vfo_main_sub(RIG *rig, vfo_t *vfo) */ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; char cmdbuf[12]; int retval; unsigned char vfo_function; @@ -1496,7 +1496,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) RETURNFUNC2(kenwood_transaction(rig, cmdbuf, NULL, 0)); } - if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; } + if (vfo == RIG_VFO_CURR) { vfo = STATE(rig)->current_vfo; } if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, split); } @@ -1640,7 +1640,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) */ int kenwood_set_split(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; char cmdbuf[6]; int retval; @@ -1674,7 +1674,8 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, { int transmitting; int retval; - struct kenwood_priv_data *priv = rig->state.priv; + struct rig_state *rs = STATE(rig); + struct kenwood_priv_data *priv = rs->priv; ENTERFUNC; @@ -1694,13 +1695,13 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, { *split = RIG_SPLIT_ON; *txvfo = RIG_VFO_SUB; - priv->tx_vfo = rig->state.tx_vfo = *txvfo; + priv->tx_vfo = rs->tx_vfo = *txvfo; } else { *split = RIG_SPLIT_OFF; *txvfo = RIG_VFO_MAIN; - priv->tx_vfo = rig->state.tx_vfo = *txvfo; + priv->tx_vfo = rs->tx_vfo = *txvfo; } } @@ -1740,35 +1741,35 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, switch (priv->info[30]) { case '0': - if (rig->state.rx_vfo == RIG_VFO_A) + if (rs->rx_vfo == RIG_VFO_A) { HAMLIB_TRACE; - *txvfo = rig->state.tx_vfo = priv->tx_vfo = (*split + *txvfo = rs->tx_vfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; } - else if (rig->state.rx_vfo == RIG_VFO_B) + else if (rs->rx_vfo == RIG_VFO_B) { HAMLIB_TRACE; - *txvfo = rig->state.tx_vfo = priv->tx_vfo = (*split + *txvfo = rs->tx_vfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; } else { rig_debug(RIG_DEBUG_WARN, "%s(%d): unknown rx_vfo=%s\n", __func__, __LINE__, - rig_strvfo(rig->state.rx_vfo)); + rig_strvfo(rs->rx_vfo)); *txvfo = RIG_VFO_A; // pick a default - rig->state.rx_vfo = priv->tx_vfo = RIG_VFO_A; + rs->rx_vfo = priv->tx_vfo = RIG_VFO_A; } break; case '1': - if (rig->state.rx_vfo == RIG_VFO_A) + if (rs->rx_vfo == RIG_VFO_A) { HAMLIB_TRACE; *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_A : RIG_VFO_B; } - else if (rig->state.rx_vfo == RIG_VFO_B) + else if (rs->rx_vfo == RIG_VFO_B) { HAMLIB_TRACE; *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; @@ -1776,9 +1777,9 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, else { rig_debug(RIG_DEBUG_WARN, "%s(%d): unknown rx_vfo=%s\n", __func__, __LINE__, - rig_strvfo(rig->state.rx_vfo)); + rig_strvfo(rs->rx_vfo)); *txvfo = RIG_VFO_A; // pick a default - rig->state.rx_vfo = RIG_VFO_A; + rs->rx_vfo = RIG_VFO_A; } break; @@ -1812,7 +1813,8 @@ int kenwood_get_vfo_if(RIG *rig, vfo_t *vfo) { int retval; int split_and_transmitting; - struct kenwood_priv_data *priv = rig->state.priv; + struct rig_state *rs = STATE(rig); + struct kenwood_priv_data *priv = rs->priv; ENTERFUNC; @@ -1838,10 +1840,10 @@ int kenwood_get_vfo_if(RIG *rig, vfo_t *vfo) switch (priv->info[30]) { case '0': - *vfo = rig->state.rx_vfo = rig->state.tx_vfo = priv->tx_vfo = + *vfo = rs->rx_vfo = rs->tx_vfo = priv->tx_vfo = split_and_transmitting ? RIG_VFO_B : RIG_VFO_A; - if (priv->info[32] == '1') { priv->tx_vfo = rig->state.tx_vfo = RIG_VFO_B; } + if (priv->info[32] == '1') { priv->tx_vfo = rs->tx_vfo = RIG_VFO_B; } break; @@ -1876,13 +1878,13 @@ int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq) vfo_t tvfo; freq_t tfreq = 0; int err; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s freq=%.0f\n", __func__, rig_strvfo(vfo), freq); tvfo = (vfo == RIG_VFO_CURR - || vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + || vfo == RIG_VFO_VFO) ? STATE(rig)->current_vfo : vfo; rig_debug(RIG_DEBUG_TRACE, "%s: tvfo=%s\n", __func__, rig_strvfo(tvfo)); @@ -1897,7 +1899,7 @@ int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq) // Malchite is so slow we don't do the get_freq // And when we have detected Doppler operations we just set the freq all the time // This should provide stable timing for set_ptt operation so relay delays are consistent - if (!RIG_IS_MALACHITE && rig->state.doppler == 0) + if (!RIG_IS_MALACHITE && STATE(rig)->doppler == 0) { rig_get_freq(rig, tvfo, &tfreq); @@ -1995,7 +1997,7 @@ int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq) int kenwood_get_freq_if(RIG *rig, vfo_t vfo, freq_t *freq) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; char freqbuf[50]; int retval; @@ -2030,7 +2032,7 @@ int kenwood_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int retval; unsigned char vfo_letter = '\0'; vfo_t tvfo; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; @@ -2040,7 +2042,7 @@ int kenwood_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } tvfo = (vfo == RIG_VFO_CURR - || vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + || vfo == RIG_VFO_VFO) ? STATE(rig)->current_vfo : vfo; if (RIG_VFO_CURR == tvfo) { @@ -2109,7 +2111,7 @@ int kenwood_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) { int retval; char buf[7]; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; @@ -2145,7 +2147,7 @@ int kenwood_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) int rit_enabled; int xit_enabled; shortfreq_t curr_rit; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called: vfo=%s, rit=%ld\n", __func__, @@ -2354,13 +2356,13 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int err; int datamode = 0; int needdata; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s called, vfo=%s, mode=%s, width=%d, curr_vfo=%s\n", __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width, - rig_strvfo(rig->state.current_vfo)); + rig_strvfo(STATE(rig)->current_vfo)); // we wont' set opposite VFO if the mode is the same as requested // setting VFOB mode requires split modifications which cause VFO flashing @@ -2515,7 +2517,7 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (vfo == RIG_VFO_CURR) { HAMLIB_TRACE; - vfo = rig->state.current_vfo; + vfo = STATE(rig)->current_vfo; } if ((vfo & (RIG_VFO_A | RIG_VFO_MAIN)) && ((priv->datamodeA == 0 && datamode) @@ -2689,11 +2691,11 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int retval; int kmode; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s called, curr_vfo=%s\n", __func__, - rig_strvfo(rig->state.current_vfo)); + rig_strvfo(STATE(rig)->current_vfo)); if (!mode || !width) { @@ -2705,7 +2707,7 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) /* only need to get it if it has to be initialized */ if (priv->curr_mode > 0 && priv->is_emulation && vfo == RIG_VFO_B) { - rig->state.current_vfo = RIG_VFO_A; + STATE(rig)->current_vfo = RIG_VFO_A; RETURNFUNC2(RIG_OK); } @@ -2844,7 +2846,7 @@ int kenwood_get_mode_if(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { int err; struct kenwood_priv_caps *caps = kenwood_caps(rig); - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; @@ -2956,7 +2958,7 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min, // we batch these commands together for speed char *cmd; int n; - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); struct hamlib_port *rp = RIGPORT(rig); ENTERFUNC; @@ -3184,7 +3186,8 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { char levelbuf[16]; int i, kenwood_val, len, result; - struct kenwood_priv_data *priv = rig->state.priv; + struct rig_state *rs = STATE(rig); + struct kenwood_priv_data *priv = rs->priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); gran_t *level_info; @@ -3331,9 +3334,9 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { int foundit = 0; - for (i = 0; i < HAMLIB_MAXDBLSTSIZ && rig->state.attenuator[i]; i++) + for (i = 0; i < HAMLIB_MAXDBLSTSIZ && rs->attenuator[i]; i++) { - if (val.i == rig->state.attenuator[i]) + if (val.i == rs->attenuator[i]) { SNPRINTF(levelbuf, sizeof(levelbuf), "RA%0*d", len, i + 1); foundit = 1; @@ -3360,9 +3363,9 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { int foundit = 0; - for (i = 0; i < HAMLIB_MAXDBLSTSIZ && rig->state.preamp[i]; i++) + for (i = 0; i < HAMLIB_MAXDBLSTSIZ && rs->preamp[i]; i++) { - if (val.i == rig->state.preamp[i]) + if (val.i == rs->preamp[i]) { SNPRINTF(levelbuf, sizeof(levelbuf), "PA%01d", i + 1); foundit = 1; @@ -3565,7 +3568,8 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int retval; int lvl; int i, ret, agclevel, len, value; - struct kenwood_priv_data *priv = rig->state.priv; + struct rig_state *rs = STATE(rig); + struct kenwood_priv_data *priv = rs->priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); gran_t *level_info; @@ -3728,7 +3732,7 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { for (i = 0; i < lvl && i < HAMLIB_MAXDBLSTSIZ; i++) { - if (rig->state.attenuator[i] == 0) + if (rs->attenuator[i] == 0) { rig_debug(RIG_DEBUG_ERR, "%s: " "unexpected att level %d\n", @@ -3742,7 +3746,7 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) RETURNFUNC(-RIG_EINTERNAL); } - val->i = rig->state.attenuator[i - 1]; + val->i = rs->attenuator[i - 1]; } break; @@ -3765,7 +3769,7 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) for (i = 0; i < lvl && i < HAMLIB_MAXDBLSTSIZ; i++) { - if (rig->state.preamp[i] == 0) + if (rs->preamp[i] == 0) { rig_debug(RIG_DEBUG_ERR, "%s: " "unexpected preamp level %d\n", @@ -3779,7 +3783,7 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) RETURNFUNC(-RIG_EINTERNAL); } - val->i = rig->state.preamp[i - 1]; + val->i = rs->preamp[i - 1]; } else { @@ -4500,11 +4504,11 @@ int kenwood_set_ctcss_tone_tn(RIG *rig, vfo_t vfo, tone_t tone) /* * kenwood_get_ctcss_tone - * Assumes rig->state.priv != NULL + * Assumes STATE(rig)->priv != NULL */ int kenwood_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; struct rig_caps *caps; char tonebuf[3]; int i, retval; @@ -4891,7 +4895,7 @@ int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, */ int kenwood_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; int retval; ENTERFUNC; @@ -5128,7 +5132,7 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status) { int retval; struct hamlib_port *rp = RIGPORT(rig); - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; if ((priv->is_k3 || priv->is_k3s) && status == RIG_POWER_ON) { @@ -5195,7 +5199,7 @@ int kenwood_get_powerstat(RIG *rig, powerstat_t *status) char pwrbuf[6]; int result; struct hamlib_port *rp = RIGPORT(rig); - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; @@ -5433,7 +5437,7 @@ int kenwood_stop_morse(RIG *rig, vfo_t vfo) int kenwood_send_voice_mem(RIG *rig, vfo_t vfo, int bank) { char cmd[16]; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; #if 0 // don't really need to turn on the list @@ -5477,7 +5481,7 @@ int kenwood_send_voice_mem(RIG *rig, vfo_t vfo, int bank) int kenwood_stop_voice_mem(RIG *rig, vfo_t vfo) { char cmd[16]; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; if (rig->caps->rig_model == RIG_MODEL_TS2000 @@ -5648,7 +5652,7 @@ int kenwood_get_mem_if(RIG *rig, vfo_t vfo, int *ch) { int err; char buf[4]; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; @@ -5887,7 +5891,7 @@ int kenwood_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan) int kenwood_set_ext_parm(RIG *rig, hamlib_token_t token, value_t val) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; char buf[4]; ENTERFUNC; @@ -5920,7 +5924,7 @@ int kenwood_set_ext_parm(RIG *rig, hamlib_token_t token, value_t val) int kenwood_get_ext_parm(RIG *rig, hamlib_token_t token, value_t *val) { int err; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index eb6aee8e0..b512a3308 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -334,7 +334,7 @@ extern struct rig_caps trudx_caps; static int inline kenwood_simple_transaction(RIG *rig, const char *cmd, size_t expected) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; return kenwood_safe_transaction(rig, cmd, priv->info, KENWOOD_MAX_BUF_LEN, expected); } diff --git a/rigs/kenwood/ts450s.c b/rigs/kenwood/ts450s.c index e5e393512..51aba0836 100644 --- a/rigs/kenwood/ts450s.c +++ b/rigs/kenwood/ts450s.c @@ -94,8 +94,8 @@ int ts450_open(RIG *rig) if (err != RIG_OK) { rig_debug(RIG_DEBUG_VERBOSE, "%s: tone unit not detected\n", __func__); - rig->state.has_set_func &= ~RIG_FUNC_TONE; - rig->state.has_get_func &= ~RIG_FUNC_TONE; + STATE(rig)->has_set_func &= ~RIG_FUNC_TONE; + STATE(rig)->has_get_func &= ~RIG_FUNC_TONE; } RIGPORT(rig)->retry = maxtries; diff --git a/rigs/kenwood/ts480.c b/rigs/kenwood/ts480.c index f9034ad7b..eb194d1ac 100644 --- a/rigs/kenwood/ts480.c +++ b/rigs/kenwood/ts480.c @@ -823,7 +823,7 @@ static int ts480_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) { int retval; char buf[7]; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; @@ -1207,7 +1207,7 @@ int ts480_init(RIG *rig) return retval; } - priv = (struct kenwood_priv_data *) rig->state.priv; + priv = (struct kenwood_priv_data *) STATE(rig)->priv; priv->ag_format = 2; priv->micgain_min = 0; @@ -2167,7 +2167,7 @@ int malachite_init(RIG *rig) retval = kenwood_init(rig); - priv = rig->state.priv; + priv = STATE(rig)->priv; priv->no_id = 1; // the Malchite doesn't like the ID; verify cmd @@ -2178,20 +2178,20 @@ int malachite_init(RIG *rig) int malachite_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { - int post_write_delay_save = rig->state.post_write_delay; - rig->state.post_write_delay = 0; + int post_write_delay_save = STATE(rig)->post_write_delay; + STATE(rig)->post_write_delay = 0; int retval = kenwood_get_mode(rig, vfo, mode, width); - rig->state.post_write_delay = post_write_delay_save; + STATE(rig)->post_write_delay = post_write_delay_save; return retval; } int malachite_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { - int post_write_delay_save = rig->state.post_write_delay; + int post_write_delay_save = STATE(rig)->post_write_delay; ENTERFUNC; - rig->state.post_write_delay = 0; + STATE(rig)->post_write_delay = 0; int retval = kenwood_get_freq(rig, vfo, freq); - rig->state.post_write_delay = post_write_delay_save; + STATE(rig)->post_write_delay = post_write_delay_save; RETURNFUNC(retval); } @@ -2212,13 +2212,13 @@ int malachite_set_freq(RIG *rig, vfo_t vfo, freq_t freq) // Malachite has a bug where it takes two freq set to make it work // under band changes -- so we just do this all the time retval = kenwood_set_freq(rig, vfo, freq + 1); - rig->state.post_write_delay = 250; // need a bit more time on band change + STATE(rig)->post_write_delay = 250; // need a bit more time on band change if (retval != RIG_OK) { RETURNFUNC(retval); } } else { - rig->state.post_write_delay = 125; + STATE(rig)->post_write_delay = 125; } retval = kenwood_set_freq(rig, vfo, freq); diff --git a/rigs/kenwood/ts570.c b/rigs/kenwood/ts570.c index dc676250d..fd1f57519 100644 --- a/rigs/kenwood/ts570.c +++ b/rigs/kenwood/ts570.c @@ -351,7 +351,7 @@ ts570_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int i; for (i = 0; i < HAMLIB_MAXDBLSTSIZ; i++) - if (kenwood_val == rig->state.preamp[i]) + if (kenwood_val == STATE(rig)->preamp[i]) { SNPRINTF(levelbuf, sizeof(levelbuf), "PA%01d", i + 1); break; /* found - stop searching */ @@ -475,7 +475,7 @@ ts570_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) for (i = 0; i < levelint && i < HAMLIB_MAXDBLSTSIZ; i++) { - if (rig->state.preamp[i] == 0) + if (STATE(rig)->preamp[i] == 0) { rig_debug(RIG_DEBUG_ERR, "%s: unexpected att level %d\n", __func__, (int)levelint); @@ -488,7 +488,7 @@ ts570_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return -RIG_EINTERNAL; } - val->i = rig->state.preamp[i - 1]; + val->i = STATE(rig)->preamp[i - 1]; } break; diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c index 84903494c..f38b46418 100644 --- a/rigs/kenwood/ts590.c +++ b/rigs/kenwood/ts590.c @@ -326,7 +326,7 @@ static int ts590_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) char cmd[32], ackbuf[32]; int retval; - if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; } + if (vfo == RIG_VFO_CURR) { vfo = STATE(rig)->current_vfo; } if (vfo == RIG_VFO_TX || vfo == RIG_VFO_RX) { vfo = vfo_fixup(rig, vfo, CACHE(rig)->split); } @@ -541,7 +541,7 @@ static int ts590_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) static int ts590_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; char levelbuf[16]; int kenwood_val; int result; @@ -731,7 +731,7 @@ static int ts590_read_meters(RIG *rig, int *swr, int *comp, int *alc) static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; char ackbuf[50]; size_t ack_len, ack_len_expected; int levelint = 0; @@ -1148,7 +1148,7 @@ static int ts590_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit) { int retval; char buf[7]; - struct kenwood_priv_data *priv = rig->state.priv; + struct kenwood_priv_data *priv = STATE(rig)->priv; ENTERFUNC; diff --git a/rigs/kenwood/tx500.c b/rigs/kenwood/tx500.c index f8b8184f0..43d422b32 100644 --- a/rigs/kenwood/tx500.c +++ b/rigs/kenwood/tx500.c @@ -854,7 +854,7 @@ int ts2000_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) if (lvl > 9) { - val->i = rig->state.preamp[0]; + val->i = STATE(rig)->preamp[0]; } break; @@ -885,7 +885,7 @@ int ts2000_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) if (lvl > 99) { - val->i = rig->state.attenuator[0]; /* Since the TS-2000 only has one step on the attenuator */ + val->i = STATE(rig)->attenuator[0]; /* Since the TS-2000 only has one step on the attenuator */ } break; diff --git a/rigs/kenwood/xg3.c b/rigs/kenwood/xg3.c index e8c8526fc..271bebca2 100644 --- a/rigs/kenwood/xg3.c +++ b/rigs/kenwood/xg3.c @@ -197,12 +197,12 @@ int xg3_init(RIG *rig) return -RIG_ENOMEM; } - rig->state.priv = (void *)priv; + STATE(rig)->priv = (void *)priv; RIGPORT(rig)->type.rig = RIG_PORT_SERIAL; // Tried set_trn to turn transceiver on/off but turning it on isn't enabled in hamlib for some reason // So we use PTT instead -// rig->state.transceive = RIG_TRN_RIG; // this allows xg3_set_trn to be called - rig->state.current_vfo = RIG_VFO_A; +// STATE(rig)->transceive = RIG_TRN_RIG; // this allows xg3_set_trn to be called + STATE(rig)->current_vfo = RIG_VFO_A; // priv->last_vfo = RIG_VFO_A; // priv->ptt = RIG_PTT_ON; // priv->powerstat = RIG_POWER_ON; @@ -352,7 +352,7 @@ int xg3_get_vfo(RIG *rig, vfo_t *vfo) return -RIG_EINVAL; } - *vfo = rig->state.current_vfo; // VFOA or MEM + *vfo = STATE(rig)->current_vfo; // VFOA or MEM return RIG_OK; } @@ -372,7 +372,7 @@ int xg3_set_vfo(RIG *rig, vfo_t vfo) // We don't actually set the vfo on the XG3 // But we need this so we can set frequencies on the band buttons - rig->state.current_vfo = vfo; + STATE(rig)->current_vfo = vfo; return RIG_OK; } @@ -388,7 +388,7 @@ int xg3_set_freq(RIG *rig, vfo_t vfo, freq_t freq) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); tvfo = (vfo == RIG_VFO_CURR || - vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + vfo == RIG_VFO_VFO) ? STATE(rig)->current_vfo : vfo; switch (tvfo) { @@ -440,7 +440,7 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } tvfo = (vfo == RIG_VFO_CURR || - vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo; + vfo == RIG_VFO_VFO) ? STATE(rig)->current_vfo : vfo; rp = RIGPORT(rig); switch (tvfo) commit 4b436479d1667f1ee3f9f50db07a2a3fc9bdb7e4 Author: George Baltz N3GB <Geo...@gm...> Date: Sat Mar 16 11:25:46 2024 -0400 More pointers to state diff --git a/rigs/kenwood/elecraft.c b/rigs/kenwood/elecraft.c index 05b32835f..dc2e8c6cb 100644 --- a/rigs/kenwood/elecraft.c +++ b/rigs/kenwood/elecraft.c @@ -96,10 +96,10 @@ int elecraft_open(RIG *rig) { int err; char buf[KENWOOD_MAX_BUF_LEN]; - struct kenwood_priv_data *priv = rig->state.priv; char *model = "Unknown"; - struct rig_state *rs = &rig->state; + struct rig_state *rs = STATE(rig); struct hamlib_port *rp = RIGPORT(rig); + struct kenwood_priv_data *priv = rs->priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called, rig version=%s\n", __func__, rig->caps->version); @@ -395,7 +395,7 @@ int elecraft_open(RIG *rig) int elecraft_close(RIG *rig) { - const struct kenwood_priv_data *priv = rig->state.priv; + const struct kenwood_priv_data *priv = STATE(rig)->priv; if (priv->save_k2_ext_lvl >= 0) { @@ -622,12 +622,12 @@ int elecraft_get_vfo_tq(RIG *rig, vfo_t *vfo) rig_debug(RIG_DEBUG_ERR, "%s: unable to parse TQ '%s'\n", __func__, splitbuf); } - *vfo = rig->state.tx_vfo = RIG_VFO_A; + *vfo = STATE(rig)->tx_vfo = RIG_VFO_A; - if (tq && ft == 1) { *vfo = rig->state.tx_vfo = RIG_VFO_B; } - else if (tq && ft =... [truncated message content] |