Skip to content

fix: handle OSError and macOS port detection for NanoVNA V2 - #848

Open
chihyunan wants to merge 1 commit into
NanoVNA-Saver:mainfrom
chihyunan:fix/macos-port-scan-oserror
Open

fix: handle OSError and macOS port detection for NanoVNA V2#848
chihyunan wants to merge 1 commit into
NanoVNA-Saver:mainfrom
chihyunan:fix/macos-port-scan-oserror

Conversation

@chihyunan

Copy link
Copy Markdown

Pull Request type

  • Bugfix

What is the current behavior?

On macOS with a NanoVNA V2, two bugs prevent the app from working:

  1. On startup, LiteVNA64.is_lite_vna_64() throws an unhandled OSError
    during port scanning, crashing the app before the UI opens. It opens fine
    when no port is connected, but the fix below ensures opening regardless.

  2. get_interfaces() only applied _fix_v2_hwinfo() on Windows. On macOS
    the V2 enumerates with vid=None and hwid containing DEMO, so it was
    silently filtered out and no device was ever detected on port scan.

Issue Number: N/A

What is the new behavior?

  • detect_version() now wraps LiteVNA64.is_lite_vna_64() in
    try/except OSError, falling back to "v2" on failure. No behavior
    change on Windows/Linux where the call succeeds normally. This ensures
    that the program will execute even when port is already connected.

  • get_interfaces() now applies _fix_v2_hwinfo() on both Windows and
    macOS (Darwin). The fix is safe on macOS because _fix_v2_hwinfo()
    only modifies a device if its hwid contains the string
    PORTS\VID_04B4&PID_0008, which is a Windows-style path that will never
    appear on Linux, leaving that platform's behavior unchanged. Now port scan
    works on MacOS correctly.

Does this introduce a breaking change?

  • No

Other information

Tested on macOS [Tahoe 26.3] with NanoVNA V2 (SAA-2). App now
launches and detects the device successfully. Both fixes are isolated to
Hardware/Hardware.py with minimal diff.

- Wrap LiteVNA64.is_lite_vna_64() call in try/except OSError to prevent
  crash on startup during port scanning
- Extend _fix_v2_hwinfo() to also apply on macOS (Darwin), not just Windows,
  so devices enumerating as DEMO with vid=None are correctly detected

Verified on macOS [your version] with NanoVNA V2.
@chihyunan
chihyunan requested a review from zarath as a code owner April 11, 2026 20:41

@zarath zarath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution

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.

2 participants