GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — kraken3: match HID responses to the requests that asked for them by creativeheadz · Pull Request #916 · liquidctl/liquidctl

Conversation

@creativeheadz

@creativeheadz creativeheadz commented Jul 22, 2026

Copy link
Copy Markdown

The problem

_write_then_read() returns whatever report arrives next, with no check that it answers the command just sent:

def _write_then_read(self, data):
    self._write(data)
    return self._read()

Two things routinely leave other reports in the queue: several call sites send with a bare _write() and never consume the reply, and the device also emits unsolicited status reports.

The two meet inside _send_data():

self._write([0x36, 0x02])          # end transfer — reply left queued
if not self._switch_bucket(...):   # reads that leftover instead

so _switch_bucket() decides success from byte 14 of the stale 0x37 0x02. Tracing every exchange of a single set lcd screen static on a Kraken 2023 Elite (1e71:300c, firmware 1.1.0, Linux):

ok        cmd=0x32 0x01  expected=0x33 0x01  got=0x33 0x01  byte14=0x01
ok        cmd=0x36 0x01  expected=0x37 0x01  got=0x37 0x01  byte14=0x01
MISMATCH  cmd=0x38 0x01  expected=0x39 0x01  got=0x37 0x02  byte14=0x01

That byte happened to be 0x01, so the bucket switch reported success without having been verified at all.

_query_buckets() reads the same blind way, and because all sixteen queries answer 0x31 0x04, a single misread shifts the entire table — _get_bucket_memory_offset() then sizes a transfer using another bucket's address. In one capture the table came back as b0@1507+8995 followed by every subsequent entry displaced by one slot.

The user-visible symptom is an LCD push that reports success and does not display, intermittently, with no error on any path — which makes it look like a panel quirk rather than a driver bug.

The fix

Clear the queue before sending, then check the prefix of what comes back.

The clear is what actually fixes it. The prefix check is a backstop and cannot by itself disambiguate replies that share a prefix, as the bucket queries do — worth stating explicitly, since prefix matching alone looks sufficient and is not.

Reads that find no matching report fall back to the first report read, preserving the previous behaviour rather than raising.

Tests

Added a regression test that queues a stale 0x37 0x02 whose byte 14 reads as success, ahead of a genuine 0x39 0x01 reporting failure, and asserts _switch_bucket() returns False. It fails on main with assert True is False and passes with this change.

This required making the mock faithful: it previously answered bucket-setup and bucket-switch with a zeroed reply[0:2] header that no real device sends, so those paths could not be tested at all. Prefixes are now set for the bucket-setup, bucket-switch, bucket-query and data-transfer commands.

Full suite: 518 passed, 2 skipped (both pre-existing). black --check clean.

Scope

Independent of #915 and branched from main, so the two can land in either order. #915 needs a malformed serial descriptor to bite; this one affects every Kraken Z and Elite, since _write_then_read() is unvalidated for all of them.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@creativeheadz
kraken3: match HID responses to the requests that asked for them
dead814
_write_then_read() returns whatever report arrives next, without checking
that it answers the command just sent.  Two things routinely leave other
reports in the queue: several call sites send with a bare _write() and never
consume the reply, and the device also emits unsolicited status reports.

The two meet inside _send_data(), which ends a transfer with

    self._write([0x36, 0x02])          # reply left queued
    if not self._switch_bucket(...):   # reads that leftover instead

so _switch_bucket() takes byte 14 of the stale 0x37 0x02 as the switch
result.  Observed on a Kraken 2023 Elite (1e71:300c), firmware 1.1.0, while
tracing every exchange of one push:

    MISMATCH  cmd=0x38 0x01  expected=0x39 0x01  got=0x37 0x02  byte14=0x01

That byte happened to be 0x01, so the switch reported success without having
been verified at all.  _query_buckets() reads the same blind way, and since
all sixteen queries answer 0x31 0x04, one misread shifts the whole table and
_get_bucket_memory_offset() then sizes a transfer from another bucket's
address.  The symptom is an LCD push that reports success and does not
display, intermittently and with no error on any path.

Clear the queue before sending, and check the prefix of what comes back.
The clear is what fixes it; the prefix check is a backstop, and cannot by
itself disambiguate replies that share a prefix, as the bucket queries do.
Reads that find no matching report fall back to the first report read, which
preserves the previous behaviour rather than raising.

The mock grew reply prefixes for the bucket-setup, bucket-switch,
bucket-query and data-transfer commands, which it previously answered with a
zeroed header that no real device sends.
@giggio

giggio commented Jul 27, 2026

Copy link
Copy Markdown

I just want to give my 2c.
I pulled both this patch and #915 together 2 days ago into my liquidctl installation and my Kraken 3 Elite is working much better. The device's screen would go black and it would cause issues that are not happening anymore.
I did not review the code, but behaviorally it is working much better.

creativeheadz reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lukas-shawford lukas-shawford mentioned this pull request Sep 17, 2026
Failed to switch active bucket" error on NZXT Kraken Elite 2024 LCD update #774
Open

This branch has not been deployed

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@creativeheadz @giggio
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.