Skip to content

nutdrv_qx: fix Cypress 0665:5161 replies - #3563

Open
pixi-p wants to merge 7 commits into
networkupstools:masterfrom
pixi-p:nutdrv-qx-cypress-0665-5161
Open

nutdrv_qx: fix Cypress 0665:5161 replies#3563
pixi-p wants to merge 7 commits into
networkupstools:masterfrom
pixi-p:nutdrv-qx-cypress-0665-5161

Conversation

@pixi-p

@pixi-p pixi-p commented Aug 10, 2026

Copy link
Copy Markdown

Fix handling of stale interrupt reports for the Cypress 0665:5161 USB transport.

The device can keep replies from prior commands queued on its interrupt endpoint,
which can break Qx protocol autodetection. Drain a bounded number of stale
reports before sending a command and use a longer reply timeout for this USB ID.

Verified with a VOLT Polska RackUPS 1200VA/720W (USB ID 0665:5161).
The driver autodetects the Voltronic-QS protocol and reports live UPS data.

Related to #2534.

Scope note: USB ID 0665:5161 is already shared by Belkin F6C1200-UNV and
Voltronic Power UPSes in qx_usb_id[]. The tested device is a VOLT Polska
RackUPS rebadge; its USB manufacturer and product strings are empty, so no
reliable finer-grained USB match is available. The quirk is therefore scoped
to this existing Cypress transport entry. Testing on a Belkin device would be
welcome.

Implementation and documentation were prepared with assistance from OpenAI
Codex; the contributor reviewed and tested the changes on the hardware
described above.

General points

  • Described the changes in the PR submission or a separate issue, e.g.
    known published or discovered protocols, applicable hardware (expected
    compatible and actually tested/developed against), limitations, etc.

  • There may be multiple commits in the PR, aligned and commented with
    a functional change. Notably, coding style changes better belong in a
    separate PR, but certainly in a dedicated commit to simplify reviews
    of "real" changes in the other commits. Similarly for typo fixes in
    comments or text documents.

  • Use of coding helper tools and AI should be disclosed in the commit
    or PR comments (it is interesting to know which ones do a decent job).
    As with other contributions, a human is responsible and thanked for the
    quality and content of the change, and is presumed to have the right to
    post that code to be published further under the project's license terms.

  • Especially with involvement of AI, including modern IDE coding aid,
    please be sure to revise that proposed code and documentation changes
    follow NUT code style guide -- this helps portability across the decades
    worth of supported systems. Notably, avoid Unicode characters where ASCII
    text is expected (C sources and headers, manual pages and other acsiidoc
    inputs). Particularly AI is keen on adding mdash characters instead of
    plain ASCII double-dash (which renders into the long dash where applicable).

  • Please star NUT on GitHub, this helps with sponsorships! ;)

Frequent "underwater rocks" for driver addition/update PRs

  • Revised existing driver families and added a sub-driver if applicable
    (nutdrv_qx, usbhid-ups...) or added a brand new driver in the other
    case.

  • Did not extend obsoleted drivers with new hardware support features
    (notably blazer and other single-device family drivers for Qx protocols,
    except the new nutdrv_qx which should cover them all).

  • For updated existing device drivers, bumped the DRIVER_VERSION macro
    or its equivalent.

  • For USB devices (HID or not), revised that the driver uses unique
    VID/PID combinations, or raised discussions when this is not the case
    (several vendors do use same interface chips for unrelated protocols).

  • For new USB devices, built and committed the changes for the
    scripts/upower/95-upower-hid.hwdb file

  • Proposed NUT data mapping is aligned with existing docs/nut-names.txt
    file. If the device exposes useful data points not listed in the file, the
    experimental.* namespace can be used as documented there, and discussion
    should be raised on the NUT Developers mailing list to standardize the new
    concept.

  • Updated data/driver.list.in if applicable (new tested device info)

