[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 23710cf2da3d8a05c7ed0
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: n0nb <n0...@us...> - 2025-10-12 12:35:09
|
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 23710cf2da3d8a05c7ed0b9bdecefe020404f0d1 (commit)
via a72397ec607cd6926149ebc4acbf189d3eb0ade6 (commit)
via 7349814e578a52939882ec8ab7ee1fa528328574 (commit)
via 48117e403ffbe8ff0c006e2ba9dcfc99f23860ee (commit)
via 7b9372ac46fd2c93f070c0cca7c19dcc34c684c7 (commit)
via fdde4d35cad736e5a93509d7e9924e9bd0e931c3 (commit)
via 8b840d8e848de077b546825a4a33f029de2ffd6a (commit)
via bc5b5b6725015fb9379679f2f10de8aef3ef7291 (commit)
from e992691354fb0d1966660f84314bfa31f3ee39c5 (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 23710cf2da3d8a05c7ed0b9bdecefe020404f0d1
Author: George Baltz N3GB <Geo...@gm...>
Date: Fri Oct 10 10:52:54 2025 -0400
Use return value from remove_nonprint()
Fix formatting glitch
diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c
index 2b5972ed9..b6171522b 100644
--- a/amplifiers/elecraft/kpa.c
+++ b/amplifiers/elecraft/kpa.c
@@ -586,7 +586,7 @@ int kpa_set_powerstat(AMP *amp, powerstat_t status)
default:
rig_debug(RIG_DEBUG_ERR, "%s invalid status=%d\n", __func__, status);
- return -RIG_EINVAL;
+ return -RIG_EINVAL;
}
diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c
index 7e1acbe70..c607ee4f0 100644
--- a/rigs/kenwood/kenwood.c
+++ b/rigs/kenwood/kenwood.c
@@ -490,8 +490,7 @@ transaction_read:
// message; if it isn't (usually '\r') then don't touch the message.
if (isprint(caps->cmdtrm))
{
- remove_nonprint(buffer);
- resp_len = strlen(buffer);
+ resp_len = remove_nonprint(buffer);
}
/* Check that command termination is correct */
commit a72397ec607cd6926149ebc4acbf189d3eb0ade6
Author: George Baltz N3GB <Geo...@gm...>
Date: Wed Oct 8 13:02:44 2025 -0400
Use correct length when transfering result to caller.
Fix formatting.
Make trace message jibe with its surrounding.
diff --git a/rigs/dummy/rot_pstrotator.c b/rigs/dummy/rot_pstrotator.c
index c156a8c7d..71dd8fc73 100644
--- a/rigs/dummy/rot_pstrotator.c
+++ b/rigs/dummy/rot_pstrotator.c
@@ -337,7 +337,7 @@ static int pstrotator_rot_open(ROT *rot)
if (bind(sockfd, (const struct sockaddr *)&clientAddr, sizeof(clientAddr)) < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: bind failed: %s\n", __func__, strerror(errno));
- close(sockfd);
+ close(sockfd);
return -RIG_EINTERNAL;
}
diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c
index 5472f2d2d..7e1acbe70 100644
--- a/rigs/kenwood/kenwood.c
+++ b/rigs/kenwood/kenwood.c
@@ -650,7 +650,7 @@ transaction_read:
{
/* move the result excluding the command terminator into the
caller buffer */
- len = min(datasize, retval) - 1;
+ len = min(datasize, resp_len) - 1;
strncpy(data, buffer, len);
data[len] = '\0';
}
@@ -706,7 +706,7 @@ transaction_read:
}
}
- rig_debug(RIG_DEBUG_TRACE, "%s: returning RIG_OK, retval=%d\n", __func__,
+ rig_debug(RIG_DEBUG_TRACE, "%s: returning RIG_OK, retval was %d\n", __func__,
retval);
retval = RIG_OK;
commit 7349814e578a52939882ec8ab7ee1fa528328574
Author: George Baltz N3GB <Geo...@gm...>
Date: Tue Oct 7 16:59:21 2025 -0400
Don't call remove_nonprint() if error occurred
The buffer may not contain a well-formed string. Use count returned by
read_string(), and check for short response. Replace 2 strlen() calls
with maximum of 1.
Reformat some comments to minimize wrapping.
diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c
index 03cbe0d12..5472f2d2d 100644
--- a/rigs/kenwood/kenwood.c
+++ b/rigs/kenwood/kenwood.c
@@ -284,6 +284,7 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data,
int retval = -RIG_EINTERNAL;
char *cmd;
int len;
+ int resp_len; // Response length
int retry_read = 0;
struct kenwood_priv_data *priv = STATE(rig)->priv;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
@@ -449,14 +450,7 @@ transaction_read:
rig_debug(RIG_DEBUG_TRACE, "%s: read_string len=%d '%s'\n", __func__,
(int)strlen(buffer), buffer);
- // This fixes the case when some corrupt data is returned; it lets us be a
- // little more robust about funky serial data. If the terminator is
- // printable(usually ';'), then there should be no nonprintables in the
- // message; if it isn't (usually '\r') then don't touch the message.
- if (isprint(caps->cmdtrm))
- {
- remove_nonprint(buffer);
- }
+ resp_len = retval;
if (retval < 0)
{
@@ -490,10 +484,20 @@ transaction_read:
goto transaction_quit;
}
+ // This fixes the case when some corrupt data is returned; it lets us be a
+ // little more robust about funky serial data. If the terminator is
+ // printable(usually ';'), then there should be no nonprintables in the
+ // message; if it isn't (usually '\r') then don't touch the message.
+ if (isprint(caps->cmdtrm))
+ {
+ remove_nonprint(buffer);
+ resp_len = strlen(buffer);
+ }
+
/* Check that command termination is correct */
- if (strchr(cmdtrm_str, buffer[strlen(buffer) - 1]) == NULL)
+ if (resp_len < 1 || strchr(cmdtrm_str, buffer[resp_len - 1]) == NULL)
{
- rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n",
+ rig_debug(RIG_DEBUG_ERR, "%s: Response is not correctly terminated '%s'\n",
__func__, buffer);
if (retry_read++ < rp->retry)
@@ -505,7 +509,7 @@ transaction_read:
goto transaction_quit;
}
- if (strlen(buffer) == 2)
+ if (resp_len == 2)
{
switch (buffer[0])
{
@@ -556,12 +560,13 @@ transaction_read:
case '?':
/* The ? response is an ambiguous response, but for get commands it seems to
- * indicate that the rig rejected the command because the state of the rig is not valid for the command
- * or that the command parameter is invalid. Retrying the command does not fix the issue,
- * as the error is caused by the an invalid combination of rig state.
+ * indicate that the rig rejected the command because the state of the rig is
+ * not valid for the command or that the command parameter is invalid.
+ * Retrying the command does not fix the issue, as the error is caused by
+ * the invalid combination of command and rig state.
*
* For example, the following cases have been observed:
- * - NL (NB level) and RL (NR level) commands fail if NB / NR are not enabled on TS-590SG
+ * - NL(NB level) and RL(NR level) commands fail if NB/NR are not enabled on TS-590SG
* - SH and SL (filter width) fail in CW mode on TS-590SG
* - GT (AGC) fails in FM mode on TS-590SG
*
@@ -701,9 +706,9 @@ transaction_read:
}
}
- retval = RIG_OK;
rig_debug(RIG_DEBUG_TRACE, "%s: returning RIG_OK, retval=%d\n", __func__,
retval);
+ retval = RIG_OK;
transaction_quit:
commit 48117e403ffbe8ff0c006e2ba9dcfc99f23860ee
Author: George Baltz N3GB <Geo...@gm...>
Date: Mon Oct 6 11:50:50 2025 -0400
Fix fd leak in rot_pstrotator.c
Close orphan fd in error case.
And in the normal close routine, too.
diff --git a/rigs/dummy/rot_pstrotator.c b/rigs/dummy/rot_pstrotator.c
index da8a2a0d5..c156a8c7d 100644
--- a/rigs/dummy/rot_pstrotator.c
+++ b/rigs/dummy/rot_pstrotator.c
@@ -18,12 +18,13 @@
*
*/
+#include "hamlib/config.h"
#include <stdlib.h>
#include <string.h> /* String function definitions */
#include <sys/time.h>
#include <errno.h>
+#include <unistd.h>
-#include "hamlib/config.h"
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@@ -277,6 +278,7 @@ static int pstrotator_rot_init(ROT *rot)
priv->az = priv->el = 0;
priv->target_az = priv->target_el = 0;
+ priv->sockfd2 = -1;
strcpy(ROTPORT(rot)->pathname, "192.168.56.1:12000");
@@ -335,6 +337,7 @@ static int pstrotator_rot_open(ROT *rot)
if (bind(sockfd, (const struct sockaddr *)&clientAddr, sizeof(clientAddr)) < 0)
{
rig_debug(RIG_DEBUG_ERR, "%s: bind failed: %s\n", __func__, strerror(errno));
+ close(sockfd);
return -RIG_EINTERNAL;
}
@@ -370,6 +373,11 @@ static int pstrotator_rot_close(ROT *rot)
rig_debug(RIG_DEBUG_VERBOSE, "%s: thread stopped\n", __func__);
priv->threadid = 0;
+ if (priv->sockfd2 != -1)
+ {
+ close(priv->sockfd2);
+ priv->sockfd2 = -1;
+ }
return RIG_OK;
}
commit 7b9372ac46fd2c93f070c0cca7c19dcc34c684c7
Author: George Baltz N3GB <Geo...@gm...>
Date: Sun Oct 5 16:32:40 2025 -0400
Fold range check into existing switch statement
Cleaner code, and avoids a bogus squawk from gcc -fanalyzer.
diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c
index 780ff36e3..e23a0df1d 100644
--- a/rigs/kenwood/k3.c
+++ b/rigs/kenwood/k3.c
@@ -2996,12 +2996,6 @@ static int k3_send_voice_mem(RIG *rig, vfo_t vfo, int ch)
const char *cmd;
int retval;
- if (ch < 1 || ch > 4)
- {
- rig_debug(RIG_DEBUG_ERR, "%s: expected 1<=ch<=4, got %d\n", __func__, ch);
- return (-RIG_EINVAL);
- }
-
switch (ch)
{
case 1: cmd = "SWT21;"; break;
@@ -3011,6 +3005,10 @@ static int k3_send_voice_mem(RIG *rig, vfo_t vfo, int ch)
case 3: cmd = "SWT35;"; break;
case 4: cmd = "SWT39;"; break;
+
+ default:
+ rig_debug(RIG_DEBUG_ERR, "%s: expected 1<=ch<=4, got %d\n", __func__, ch);
+ return (-RIG_EINVAL);
}
retval = kenwood_transaction(rig, cmd, NULL, 0);
commit fdde4d35cad736e5a93509d7e9924e9bd0e931c3
Author: George Baltz N3GB <Geo...@gm...>
Date: Sun Oct 5 16:22:13 2025 -0400
Remove funky debug writes in trxmanager.c
diff --git a/rigs/dummy/trxmanager.c b/rigs/dummy/trxmanager.c
index aa21ee3d3..a462086fd 100644
--- a/rigs/dummy/trxmanager.c
+++ b/rigs/dummy/trxmanager.c
@@ -1165,11 +1165,7 @@ static int trxmanager_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
if (strlen(response) != 16 || strstr(response, cmd) == NULL)
{
- FILE *fp;
rig_debug(RIG_DEBUG_ERR, "%s invalid response='%s'\n", __func__, response);
- fp = fopen("debug.txt", "w+");
- fprintf(fp, "XT response=%s\n", response);
- fclose(fp);
return -RIG_EPROTO;
}
commit 8b840d8e848de077b546825a4a33f029de2ffd6a
Author: George Baltz N3GB <Geo...@gm...>
Date: Sun Oct 5 16:19:16 2025 -0400
Always return in error case
Don't fall into normal code and get a segfault.
diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c
index 4b9a6a79b..2b5972ed9 100644
--- a/amplifiers/elecraft/kpa.c
+++ b/amplifiers/elecraft/kpa.c
@@ -574,7 +574,7 @@ int kpa_set_powerstat(AMP *amp, powerstat_t status)
switch (status)
{
- case RIG_POWER_UNKNOWN: break;
+ //case RIG_POWER_UNKNOWN: break;
case RIG_POWER_OFF: cmd = "^ON0;"; break;
@@ -584,17 +584,15 @@ int kpa_set_powerstat(AMP *amp, powerstat_t status)
case RIG_POWER_STANDBY: cmd = "^OS0;"; break;
-
default:
rig_debug(RIG_DEBUG_ERR, "%s invalid status=%d\n", __func__, status);
+ return -RIG_EINVAL;
}
retval = kpa_transaction(amp, cmd, NULL, 0);
- if (retval != RIG_OK) { return retval; }
-
- return RIG_OK;
+ return retval;
}
int kpa_reset(AMP *amp, amp_reset_t reset)
diff --git a/amplifiers/gemini/gemini.c b/amplifiers/gemini/gemini.c
index 58da33581..c2f351813 100644
--- a/amplifiers/gemini/gemini.c
+++ b/amplifiers/gemini/gemini.c
@@ -348,7 +348,7 @@ int gemini_set_powerstat(AMP *amp, powerstat_t status)
switch (status)
{
- case RIG_POWER_UNKNOWN: break;
+ //case RIG_POWER_UNKNOWN: break;
case RIG_POWER_OFF: cmd = "R0\n"; break;
@@ -358,17 +358,15 @@ int gemini_set_powerstat(AMP *amp, powerstat_t status)
case RIG_POWER_STANDBY: cmd = "R0\n"; break;
-
default:
rig_debug(RIG_DEBUG_ERR, "%s invalid status=%d\n", __func__, status);
+ return -RIG_EINVAL;
}
retval = gemini_transaction(amp, cmd, NULL, 0);
- if (retval != RIG_OK) { return retval; }
-
- return RIG_OK;
+ return retval;
}
int gemini_reset(AMP *amp, amp_reset_t reset)
commit bc5b5b6725015fb9379679f2f10de8aef3ef7291
Author: George Baltz N3GB <Geo...@gm...>
Date: Sun Oct 5 12:51:42 2025 -0400
Use auto storage instead of clobbering string literal.
diff --git a/tests/rigctltcp.c b/tests/rigctltcp.c
index 5ccccd09b..05ca65dc8 100644
--- a/tests/rigctltcp.c
+++ b/tests/rigctltcp.c
@@ -1121,7 +1121,7 @@ void *handle_socket(void *arg)
powerstat_t powerstat;
unsigned char cmd[64];
unsigned char reply[64];
- unsigned char *term = (unsigned char *)";";
+ unsigned char term[2] = ";";
rig_debug(RIG_DEBUG_TRACE, "%s: doing rigctl_parse vfo_mode=%d, secure=%d\n",
__func__,
handle_data_arg->vfo_mode, handle_data_arg->use_password);
-----------------------------------------------------------------------
Summary of changes:
amplifiers/elecraft/kpa.c | 8 +++-----
amplifiers/gemini/gemini.c | 8 +++-----
rigs/dummy/rot_pstrotator.c | 10 +++++++++-
rigs/dummy/trxmanager.c | 4 ----
rigs/kenwood/k3.c | 10 ++++------
rigs/kenwood/kenwood.c | 40 ++++++++++++++++++++++------------------
tests/rigctltcp.c | 2 +-
7 files changed, 42 insertions(+), 40 deletions(-)
hooks/post-receive
--
Hamlib -- Ham radio control libraries
|