[Bug 264271] comms/nanovna-saver: incorrect /dev/cua* to umodem number mapping

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 27 May 2022 04:01:55 UTC

            Bug ID: 264271
           Summary: comms/nanovna-saver: incorrect /dev/cua* to umodem
                    number mapping
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: hamradio@FreeBSD.org
          Reporter: jeffpc@josefsipek.net
             Flags: maintainer-feedback?(hamradio@FreeBSD.org)
          Assignee: hamradio@FreeBSD.org

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
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

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',
  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)
line 37, in __init__
line 67, in rescanSerialPort
    for iface in get_interfaces():
line 86, in get_interfaces
    vid_pid = usb_vid_pid(d.device)
"/usr/local/lib/python3.8/site-packages/NanoVNASaver/Hardware/Sysctl.py", line
20, in usb_vid_pid
    result =
"/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

You are receiving this mail because:
You are the assignee for the bug.