Frequent "underwater rocks" for general C code PRs

  • Did not "blindly assume" default integer type sizes and value ranges,
    structure layout and alignment in memory, endianness (layout of bytes and
    bits in memory for multi-byte numeric types), or use of generic int where
    language or libraries dictate the use of size_t (or ssize_t sometimes).
  • Progress and errors are handled with upsdebugx(), upslogx(),
    fatalx() and related methods, not with direct printf() or exit().
    Similarly, NUT helpers are used for error-checked memory allocation and
    string operations (except where customized error handling is needed,
    such as unlocking device ports, etc.)

  • Coding style (including whitespace for indentations) follows precedent
    in the code of the file, and examples/guide in docs/developers.txt file.

  • For newly added files, the Makefile.am recipes were updated and the
    make distcheck target passes.

General documentation updates

  • Added a bullet point into NEWS.adoc, possibly also UPGRADING.adoc
    if there is something packagers or custom-build users should take into
    account (new driver categories, configuration options, dependencies...)

  • Updated docs/acknowledgements.txt (for vendor-backed device support)

  • Added or updated manual page information in docs/man/*.txt files
    and corresponding recipe lists in docs/man/Makefile.am for new pages

  • Passed make spellcheck, updated spell-checking dictionary in the
    docs/nut.dict file if needed (did not remove any words -- the make
    rule printout in case of changes suggests how to maintain it).

Additional work may be needed after posting this PR

  • Propose a PR for NUT DDL with detailed device data dumps from tests
    against real hardware (the more models, the better).

  • Address NUT CI farm build failures for the PR: testing on numerous
    platforms and toolkits can expose issues not seen on just one system.

  • Revise suggestions from LGTM.COM analysis about "new issues" with
    the changed codebase.

Drain stale interrupt reports before issuing a command for the Cypress 0665:5161 transport, and use a longer reply timeout for this device quirk. This allows Voltronic-QS autodetection for a VOLT Polska RackUPS 1200VA/720W.

Related to networkupstools#2534.

Signed-off-by: pixi-p <pixip@o2.pl>
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

A ZIP file with standard source tarball and another tarball with pre-built docs for commit ee102b7 is temporarily available: NUT-tarballs-PR-3563.zip.

@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.5037-master completed (commit e10a35c67a by @pixi-p)

@pixi-p

pixi-p commented Aug 10, 2026

Copy link
Copy Markdown
Author

The Jenkins failure happens while loading the trusted Jenkins pipeline/library from master:
“Version override not permitted for library jenkins-dynamatrix”.

This PR does not modify Jenkinsfiles or CI configuration, so this appears unrelated to the submitted change.

@jimklimov jimklimov added USB Qx protocol driver Driver based on Megatec Q<number> such as new nutdrv_qx, or obsoleted blazer and some others Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) labels Aug 11, 2026
@jimklimov jimklimov added this to the 2.8.6 milestone Aug 11, 2026
@jimklimov

Copy link
Copy Markdown
Member

Yes, a Jenkins plugin update renamed a configuration toggle so it defaulted to not allowing the feature we use there, should be fixed now, will restart the build.

…gured via `ups.conf` [networkupstools#3563]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…kupstools#3563]

Clarified impact of `cypress`/`cypress_0665_5161_subdriver` subdriver fix on deployments and provided workaround instructions.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…etworkupstools#3563]

Clarified impact of `cypress`/`cypress_0665_5161_subdriver` subdriver fix on deployments and provided workaround instructions.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@AppVeyorBot

Copy link
Copy Markdown

@jimklimov

Copy link
Copy Markdown
Member

Resolving some other hiccups on CI farm after upgrades of several nodes last week...

@AppVeyorBot

Copy link
Copy Markdown

Build nut 2.8.5.5044-master completed (commit dafdf3ddf1 by @jimklimov)

@AppVeyorBot

Copy link
Copy Markdown

@jimklimov

Copy link
Copy Markdown
Member

Errors from FreeBSD worker are transient, not related to this PR (some Makefile/asciidoc bug that only happens there).
Errors from OmniOS worker are due to some missed step in recent upgrade, not related to this PR too.

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

Labels

Incorrect or missing readings On some devices driver-reported values are systemically off (e.g. x10, x0.1, const+Value, etc.) Qx protocol driver Driver based on Megatec Q<number> such as new nutdrv_qx, or obsoleted blazer and some others USB

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants