Bug 264271 - comms/nanovna-saver: incorrect /dev/cua* to umodem number mapping
Summary: comms/nanovna-saver: incorrect /dev/cua* to umodem number mapping
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Diane Bruce
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-05-27 04:01 UTC by Josef 'Jeff' Sipek
Modified: 2022-08-01 13:20 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (hamradio)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josef 'Jeff' Sipek 2022-05-27 04:01:55 UTC
While trying to validate an upstream fix to a device enumeration issue [1], I realized that the ports package has a tweak to get the USB vendor & product IDs from sysctl [2].  Unfortunately, this code is incorrect since it assumes that /dev/cua*N corresponds to dev.umodem.N.  For example, on my system I see:

$ sysctl -a|grep umodem
hw.usb.umodem.debug: 0
dev.umodem.0.ttyports: 1
dev.umodem.0.ttyname: U1
dev.umodem.0.%parent: uhub5
dev.umodem.0.%pnpinfo: vendor=0x0483 product=0x5740 devclass=0x02 devsubclass=0x00 devproto=0x00 sernum="510" release=0x0200 mode=host intclass=0x02 intsubclass=0x02 intprotocol=0x01 ttyname=U1 ttyports=1
dev.umodem.0.%location: bus=2 hubaddr=2 port=8 devaddr=4 interface=0 ugen=ugen2.4
dev.umodem.0.%driver: umodem
dev.umodem.0.%desc: STMicroelectronics ChibiOS/RT Virtual COM Port, class 2/0, rev 1.10/2.00, addr 4
dev.umodem.%parent: 

The %pnpinfo and ttyname nodes state that dev.umodem.0 corresponds to /dev/cuaU1.  As a result, NanoVNA-Saver fails to start with the following backtrace as it finds cuaU1 and then proceeds to attempt to get dev.umodem.1.%pnpinfo sysctl nodes:

Traceback (most recent call last):
  File "/usr/local/bin/NanoVNASaver", line 33, in <module>
    sys.exit(load_entry_point('NanoVNASaver==0.3.10', 'console_scripts', 'NanoVNASaver')())
  File "/usr/local/lib/python3.8/site-packages/NanoVNASaver/__main__.py", line 85, in main
    window = NanoVNASaver()
  File "/usr/local/lib/python3.8/site-packages/NanoVNASaver/NanoVNASaver.py", line 92, in __init__
    self.serial_control = SerialControl(self)
  File "/usr/local/lib/python3.8/site-packages/NanoVNASaver/Controls/SerialControl.py", line 37, in __init__
    self.rescanSerialPort()
  File "/usr/local/lib/python3.8/site-packages/NanoVNASaver/Controls/SerialControl.py", line 67, in rescanSerialPort
    for iface in get_interfaces():
  File "/usr/local/lib/python3.8/site-packages/NanoVNASaver/Hardware/Hardware.py", line 86, in get_interfaces
    vid_pid = usb_vid_pid(d.device)
  File "/usr/local/lib/python3.8/site-packages/NanoVNASaver/Hardware/Sysctl.py", line 20, in usb_vid_pid
    result = (posix_sysctlbyname(b'dev.umodem.'+bytes(digit,'ascii')+b'.%pnpinfo')).decode('ascii')
  File "/usr/local/lib/python3.8/site-packages/NanoVNASaver/Hardware/Sysctl.py", line 14, in posix_sysctlbyname
    raise Exception('sysctlbyname returned with error %s' % result)
Exception: sysctlbyname returned with error -1

[1] https://github.com/NanoVNA-Saver/nanovna-saver/issues/502
[2] https://cgit.freebsd.org/ports/tree/comms/nanovna-saver/files
Comment 1 Diane Bruce freebsd_committer freebsd_triage 2022-05-30 21:36:05 UTC
I'll look at this ASAP.
Comment 2 Diane Bruce freebsd_committer freebsd_triage 2022-06-07 17:59:14 UTC
Oopsies I had the wrong PR on the git commit.