radio_io: say when radio_device is the wrong kind of port for the rig (#179) - #182
Merged
Conversation
A FlexRadio (SmartSDR, model 23005) is a network rig: Hamlib wants an address in rig_pathname and appends its own default port. Configured with radio_device = COM4, Hamlib built "COM4:4992", failed to resolve it, and returned "Invalid parameter" -- which sent the reporter of #179 looking at baud rates and CAT ports instead of at the address he needed. Nothing told him the rig was a network rig. Three things now do: - `-K` gains a Port column (serial / net / usb), so the port kind is visible at the moment you pick the model number. - radio_serial_speed is only pushed at serial rigs. It was previously sent unconditionally, so every network rig logged "rig_set_conf(serial_speed) failed: -1" -- alarming, and a waste of the one signal that says this is not a serial rig at all. - radio_device is checked against the rig's port kind before rig_open, and the advice is repeated next to the failure, since the pre-flight line is easily lost in Hamlib's backend chatter. The check is advisory only. It matches the device string by shape, and a shape heuristic must never veto a configuration that would in fact have worked, so Hamlib still gets to try either way. test_radio_port leans on the false-positive side accordingly: bare and bracketed IPv6, rigctld host:port, \\.\COM12, /dev/serial/by-id, and an unset device all have to stay silent, and "COMPUTER" / "com.example.net" must not read as COM ports. Port kind and model name are read through rig_get_caps_int() / rig_get_caps_cptr() rather than rig->caps->..., for the same reason the conf tokens are already preferred over rig->state.rigport: accessors keyed on the model number do not depend on a struct layout that Hamlib 5 is progressively closing off. Also switch the failure message from rigerror() to rigerror2(): the former appends Hamlib's debug ring buffer, so above log level 0 the actual reason is buried. "rig_open(COM4) failed: Invalid parameter (-1)" instead of a page of backend trace. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The version ladder around rig_state existed to fetch `rs`, but nothing
ever read it -- the block only logs hamlib_version2, and gcc has been
saying so ("unused variable 'rs'") on every build.
Its fallback arm dereferences radio->state, and Hamlib 5 removed `state`
from struct s_rig, so this dead line was the one thing in radio_io.c
that would not compile against 5.0.0~git. Deleting it costs nothing and
takes the file to zero errors under Hamlib 5 headers.
Verified with -fsyntax-only against Hamlib 5.0.0~git (a475dad9d) for
both radio_io.c and rigctl_parse.c; still builds and behaves on the
4.6.2 we ship against.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the diagnosis half of #179.
A FlexRadio (SmartSDR, model 23005) is a network rig: Hamlib wants an address in
rig_pathnameand appends its own default port. Configured withradio_device = COM4, Hamlib built"COM4:4992", failed to resolve it, and returnedInvalid parameter— which sent the reporter looking at baud rates and CAT ports instead of at the address he actually needed.Nothing in Mercury told him the rig was a network rig. Three things now do.
Before / after
and
-Kgains a Port column, so the port kind is visible at the moment you pick the model number:Changes
-Kshows the port kind (serial / net / usb).radio_serial_speedis only pushed at serial rigs. It was sent unconditionally, so every network rig loggedrig_set_conf(serial_speed) failed: -1— alarming, and a waste of the one signal that says this is not a serial rig at all.radio_deviceis checked against the rig's port kind beforerig_open, with the advice repeated next to the failure (the pre-flight line is easily lost in Hamlib's backend chatter).rigerror2()instead ofrigerror()— the latter appends Hamlib's debug ring buffer, so above log level 0 the actual reason is buried.rig_statelookup removed (separate commit):rswas assigned and never read — gcc has been warning about it — and its fallback arm dereferencedradio->state, which Hamlib 5 removed. It was the only thing inradio_io.cthat would not compile against 5.The check is advisory only
It matches the device string by shape, and a shape heuristic must never veto a configuration that would in fact have worked — so Hamlib still gets to try either way.
test_radio_portleans on the false-positive side accordingly: bare and bracketed IPv6,rigctldhost:port,\\.\COM12,/dev/serial/by-id/...and an unset device all have to stay silent, andCOMPUTER/com.example.netmust not read as COM ports.Hamlib 5
Port kind and model name are read via
rig_get_caps_int()/rig_get_caps_cptr()rather thanrig->caps->…, for the same reason the conf tokens are already preferred overrig->state.rigport: accessors keyed on the model number don't depend on a struct layout Hamlib 5 is progressively closing off.Verified with
-fsyntax-onlyagainst Hamlib 5.0.0~git (a475dad9d):radio_io.candrigctl_parse.cboth compile with 0 errors (before this branch,radio_io.cfailed onradio->state). All three symbols used are declared in Hamlib 5'srig.hand exported by the vendored w64/macOS libs. Still builds and behaves on the 4.6.2 we ship against.Testing
make test— 234 pass (8 new intest_radio_port)go test -count=1intests/integration— PASS-R 23005 -A COM4) and his fix (-A 192.168.1.50); the latter draws no warning. Serial rig +/dev/ttyUSB0also stays silent.Not addressed here
ptt_pathname/ptt_typeconfig. The reporter has "COM5 for PTT only on RTS"; Mercury can't express that. Harmless for his Flex (SmartSDR keys over the network) but a real gap for split CAT/PTT setups.docs/— he asked, and the answer is currently no.🤖 Generated with Claude Code