kopia lustrzana https://github.com/Hamlib/Hamlib
Let kenwood serial read remove non-printable chars from responses
Should help it be a bit more robust against bad serial data like this https://github.com/Hamlib/Hamlib/issues/1652pull/1662/head
rodzic
b2b8586c93
commit
d1e0e3f204
|
@ -231,6 +231,23 @@ struct confparams kenwood_cfg_params[] =
|
|||
{ RIG_CONF_END, NULL, }
|
||||
};
|
||||
|
||||
int remove_nonprint(char *s)
|
||||
{
|
||||
int i, j = 0;
|
||||
if (s == NULL) return 0;
|
||||
|
||||
for (i = 0; s[i] != '\0'; ++i)
|
||||
{
|
||||
if (isprint((unsigned char)s[i]))
|
||||
{
|
||||
s[j++] = s[i]; // Copy printable character
|
||||
}
|
||||
}
|
||||
s[j] = '\0'; // Null-terminate the string
|
||||
|
||||
return j; // Return the new length of the string
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* kenwood_transaction
|
||||
|
@ -424,6 +441,10 @@ 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
|
||||
// let's us be a little more robust about funky serial data
|
||||
remove_nonprint(buffer);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_WARN,
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "token.h"
|
||||
#include "idx_builtin.h"
|
||||
|
||||
#define BACKEND_VER "20241022"
|
||||
#define BACKEND_VER "20250107"
|
||||
|
||||
#define EOM_KEN ';'
|
||||
#define EOM_TH '\r'
|
||||
|
|
Ładowanie…
Reference in New Issue