Skip to content

Un-break hamlib on TM-D710/TM-V71/etc#1768

Merged
N0NB merged 1 commit into
Hamlib:masterfrom
larsks:fix/bad-kenwood-protocol
Jun 18, 2025
Merged

Un-break hamlib on TM-D710/TM-V71/etc#1768
N0NB merged 1 commit into
Hamlib:masterfrom
larsks:fix/bad-kenwood-protocol

Conversation

@larsks

@larsks larsks commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

This reverts commit d1e0e3f.

That commit introduced a remove_nonprint method that breaks hamlib on all
TM-D710/TM-V71A devices by erroneously removing the command termination
character.

Resolves: #1767 #1698

@larsks larsks mentioned this pull request Jun 17, 2025
@N0NB

N0NB commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Rather than a complete reversion, would it be possible to not apply the remove_nonprint function to affected models or, better yet, make sure the command termination character is preserved? Mike's commit references issue #1652 so it seems there is a reason Mike added this but may have inadvertently stripped the command terminator as well.

@larsks

larsks commented Jun 17, 2025

Copy link
Copy Markdown
Contributor Author

Rather than a complete reversion, would it be possible to not apply the remove_nonprint function to affected models or, better yet, make sure the command termination character is preserved?

Maybe! This revert will at least resolve the problem for people trying to use hamlib with impacted devices. We can certainly choose not to merge it, but now at least I can point people here who run into the same problem.

To be clear: at the moment, hamlib is now completely broken on a variety of Kenwood devices. I'm sure it's possible to create a more nuanced solution to #1652, but that will take time and given severe nature of the problem I wanted to make this fix available.

Mike's commit references issue #1652 so it seems there is a reason Mike added this but may have inadvertently stripped the command terminator as well.

The change was made in the context of Kenwood devices that use ; as the command terminator; it was never tested on devices that use \r.

@GeoBaltz

GeoBaltz commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

How about checking the expected command terminator(kenwood_priv_caps.cmdtrm) - if it is printable, remove the nonprintables. If it isn't printable, then don't.

@N0NB

N0NB commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

George, that's a much more elegant solution than my example in #1767 which only tests for \r and is hard coded.

@GeoBaltz

GeoBaltz commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Something like this -

diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c
index 1596c2dfe..88655f2dd 100644
--- a/rigs/kenwood/kenwood.c
+++ b/rigs/kenwood/kenwood.c
@@ -445,7 +445,13 @@ transaction_read:
 
     // 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 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);
+    }
 
     if (retval < 0)
     {

@N0NB

N0NB commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

George, check my proposed fix in #1767. The problem is outlined in #1652 and I think needs to be dealt with in the remove_nonprint function.

@N0NB

N0NB commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Then again, yours might be correct if radios that use EOM_TH (\r) need to pass unprintable characters to the host.

@N0NB

N0NB commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

Lars, give George's patch preference over mine as it's likely correct in that radios that use EOM_TH should not have the message modified.

@brightkill

Copy link
Copy Markdown

Since the previous commit works for some devices but breaks others, maybe instead of reverting it entirely, we could keep the old behavior behind a ./configure flag (e.g., --enable-removenonprint or similar).

This way, users who rely on the previous behavior can enable it explicitly, while the default remains compatible with the majority of devices.

@N0NB

N0NB commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

Hi @brightkill

I think George's submission will work for both cases. Having to invoke configure time options for relatively common devices is not something we wish to do. This will be resolved in the library.

One question I have for you related to issue #1652 is whether the device firmware was updated by the authors to remove the unprintable characters?

@larsks larsks changed the title Revert "Let kenwood serial read remove non-printable chars from responses" Un-break hamlib on TM-D710/TM-V71/etc Jun 18, 2025
@larsks larsks force-pushed the fix/bad-kenwood-protocol branch from 2dac91d to 7bea004 Compare June 18, 2025 02:05
@larsks

larsks commented Jun 18, 2025

Copy link
Copy Markdown
Contributor Author

@GeoBaltz I've updated this PR to adopt your proposed solution.

@larsks larsks force-pushed the fix/bad-kenwood-protocol branch from 7bea004 to 9e3c8a1 Compare June 18, 2025 02:14
Commit d1e0e3f introduced a `remove_nonprint` method that breaks hamlib on
all TM-D710/TM-V71A devices by erroneously removing the command termination
character (`\r`).

This commit adopts a solution proposed by @GeoBaltz that only runs
`remove_nonprint` if the command termination character itself is printable.

Resolves: Hamlib#1767 Hamlib#1698
@larsks larsks force-pushed the fix/bad-kenwood-protocol branch from 9e3c8a1 to 85c9e15 Compare June 18, 2025 02:15
@N0NB N0NB merged commit 85c9e15 into Hamlib:master Jun 18, 2025
5 checks passed
@N0NB

N0NB commented Jun 18, 2025

Copy link
Copy Markdown
Contributor

Thanks, Lars and George.

This will be in tomorrow's daily snapshot. I will also cherry-pick this over into the Hamlib-4.6.3 branch for a bug fix 4.6.4 release in a few weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kenwood_transaction() is erroneously stripping eol characters, breaking hamlib for tm-d710/tm-v71a devices.

4 participants