[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 745e72a6cf7023cfd26c2
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2024-05-31 13:39:39
|
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 745e72a6cf7023cfd26c282207803e4c62897668 (commit) via 88439f8f12c3011751e995e01b2b09a4fa77dd66 (commit) via befb2ffcdf0965709055262fb5dad3e00d647d5c (commit) via 218385a76c0a82ef040be0a1eb5502b25c5664ed (commit) via 1e3be1a88fd96e59a9715b5f04079c782eccd05d (commit) via 3583b077e823f0b9474353f36fee4781c1bb4940 (commit) via be0f7407f2857ccc55ec1f18550b16644421dfb0 (commit) via a300a73f1d584c28c0e17414445be00c716740f3 (commit) via 86dc5c8d6fab469ab6191502ad4f4cd7bb0b7326 (commit) via c730e445a14b8faf1c6112cc8fb1c2217e6c1374 (commit) via 04c3c03334dd250cccee9b99c808e7b9dfdf5dcb (commit) via 2de9778f27a7d614cfe33d8af6f6ff2d1b78e444 (commit) via a721c04c536c0f7301608f49dcccbb1c03152f58 (commit) via f53dc99057869642b896c4743a99335900cfb39b (commit) via a5f53bbcf68ba5fea29a40efbda357f109897663 (commit) via 18568986f85688a6a2d6ae89c950af94dea6be2f (commit) from 461f3c4172ded779cf258cd5ea4d1c0179c4586f (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 745e72a6cf7023cfd26c282207803e4c62897668 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu May 30 17:34:02 2024 -0500 Add ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW Supported by SPID rotators diff --git a/doc/man1/rotctl.1 b/doc/man1/rotctl.1 index f947223a2..93c925883 100644 --- a/doc/man1/rotctl.1 +++ b/doc/man1/rotctl.1 @@ -410,8 +410,9 @@ are returned as double precision floating point values. Move the rotator in a specific direction at the given rate. .IP .RI \(aq Direction \(aq -is an integer or keyword defined as \(oq2\(cq = UP, \(oq4\(cq = DOWN, \(oq8\(cq = LEFT or CCW -and \(oq16\(cq = RIGHT or CW +is an integer or keyword defined as \(oq2\(cq = UP, \(oq4\(cq = DOWN, \(oq8\(cq = LEFT or CCW, +\(oq16\(cq = RIGHT or CW, \(oq32\(cq = UP_LEFT or UP_CCW, \(oqR64\(cq = UP_RIGHT = UP_CW, +\(oq128\(cq = DOWN_LEFT or DOWN_CCW, \(oq256\(cq = DOWN_RIGHT or DOWN_CW .IP .RI \(aq Speed \(aq is an integer between 1 and 100. Use -1 for no change to current speed. diff --git a/doc/man1/rotctld.1 b/doc/man1/rotctld.1 index 852831c1e..f65bbcf3d 100644 --- a/doc/man1/rotctld.1 +++ b/doc/man1/rotctld.1 @@ -322,8 +322,9 @@ are returned as double precision floating point values. Move the rotator in a specific direction at the given rate. .IP .RI \(aq Direction \(aq -is an integer defined as \(oq2\(cq = Up, \(oq4\(cq = Down, \(oq8\(cq = Left, -and \(oq16\(cq = Right. +is an integer or keyword defined as \(oq2\(cq = UP, \(oq4\(cq = DOWN, \(oq8\(cq = LEFT or CCW, +\(oq16\(cq = RIGHT or CW, \(oq32\(cq = UP_LEFT or UP_CCW, \(oqR64\(cq = UP_RIGHT = UP_CW, +\(oq128\(cq = DOWN_LEFT or DOWN_CCW, \(oq256\(cq = DOWN_RIGHT or DOWN_CW .IP .RI \(aq Speed \(aq is an integer between 1 and 100. Use -1 for no change to current speed. diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 6427001c3..82bc634e2 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -215,6 +215,126 @@ typedef enum { */ #define ROT_MOVE_CW ROT_MOVE_RIGHT +/** + * \def ROT_MOVE_UP_LEFT + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_UP_CCW. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_CCW, + * ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW, ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW, + * ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW + */ +#define ROT_MOVE_UP_LEFT (1<<5) + +/** + * \def ROT_MOVE_UP_CCW + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_UP_LEFT. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_LEFT, + * ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW, ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW, + * ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW + */ +#define ROT_MOVE_UP_CCW ROT_MOVE_UP_LEFT + +/** + * \def ROT_MOVE_UP_RIGHT + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_UP_CW. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW, + * ROT_MOVE_UP_CW, ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW, + * ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW + */ +#define ROT_MOVE_UP_RIGHT (1<<6) + +/** + * \def ROT_MOVE_UP_CW + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_UP_RIGHT. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW, + * ROT_MOVE_UP_RIGHT, ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW, + * ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW + */ +#define ROT_MOVE_UP_CW ROT_MOVE_UP_RIGHT + +/** + * \def ROT_MOVE_DOWN_LEFT + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_DOWN_CCW. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW, + * ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW, ROT_MOVE_DOWN_CCW, + * ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW + */ +#define ROT_MOVE_DOWN_LEFT (1 << 7) + + +/** + * \def ROT_MOVE_DOWN_CCW + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_DOWN_LEFT. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW, + * ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW, ROT_MOVE_DOWN_LEFT, + * ROT_MOVE_DOWN_RIGHT, ROT_MOVE_DOWN_CW + */ +#define ROT_MOVE_DOWN_CCW ROT_MOVE_DOWN_LEFT + +/** + * \def ROT_MOVE_DOWN_RIGHT + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_DOWN_CW. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW, + * ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW, ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW, + * ROT_MOVE_DOWN_CW + */ +#define ROT_MOVE_DOWN_RIGHT (1 << 8) + +/** + * \def ROT_MOVE_DOWN_CW + * \brief A macro that returns the flag for the \b clockwise direction. + * + * This macro defines the value of the \b clockwise direction which can be + * used with the rot_move() function. This value is equivalent to + * ROT_MOVE_DOWN_RIGHT. + * + * \sa rot_move(), ROT_MOVE_UP, ROT_MOVE_DOWN, ROT_MOVE_LEFT, ROT_MOVE_CCW, + * ROT_MOVE_RIGHT, ROT_MOVE_CW, ROT_MOVE_UP_LEFT, ROT_MOVE_UP_CCW, + * ROT_MOVE_UP_RIGHT, ROT_MOVE_UP_CW, ROT_MOVE_DOWN_LEFT, ROT_MOVE_DOWN_CCW, + * ROT_MOVE_DOWN_RIGHT, + */ +#define ROT_MOVE_DOWN_CW ROT_MOVE_DOWN_RIGHT /** * \brief Rotator status flags diff --git a/rigs/dummy/rot_dummy.c b/rigs/dummy/rot_dummy.c index 1bf2b2d4e..dec0f8cfc 100644 --- a/rigs/dummy/rot_dummy.c +++ b/rigs/dummy/rot_dummy.c @@ -436,6 +436,22 @@ static int dummy_rot_move(ROT *rot, int direction, int speed) case ROT_MOVE_CW: return dummy_rot_set_position(rot, 180, priv->target_el); + case ROT_MOVE_UP_LEFT: + dummy_rot_set_position(rot, priv->target_az, 90); + return dummy_rot_set_position(rot, -180, priv->target_el); + + case ROT_MOVE_UP_RIGHT: + dummy_rot_set_position(rot, priv->target_az, 90); + return dummy_rot_set_position(rot, 180, priv->target_el); + + case ROT_MOVE_DOWN_LEFT: + dummy_rot_set_position(rot, priv->target_az, 0); + return dummy_rot_set_position(rot, -180, priv->target_el); + + case ROT_MOVE_DOWN_RIGHT: + dummy_rot_set_position(rot, priv->target_az, 0); + return dummy_rot_set_position(rot, 180, priv->target_el); + default: return -RIG_EINVAL; } diff --git a/rigs/flexradio/README b/rigs/flexradio/README new file mode 100644 index 000000000..4e9fcf2a6 --- /dev/null +++ b/rigs/flexradio/README @@ -0,0 +1 @@ +See https://github.com/flexradio/smartsdr-api-docs/wiki/SmartSDR-TCPIP-API diff --git a/rotators/spid/spid.c b/rotators/spid/spid.c index e0dd0d712..c9ef0b3e7 100644 --- a/rotators/spid/spid.c +++ b/rotators/spid/spid.c @@ -37,6 +37,7 @@ struct spid_rot2prog_priv_data { int az_resolution; int el_resolution; + int dir; // current direction }; enum spid_rot2prog_framemagic @@ -213,6 +214,7 @@ static int spid_rot_init(ROT *rot) priv->az_resolution = 0; priv->el_resolution = 0; + priv->dir = 0; } return RIG_OK; @@ -238,9 +240,10 @@ static int spid_rot_cleanup(ROT *rot) return RIG_OK; } -static int spid_get_conf2(ROT *rot, hamlib_token_t token, char *val, int val_len) +static int spid_get_conf2(ROT *rot, hamlib_token_t token, char *val, + int val_len) { - const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) + const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) rot->state.priv; rig_debug(RIG_DEBUG_TRACE, "%s called %d\n", __func__, (int)token); @@ -343,7 +346,7 @@ static int spid_rot2prog_rot_set_position(ROT *rot, azimuth_t az, { struct rot_state *rs = &rot->state; hamlib_port_t *rotp = ROTPORT(rot); - const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) + const struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) rs->priv; int retval; int retry_read = 0; @@ -494,6 +497,8 @@ static int spid_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) static int spid_rot_stop(ROT *rot) { + struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) + rot->state.priv; hamlib_port_t *rotp = ROTPORT(rot); int retval; int retry_read = 0; @@ -530,36 +535,68 @@ static int spid_rot_stop(ROT *rot) return retval; } + priv->dir = 0; + return RIG_OK; } static int spid_md01_rot2prog_rot_move(ROT *rot, int direction, int speed) { + struct spid_rot2prog_priv_data *priv = (struct spid_rot2prog_priv_data *) + rot->state.priv; char dir = 0x00; int retval; char cmdstr[13]; rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); + dir = priv->dir; + switch (direction) { case ROT_MOVE_UP: - dir = 0x04; + if (dir != 0x01 || dir != 0x02) { dir = 0; } + + dir |= 0x04; break; case ROT_MOVE_DOWN: + if (dir != 0x01 || dir != 0x02) { dir = 0; } + dir = 0x08; break; case ROT_MOVE_LEFT: + if (dir != 0x04 || dir != 0x08) { dir = 0; } + dir = 0x01; break; case ROT_MOVE_RIGHT: + if (dir != 0x04 || dir != 0x08) { dir = 0; } + dir = 0x02; break; + + case ROT_MOVE_UP_RIGHT: + dir = 0x06; + break; + + case ROT_MOVE_DOWN_RIGHT: + dir = 0x0a; + break; + + case ROT_MOVE_UP_LEFT: + dir = 0x05; + break; + + case ROT_MOVE_DOWN_LEFT: + dir = 0x09; + break; } + priv->dir = dir; + cmdstr[0] = 0x57; /* S */ cmdstr[1] = dir; /* H1 */ cmdstr[2] = 0x00; /* H2 */ @@ -599,7 +636,7 @@ const struct rot_caps spid_rot1prog_rot_caps = ROT_MODEL(ROT_MODEL_SPID_ROT1PROG), .model_name = "Rot1Prog", .mfg_name = "SPID", - .version = "20220109.0", + .version = "20240530.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZIMUTH, diff --git a/src/rotator.c b/src/rotator.c index c601f402d..f82702e62 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -949,8 +949,9 @@ int HAMLIB_API rot_reset(ROT *rot, rot_reset_t reset) * * Move the rotator in the specified direction. The \a direction is one of * #ROT_MOVE_CCW, #ROT_MOVE_CW, #ROT_MOVE_LEFT, #ROT_MOVE_RIGHT, #ROT_MOVE_UP, - * or #ROT_MOVE_DOWN. The \a speed is a value between 1 and 100 or - * #ROT_SPEED_NOCHANGE. + * #ROT_MOVE_DOWN, #ROT_MOVE_UP_LEFT, #ROT_MOVE_CCW, #ROT_MOVE_UP_RIGHT, #ROT_MOVE_UP_CW, + * #ROT_MOVE_DOWN_LEFT, #ROT_MOVE_DOWN_CCW, #ROT_MOVE_DOWN_RIGHT, #ROT_MOVE_DOWN_CW. + * The \a speed is a value between 1 and 100 or #ROT_SPEED_NOCHANGE. * * \retval RIG_OK The rotator move was successful. * \retval RIG_EINVAL \a rot is NULL or inconsistent. diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index d266cf3c0..af07cc736 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -1897,6 +1897,22 @@ declare_proto_rot(move) { direction = ROT_MOVE_DOWN; } + else if (!strcmp(arg1, "DOWN_RIGHT") || !strcmp(arg1, "DOWN_CW")) + { + direction = ROT_MOVE_DOWN_CW; + } + else if (!strcmp(arg1, "DOWN_LEFT") || !strcmp(arg1, "DOWN_CCW")) + { + direction = ROT_MOVE_DOWN_CCW; + } + else if (!strcmp(arg1, "UP_RIGHT") || !strcmp(arg1, "UP_CW")) + { + direction = ROT_MOVE_UP_CW; + } + else if (!strcmp(arg1, "UP_LEFT") || !strcmp(arg1, "UP_CCW")) + { + direction = ROT_MOVE_UP_CCW; + } else { CHKSCN1ARG(sscanf(arg1, "%d", &direction)); commit 88439f8f12c3011751e995e01b2b09a4fa77dd66 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu May 30 17:22:00 2024 -0500 Update simflex.c diff --git a/simulators/simflex.c b/simulators/simflex.c index 3ee3113f2..d006348b1 100644 --- a/simulators/simflex.c +++ b/simulators/simflex.c @@ -93,6 +93,7 @@ int main() { printf("Server is listening on port %d\n", PORT); + while (1) { // Accept incoming connection if ((new_socket = accept(server_fd, (struct sockaddr *)&address, (socklen_t*)&addrlen)) < 0) { perror("accept"); @@ -154,6 +155,7 @@ int main() { } close(new_socket); + } close(server_fd); #if defined(WIN32) || defined(_WIN32) WSACleanup(); commit befb2ffcdf0965709055262fb5dad3e00d647d5c Author: Mike Black W9MDB <mdb...@ya...> Date: Thu May 30 10:03:01 2024 -0500 Add a bit more debug to rigctlcom.c diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index 2716b98fe..4bf136ec3 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -502,6 +502,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode)); exit(2); } + #endif if (my_model > 5 && !rig_file) @@ -654,6 +655,9 @@ int main(int argc, char *argv[]) } while (retcode == 0 && !ctrl_c); + rig_debug(RIG_DEBUG_VERBOSE, "%s: rigctlcom exiting, retcode=%d, ctrl_c=%d\n", + __func__, retcode, ctrl_c); + rig_close(my_rig); /* close port */ rig_cleanup(my_rig); /* if you care about memory */ @@ -705,6 +709,7 @@ static rmode_t ts2000_get_mode() default: mode = 0; break; } + #else // Perhaps we should emulate a rig that has PKT modes instead?? //int kwidth_ssb[] = { 10, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; @@ -717,7 +722,7 @@ static rmode_t ts2000_get_mode() case RIG_MODE_USB: mode = 2; break; - case RIG_MODE_CW: mode = 3; + case RIG_MODE_CW: mode = 3; break; // is this correct? case RIG_MODE_FM: mode = 4; break; @@ -742,6 +747,7 @@ static rmode_t ts2000_get_mode() default: mode = 0; break; } + #endif @@ -802,8 +808,9 @@ static int handle_ts2000(void *arg) int p13 = 0; // P13(1) Tone dummy value for now int p14 = 0; // P14(2) Tone Freq dummy value for now int p15 = 0; // P15(1) Shift status dummy value for now - int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), - &freq); + int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + CACHE(my_rig)->split), + &freq); char response[64]; char *fmt = // cppcheck-suppress * @@ -816,7 +823,7 @@ static int handle_ts2000(void *arg) mode = ts2000_get_mode(); retval = rig_get_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), - &ptt); + &ptt); if (retval != RIG_OK) { @@ -900,8 +907,9 @@ static int handle_ts2000(void *arg) freq_t freq = 0; char response[32]; - int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), - &freq); + int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + CACHE(my_rig)->split), + &freq); if (retval != RIG_OK) { @@ -917,8 +925,9 @@ static int handle_ts2000(void *arg) { char response[32]; freq_t freq = 0; - int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), - &freq); + int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + CACHE(my_rig)->split), + &freq); if (retval != RIG_OK) { @@ -972,7 +981,8 @@ static int handle_ts2000(void *arg) } else if (strcmp(arg, "TX;") == 0) { - return rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), 1); + return rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), + 1); } else if (strcmp(arg, "AI0;") == 0) { @@ -1089,8 +1099,9 @@ static int handle_ts2000(void *arg) { char response[32]; int valA; - int retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), - RIG_FUNC_AIP, &valA); + int retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + CACHE(my_rig)->split), + RIG_FUNC_AIP, &valA); int valB; if (retval != RIG_OK) @@ -1108,8 +1119,9 @@ static int handle_ts2000(void *arg) return retval; } - retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), - RIG_FUNC_AIP, &valB); + retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + CACHE(my_rig)->split), + RIG_FUNC_AIP, &valB); if (retval != RIG_OK) { @@ -1134,8 +1146,9 @@ static int handle_ts2000(void *arg) (char *)arg); } - retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), - RIG_FUNC_AIP, valA); + retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + CACHE(my_rig)->split), + RIG_FUNC_AIP, valA); if (retval != RIG_OK) { @@ -1144,8 +1157,9 @@ static int handle_ts2000(void *arg) return retval; } - retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), - RIG_FUNC_AIP, valB); + retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + CACHE(my_rig)->split), + RIG_FUNC_AIP, valB); if (retval != RIG_OK) { @@ -1560,13 +1574,15 @@ static int handle_ts2000(void *arg) } else if (strcmp(arg, "FT0;") == 0) { - return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), - vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), 0); + return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + CACHE(my_rig)->split), + vfo_fixup(my_rig, RIG_VFO_A, CACHE(my_rig)->split), 0); } else if (strcmp(arg, "FT1;") == 0) { - return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), - vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), 0); + return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + CACHE(my_rig)->split), + vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), 0); } else if (strncmp(arg, "FA0", 3) == 0) { @@ -1583,7 +1599,8 @@ static int handle_ts2000(void *arg) freq_t freq; sscanf((char *)arg + 2, "%"SCNfreq, &freq); - return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), freq); + return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, CACHE(my_rig)->split), + freq); } else if (strncmp(arg, "MD", 2) == 0) { commit 218385a76c0a82ef040be0a1eb5502b25c5664ed Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 29 17:50:10 2024 -0500 Fix ID for Xiegu X6100 diff --git a/rigs/icom/xiegu.c b/rigs/icom/xiegu.c index 46e0ad00e..d70de0f4a 100644 --- a/rigs/icom/xiegu.c +++ b/rigs/icom/xiegu.c @@ -148,10 +148,10 @@ int xiegu_rig_open(RIG *rig) if (retval == RIG_OK) { dump_hex(id,id_len); - iid = (int)id[2]; - if (id[3] != 0xfd) + iid = (int)id[1]; + if (id_len > 2) { - iid = (iid << 8) + id[3]; + iid = (iid << 8) + id[2]; } rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu Radio ID=0x%04x\n", __func__, iid); switch(iid) @@ -160,7 +160,7 @@ int xiegu_rig_open(RIG *rig) case 0x0090: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "G90S");break; case 0x0106: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "G106/G106C");break; case 0x6100: - case 0xa400: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "X6100");break; + case 0x00a4: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "X6100");break; default: rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu model %s\n", __func__, "Unknown");break; } } commit 1e3be1a88fd96e59a9715b5f04079c782eccd05d Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 29 17:06:36 2024 -0500 Fix Xiegu ID for G90 1-byte answer diff --git a/rigs/icom/xiegu.c b/rigs/icom/xiegu.c index fad83abdc..46e0ad00e 100644 --- a/rigs/icom/xiegu.c +++ b/rigs/icom/xiegu.c @@ -148,7 +148,11 @@ int xiegu_rig_open(RIG *rig) if (retval == RIG_OK) { dump_hex(id,id_len); - iid = (((int)id[2]) << 8) + id[3]; + iid = (int)id[2]; + if (id[3] != 0xfd) + { + iid = (iid << 8) + id[3]; + } rig_debug(RIG_DEBUG_VERBOSE, "%s: Xiegu Radio ID=0x%04x\n", __func__, iid); switch(iid) { @@ -374,7 +378,7 @@ struct rig_caps x6100_caps = RIG_MODEL(RIG_MODEL_X6100), .model_name = "X6100", .mfg_name = "Xiegu", - .version = BACKEND_VER ".5", + .version = BACKEND_VER ".6", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -565,7 +569,7 @@ struct rig_caps g90_caps = RIG_MODEL(RIG_MODEL_G90), .model_name = "G90", .mfg_name = "Xiegu", - .version = BACKEND_VER ".10", + .version = BACKEND_VER ".11", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -740,7 +744,7 @@ struct rig_caps x5105_caps = RIG_MODEL(RIG_MODEL_X5105), .model_name = "X5105", .mfg_name = "Xiegu", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".2", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, commit 3583b077e823f0b9474353f36fee4781c1bb4940 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 29 06:13:59 2024 -0500 Add network_flush2 to support async messages from Flex TCP This allow one to send a command to the Flex and process all the messages returned in the backend rather than thread. This then gives a synchronous behavior which clients expect diff --git a/src/network.c b/src/network.c index 1e76c0cd3..41461c20c 100644 --- a/src/network.c +++ b/src/network.c @@ -379,6 +379,31 @@ int network_open(hamlib_port_t *rp, int default_port) } +// flush and keep what gets flushed based on stopset +// Used by SmartSDR backend for example +// return # of bytes read +int network_flush2(hamlib_port_t *rp, unsigned char *stopset, char *buf, int buf_len) +{ + unsigned int len = 0; +#ifdef __MINGW32__ + int ret = ioctlsocket(rp->fd, FIONREAD, &len); +#else + int ret = ioctl(rp->fd, FIONREAD, &len); +#endif + if (ret != 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: ioctl err '%s'\n", __func__, strerror(errno)); + return 0; + } + + if (len > 0) { + buf[0] = 0; + if (len > buf_len) len = buf_len-1; + read_string(rp, (unsigned char *)buf, len+1, (char*)stopset, 1, 0, 1); + } + + return len; +} /** * \brief Clears any data in the read buffer of the socket * diff --git a/src/network.h b/src/network.h index 7dc9c517c..18ed720e7 100644 --- a/src/network.h +++ b/src/network.h @@ -31,6 +31,7 @@ __BEGIN_DECLS int network_open(hamlib_port_t *p, int default_port); int network_close(hamlib_port_t *rp); void network_flush(hamlib_port_t *rp); +int network_flush2(hamlib_port_t *rp, unsigned char *stopset, char *buf, int buf_len); int network_publish_rig_poll_data(RIG *rig); int network_publish_rig_transceive_data(RIG *rig); int network_publish_rig_spectrum_data(RIG *rig, struct rig_spectrum_line *line); commit be0f7407f2857ccc55ec1f18550b16644421dfb0 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 29 06:12:00 2024 -0500 Fix RFMETER_POWER_WATTS in dummy.c diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index 9f8da3406..882f30581 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -1258,6 +1258,7 @@ static int dummy_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; channel_t *curr = priv->curr; int idx; + static float rfpower = 0; ENTERFUNC; idx = rig_setting2idx(level); @@ -1311,6 +1312,7 @@ static int dummy_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { curr->levels[idx].f = (float)(time(NULL) % 32) / 64.0f + (float)( rand() % 4) / 8.0f; + rfpower = curr->levels[idx].f; } break; @@ -1322,9 +1324,11 @@ static int dummy_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } else { +#if 0 curr->levels[idx].f = (float)(time(NULL) % 32) / 64.0f + (float)( rand() % 4) / 8.0f; - curr->levels[idx].f *= 100.0f; +#endif + curr->levels[idx].f = 100.0f * rfpower; } break; @@ -2377,7 +2381,7 @@ struct rig_caps dummy_caps = RIG_MODEL(RIG_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20230611.0", + .version = "20240529.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, commit a300a73f1d584c28c0e17414445be00c716740f3 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue May 28 22:41:10 2024 -0500 Fix RIG_ELIMIT error diff --git a/src/rotator.c b/src/rotator.c index 51765ea5c..c601f402d 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -748,7 +748,7 @@ int HAMLIB_API rot_set_position(ROT *rot, rot_debug(RIG_DEBUG_TRACE, "%s: range problem az=%.02f(min=%.02f,max=%.02f), el=%02f(min=%.02f,max=%02f)\n", __func__, azimuth, rs->min_az, rs->max_az, elevation, rs->min_el, rs->max_el); - return -RIG_LIMIT; + return -RIG_ELIMIT; } if (caps->set_position == NULL) commit 86dc5c8d6fab469ab6191502ad4f4cd7bb0b7326 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue May 28 22:36:39 2024 -0500 Add new error message for ELIMIT diff --git a/src/rig.c b/src/rig.c index f42aace5a..22d2363bc 100644 --- a/src/rig.c +++ b/src/rig.c @@ -242,7 +242,8 @@ static const char *const rigerror_table[] = "Argument out of domain of func", "Function deprecated", "Security error password not provided or crypto failure", - "Rig is not powered on" + "Rig is not powered on", + "Limit exceeded" }; commit c730e445a14b8faf1c6112cc8fb1c2217e6c1374 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue May 28 22:35:46 2024 -0500 Add new error ELIMIT for things like rot_move that exceed set limits diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 9f52d271d..6e8419cd6 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -205,6 +205,7 @@ enum rig_errcode_e { RIG_EDEPRECATED,/*!< 18 Function deprecated */ RIG_ESECURITY, /*!< 19 Security error */ RIG_EPOWER, /*!< 20 Rig not powered on */ + RIG_ELIMIT, /*!< 21 Limit exceeded */ RIG_EEND // MUST BE LAST ITEM IN LAST }; /** diff --git a/src/rotator.c b/src/rotator.c index 5dd492b18..51765ea5c 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -748,7 +748,7 @@ int HAMLIB_API rot_set_position(ROT *rot, rot_debug(RIG_DEBUG_TRACE, "%s: range problem az=%.02f(min=%.02f,max=%.02f), el=%02f(min=%.02f,max=%02f)\n", __func__, azimuth, rs->min_az, rs->max_az, elevation, rs->min_el, rs->max_el); - return -RIG_EINVAL; + return -RIG_LIMIT; } if (caps->set_position == NULL) commit 04c3c03334dd250cccee9b99c808e7b9dfdf5dcb Author: Mike Black W9MDB <mdb...@ya...> Date: Mon May 27 23:06:37 2024 -0500 Add simft710.c diff --git a/simulators/Makefile.am b/simulators/Makefile.am index c08b82e17..05432a4d2 100644 --- a/simulators/Makefile.am +++ b/simulators/Makefile.am @@ -8,7 +8,7 @@ DISTCLEANFILES = bin_PROGRAMS = -check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710 simts890 simxiegux108g simxiegux6100 simic910 simft450 simelecraftk4 simmicom simflex +check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simtrusdx simft1000 simtmd710 simts890 simxiegux108g simxiegux6100 simic910 simft450 simelecraftk4 simmicom simflex simft710 simelecraft_SOURCES = simelecraft.c simkenwood_SOURCES = simkenwood.c diff --git a/simulators/simft710.c b/simulators/simft710.c new file mode 100644 index 000000000..e136e8eab --- /dev/null +++ b/simulators/simft710.c @@ -0,0 +1,624 @@ +// can run this using rigctl/rigctld and socat pty devices +// gcc -o simyaesu simyaesu.c +#define _XOPEN_SOURCE 700 +// since we are POSIX here we need this +#if 0 +struct ip_mreq +{ + int dummy; +}; +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include "../include/hamlib/rig.h" + +#define BUFSIZE 256 + +float freqA = 14074000; +float freqB = 14074500; +char tx_vfo = '0'; +char rx_vfo = '0'; +char modeA = '1'; +char modeB = '1'; +int ks = 20; +int bandselect = 5; +int width = 21; +int narrow = 0; +int vd = 0; +int sm0 = 0; +int sm1 = 0; +int vs = 0; +int vx = 0; +int pa = 0; +int ra = 0; +int ag = 0; +int pc = 100; +int is = 0; +int bp_on = 0; +int bp_pos = 0; +int rl = 0; +int nb = 0; +int nr = 0; +int tx = 0; +int mg = 0; +int rg = 100; +int vg = 0; +int kr = 0; +int bi = 0; +int gt = 0; +int ex016 = 0; +int ex020 = 0; +int st = 0; + +// ID 0310 == 310, Must drop leading zero +typedef enum nc_rigid_e +{ + NC_RIGID_NONE = 0, + NC_RIGID_FT450 = 241, + NC_RIGID_FT450D = 244, + NC_RIGID_FT950 = 310, + NC_RIGID_FT891 = 135, + NC_RIGID_FT991 = 135, + NC_RIGID_FT2000 = 251, + NC_RIGID_FT2000D = 252, + NC_RIGID_FTDX1200 = 583, + NC_RIGID_FTDX9000D = 101, + NC_RIGID_FTDX9000Contest = 102, + NC_RIGID_FTDX9000MP = 103, + NC_RIGID_FTDX5000 = 362, + NC_RIGID_FTDX3000 = 460, + NC_RIGID_FTDX101D = 681, + NC_RIGID_FTDX101MP = 682, + NC_RIGID_FT710 = 800 +} nc_rigid_t; + +int +getmyline(int fd, char *buf) +{ + char c; + int i = 0; + memset(buf, 0, BUFSIZE); + + while (read(fd, &c, 1) > 0) + { + buf[i++] = c; + + if (c == ';') { return strlen(buf); } + } + + if (strlen(buf) == 0) { hl_usleep(10 * 1000); } + + return strlen(buf); +} + +#if defined(WIN32) || defined(_WIN32) +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd; + fd = open(comport, O_RDWR); + + if (fd < 0) + { + perror(comport); + } + + return fd; +} + +#else +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd = posix_openpt(O_RDWR); + char *name = ptsname(fd); + + if (name == NULL) + { + perror("pstname"); + return -1; + } + + printf("name=%s\n", name); + + if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) + { + perror("posix_openpt"); + return -1; + } + + return fd; +} +#endif + + + +int main(int argc, char *argv[]) +{ + char buf[256]; + char *pbuf; + int n; + int fd = openPort(argv[1]); + + while (1) + { + if (getmyline(fd, buf)) + { +// printf("Cmd:%s\n", buf); + } + else { continue; } + + if (strcmp(buf, ";") == 0) + { + pbuf = "?;"; + n = write(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "RM4;") == 0) + { + hl_usleep(50 * 1000); + pbuf = "RM4100;"; + n = write(fd, pbuf, strlen(pbuf)); + + if (n <= 0) { perror("RM4"); } + } + else if (strcmp(buf, "RM5;") == 0) + { + static int power = 0; + power+=5; + if (power > 255) power = 0; + hl_usleep(50 * 1000); + snprintf(buf,sizeof(buf),"RM5%03d000;", power); + n = write(fd, buf, strlen(buf)); + + if (n <= 0) { perror("RM5"); } + } + else if (strcmp(buf, "RM6;") == 0) + { + hl_usleep(50 * 1000); + pbuf = "AN030;"; + n = write(fd, pbuf, strlen(pbuf)); + + if (n <= 0) { perror("AN"); } + } + else if (strcmp(buf, "IF;") == 0) + { + hl_usleep(50 * 1000); + pbuf = "IF059014200000+000000700000;"; + n = write(fd, pbuf, strlen(pbuf)); + + if (n <= 0) { perror("IF"); } + } + else if (strcmp(buf, "FA;") == 0) + { + SNPRINTF(buf, sizeof(buf), "FA%08.0f;", freqA); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "FA", 2) == 0) + { + sscanf(buf, "FA%f", &freqA); + } + else if (strcmp(buf, "FB;") == 0) + { + SNPRINTF(buf, sizeof(buf), "FB%08.0f;", freqB); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "FB", 2) == 0) + { + sscanf(buf, "FB%f", &freqB); + } + else if (strcmp(buf, "ID;") == 0) + { + hl_usleep(50 * 1000); + int id = NC_RIGID_FT710; + SNPRINTF(buf, sizeof(buf), "ID%03d;", id); + n = write(fd, buf, strlen(buf)); + + if (n <= 0) { perror("ID"); } + } + else if (strcmp(buf, "PS;") == 0) + { + SNPRINTF(buf, sizeof(buf), "PS1;"); + n = write(fd, buf, strlen(buf)); + } + else if (strcmp(buf, "AI;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "AI0;"); + n = write(fd, buf, strlen(buf)); + + if (n <= 0) { perror("ID"); } + } + else if (strcmp(buf, "AI0;") == 0) + { + hl_usleep(50 * 1000); + } + else if (strcmp(buf, "FT;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "FT%c;", tx_vfo); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("FT"); } + } + else if (strncmp(buf, "FT", 2) == 0) + { + tx_vfo = buf[2]; + } + else if (strcmp(buf, "MD0;") == 0) + { + printf("MD=%s\n", buf); + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "MD0%c;", modeA); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("MD0;"); } + } + else if (strncmp(buf, "MD0", 3) == 0) + { + modeA = buf[3]; + } + else if (strcmp(buf, "MD1;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "MD1%c;", modeB); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("MD0;"); } + } + else if (strncmp(buf, "MD1", 3) == 0) + { + modeB = buf[3]; + } + + + +#if 0 + else if (strncmp(buf, "AI", 2) == 0) + { + if (strcmp(buf, "AI;")) + { + hl_usleep(50 * 1000); + n = fprintf(fp, "%s", "AI0;"); + + if (n <= 0) { perror("AI"); } + } + } + +#endif + else if (strcmp(buf, "VS;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "VS%d;", vs); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("VS"); } + } + else if (strncmp(buf, "VS", 2) == 0) + { + sscanf(buf, "VS%d", &vs); + } + else if (strcmp(buf, "KR;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "KR%d;", kr); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("KR"); } + } + else if (strncmp(buf, "KR", 2) == 0) + { + sscanf(buf, "KR%d", &kr); + } + else if (strcmp(buf, "BI;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "BI%d;", bi); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("BI"); } + } + else if (strncmp(buf, "BI", 2) == 0) + { + sscanf(buf, "BI%d", &bi); + } + else if (strcmp(buf, "VX;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "VX%d;", vx); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("VX"); } + } + else if (strncmp(buf, "VX", 2) == 0) + { + sscanf(buf, "VX%d", &vx); + } + + else if (strcmp(buf, "PA;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "PA%d;", pa); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("PA"); } + } + else if (strncmp(buf, "PA", 2) == 0) + { + sscanf(buf, "PA%d", &vs); + } + else if (strcmp(buf, "RA;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "RA%d;", ra); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("RA"); } + } + else if (strncmp(buf, "RA", 2) == 0) + { + sscanf(buf, "RA%d", &ra); + } + else if (strcmp(buf, "AG;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "AG%d;", ag); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("AG"); } + } + else if (strncmp(buf, "AG", 2) == 0) + { + sscanf(buf, "AG%d", &ag); + } + else if (strcmp(buf, "PC;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "PC%03d;", pc); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("PC"); } + } + else if (strncmp(buf, "PC", 2) == 0) + { + sscanf(buf, "PC%d", &pc); + } + else if (strcmp(buf, "VG;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "VG%03d;", vg); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("VG"); } + } + else if (strncmp(buf, "VG", 2) == 0) + { + sscanf(buf, "VG%d", &vg); + } + else if (strcmp(buf, "RG0;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "RG0%03d;", rg); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("RG"); } + } + else if (strncmp(buf, "RG", 2) == 0) + { + sscanf(buf, "RG0%d", &rg); + } + else if (strcmp(buf, "GT0;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "GT0%0d;", gt); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("GT"); } + } + else if (strncmp(buf, "GT", 2) == 0) + { + sscanf(buf, "GT0%d", >); + } + else if (strcmp(buf, "TX;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "TX+%04d;", tx); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("TX"); } + } + else if (strncmp(buf, "TX", 2) == 0) + { + sscanf(buf, "TX%d", &tx); + } + else if (strcmp(buf, "IS;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "IS+%04d;", is); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("IS"); } + } + else if (strncmp(buf, "IS", 2) == 0) + { + sscanf(buf, "IS%d", &is); + } + else if (strcmp(buf, "RL0;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "RL0%d;", rl); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("RL"); } + } + else if (strncmp(buf, "RL", 2) == 0) + { + sscanf(buf, "RL0%02d", &rl); + } + else if (strcmp(buf, "BP00;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "BP0%d;", bp_on); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("BP"); } + } + else if (strncmp(buf, "BP00", 4) == 0) + { + sscanf(buf, "BP00%d", &bp_on); + } + else if (strcmp(buf, "BP01;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "BP0%d;", bp_pos); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("BP"); } + } + else if (strncmp(buf, "BP01", 4) == 0) + { + sscanf(buf, "BP01%d", &bp_pos); + } + else if (strcmp(buf, "NB0;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "NB0%d;", nb); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("NB"); } + } + else if (strncmp(buf, "NB0", 3) == 0) + { + sscanf(buf, "NB0%d", &nb); + } + else if (strcmp(buf, "NR0;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "NR0%d;", nr); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("NR"); } + } + else if (strncmp(buf, "NR0", 3) == 0) + { + sscanf(buf, "NR0%d", &nr); + } + + + else if (strcmp(buf, "EX032;") == 0) + { + static int ant = 0; + ant = (ant + 1) % 3; + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("EX032"); } + } + else if (strcmp(buf, "EX016;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "EX016%04d;", ex016); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("EX016"); } + } + else if (strcmp(buf, "EX020;") == 0) + { + hl_usleep(50 * 1000); + SNPRINTF(buf, sizeof(buf), "EX020%04d;", ex020); + n = write(fd, buf, strlen(buf)); + + if (n < 0) { perror("EX016"); } + } + else if (strncmp(buf, "EX020", 5) == 0) + { + sscanf(buf, "EX020%d\n", &ex020); + } + else if (strncmp(buf, "KS;", 3) == 0) + { + sprintf(buf, "KS%d;", ks); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "KS", 2) == 0) + { + sscanf(buf, "KS%03d", &ks); + } + else if (strncmp(buf, "MG;", 3) == 0) + { + sprintf(buf, "MG%03d;", mg); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MG", 2) == 0) + { + sscanf(buf, "MG%03d", &mg); + } + else if (strncmp(buf, "BS;", 3) == 0) // cannot query BS + { + sprintf(buf, "BS%02d;", bandselect); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SH0;", 4) == 0) + { + sprintf(buf, "SH0%02d;", width); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SH0", 3) == 0) + { + sscanf(buf, "SH0%02d", &width); + } + else if (strncmp(buf, "NA0;", 4) == 0) + { + sprintf(buf, "NA0%d;", narrow); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "NA0", 3) == 0) + { + sscanf(buf, "NA0%d", &narrow); + } + else if (strncmp(buf, "VD;", 3) == 0) + { + sprintf(buf, "VD%d;", vd); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "VD", 2) == 0) + { + sscanf(buf, "VD%d", &vd); + } + else if (strncmp(buf, "SM0;", 4) == 0) + { + sprintf(buf, "SM0%d;", sm0); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SM0", 3) == 0) + { + sscanf(buf, "SM0%3d", &sm0); + } + else if (strncmp(buf, "SM1;", 4) == 0) + { + sprintf(buf, "SM1%d;", sm1); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SM1", 3) == 0) + { + sscanf(buf, "SM1%3d", &sm1); + } + else if (strncmp(buf, "ST1", 3) == 0) + { + sscanf(buf, "ST1%3d", &st); + } + else if (strncmp(buf, "ST;", 3) == 0) + { + sprintf(buf,"ST%d;", st); + n = write(fd, buf, strlen(buf)); + } + else if (strlen(buf) > 0) + { + fprintf(stderr, "Unknown command: %s\n", buf); + } + + } + + return 0; +} commit 2de9778f27a7d614cfe33d8af6f6ff2d1b78e444 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon May 27 22:59:54 2024 -0500 Add RFPOWER_METER and WATTS to py3test.py diff --git a/bindings/py3test.py b/bindings/py3test.py index 91b7e2f14..52f85e1e7 100755 --- a/bindings/py3test.py +++ b/bindings/py3test.py @@ -73,6 +73,8 @@ def StartUp(): Hamlib.rigerror(my_rig.error_status))) print("AF level:\t\t%0.2f" % my_rig.get_level_f(Hamlib.RIG_LEVEL_AF)) + print("Power level:\t\t%0.2f" % my_rig.get_level_f(Hamlib.RIG_LEVEL_RFPOWER_METER)) + print("Power level Watts:\t\t%0.2f" % my_rig.get_level_f(Hamlib.RIG_LEVEL_RFPOWER_METER_WATTS)) print("strength:\t\t%s" % my_rig.get_level_i(Hamlib.RIG_LEVEL_STRENGTH)) print("status:\t\t\t%s" % my_rig.error_status) print("status(str):\t\t%s" % Hamlib.rigerror(my_rig.error_status)) commit a721c04c536c0f7301608f49dcccbb1c03152f58 Merge: a5f53bbcf f53dc9905 Author: Michael Black <mdb...@ya...> Date: Mon May 27 22:13:00 2024 -0500 Merge pull request #1557 from GeoBaltz/fix12 Normalize some debug/trace output. commit f53dc99057869642b896c4743a99335900cfb39b Author: George Baltz N3GB <Geo...@gm...> Date: Mon May 27 20:31:46 2024 -0400 Normalize some debug/trace output. Make spaces(len) actually return a string of length 'len', not len + 1. Eliminate static writable memory and a 256 byte write on each debug/trace call. Make the depth stars line up. diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index fc360c692..9f52d271d 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -33,7 +33,7 @@ // Our shared secret password #define HAMLIB_SECRET_LENGTH 32 -#define HAMLIB_TRACE rig_debug(RIG_DEBUG_TRACE,"%s%s(%d) trace\n",spaces(rig->state.depth-1), __FILE__, __LINE__) +#define HAMLIB_TRACE rig_debug(RIG_DEBUG_TRACE,"%s%s(%d) trace\n",spaces(rig->state.depth), __FILE__, __LINE__) #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) #include <stdio.h> @@ -3738,7 +3738,7 @@ extern HAMLIB_EXPORT_VAR(char) debugmsgsave3[DEBUGMSGSAVE_SIZE]; // last-2 debu // Measuring elapsed time -- local variable inside function when macro is used #define ELAPSED1 struct timespec __begin; elapsed_ms(&__begin, HAMLIB_ELAPSED_SET); -#define ELAPSED2 rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s: elapsed=%.0lfms\n", spaces(rig->state.depth-1), rig->state.depth, __func__, elapsed_ms(&__begin, HAMLIB_ELAPSED_GET)); +#define ELAPSED2 rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s: elapsed=%.0lfms\n", spaces(rig->state.depth), rig->state.depth, __func__, elapsed_ms(&__begin, HAMLIB_ELAPSED_GET)); // use this instead of snprintf for automatic detection of buffer limit #define SNPRINTF(s,n,...) { snprintf(s,n,##__VA_ARGS__);if (strlen(s) > n-1) fprintf(stderr,"****** %s(%d): buffer overflow ******\n", __func__, __LINE__); } diff --git a/src/misc.c b/src/misc.c index e7bdb2c02..8d17baf6b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2857,26 +2857,21 @@ char *rig_date_strget(char *buf, int buflen, int localtime) return date_strget(buf, buflen, localtime); } +#define MAX_SPACES 256 const char *spaces(int len) { - static char s[256]; - memset(s, '*', sizeof(s)); + static const char s[MAX_SPACES + 1] = + "****************************************************************" + "****************************************************************" + "****************************************************************" + "****************************************************************"; - if (len > 255) + if (len < 0 || len > MAX_SPACES) { len = 0; } - if (len > 0) - { - s[len + 1] = 0; - } - else - { - s[1] = 0; - } - - return s; + return &s[MAX_SPACES - len]; } // if which==0 rig_band_select str will be returned commit a5f53bbcf68ba5fea29a40efbda357f109897663 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon May 27 16:11:38 2024 -0500 Change TS590 to Handshake=None -- it's not required and the rig can be in a state where RTS causes transmit. diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c index f38b46418..b71181518 100644 --- a/rigs/kenwood/ts590.c +++ b/rigs/kenwood/ts590.c @@ -1725,7 +1725,7 @@ struct rig_caps ts590_caps = .serial_data_bits = 8, .serial_stop_bits = 1, .serial_parity = RIG_PARITY_NONE, - .serial_handshake = RIG_HANDSHAKE_HARDWARE, + .serial_handshake = RIG_HANDSHAKE_NONE, .write_delay = 0, .post_write_delay = 0, .timeout = 500, @@ -2119,7 +2119,7 @@ struct rig_caps ts590sg_caps = .serial_data_bits = 8, .serial_stop_bits = 1, .serial_parity = RIG_PARITY_NONE, - .serial_handshake = RIG_HANDSHAKE_HARDWARE, + .serial_handshake = RIG_HANDSHAKE_NONE, .write_delay = 0, .post_write_delay = 0, .timeout = 500, commit 18568986f85688a6a2d6ae89c950af94dea6be2f Author: Mike Black W9MDB <mdb...@ya...> Date: Sat May 25 11:38:16 2024 -0500 Fix port override diff --git a/src/conf.c b/src/conf.c index 9e1e83e2a..2807710b2 100644 --- a/src/conf.c +++ b/src/conf.c @@ -262,7 +262,7 @@ static int frontend_set_conf(RIG *rig, hamlib_token_t token, const char *val) char *val2 = strdup(val); char *p = strchr(val2,':'); // port in here? if (p) { - p = 0; // terminate it + *p = 0; // terminate it rig_debug(RIG_DEBUG_WARN, "%s: overriding port and changing to 4992\n", __func__); } sprintf(rs->rigport_deprecated.pathname, "%s:%s", val2, "4992"); ----------------------------------------------------------------------- Summary of changes: bindings/py3test.py | 2 + doc/man1/rotctl.1 | 5 +- doc/man1/rotctld.1 | 5 +- include/hamlib/rig.h | 5 +- include/hamlib/rotator.h | 120 ++++++++++++++++++++++++++++++++++ rigs/dummy/dummy.c | 8 ++- rigs/dummy/rot_dummy.c | 16 +++++ rigs/flexradio/README | 1 + rigs/icom/xiegu.c | 14 ++-- rigs/kenwood/ts590.c | 4 +- rotators/spid/spid.c | 47 +++++++++++-- simulators/Makefile.am | 2 +- simulators/simflex.c | 2 + simulators/{simft450.c => simft710.c} | 23 +++++-- src/conf.c | 2 +- src/misc.c | 21 +++--- src/network.c | 25 +++++++ src/network.h | 1 + src/rig.c | 3 +- src/rotator.c | 7 +- tests/rigctlcom.c | 61 ++++++++++------- tests/rotctl_parse.c | 16 +++++ 22 files changed, 324 insertions(+), 66 deletions(-) create mode 100644 rigs/flexradio/README copy simulators/{simft450.c => simft710.c} (96%) hooks/post-receive -- Hamlib -- Ham radio control libraries |