Skip to content

WHB04 reconnects and drops paired STOP/RESET input on unknown button codes #668

Description

@righteousgambit

Controller version

develop at 2ea66c10e96d88013a04441134d3d4f8e8c88510. This is controller-side pendant handling; firmware is not involved in the failure.

Reproduction

Feed the WHB04 parser one valid eight-byte packet containing a valid safety/action button in either button slot and an unknown nonzero value in the other slot:

packet = struct.pack(
    "BBBBBBbB",
    0x04,
    0,
    Button.STOP.value,  # RESET reproduces it too
    0xFF,               # unknown/transient value
    StepSize.LEAD.value,
    Axis.OFF.value,
    0,
    0,
)
daemon._process_input_packet(packet)

The same result occurs with the two button slots reversed.

Expected

Ignore the unknown button value, preserve the valid button from the same packet, and dispatch its callback without cycling the pendant connection.

Actual

Both nonzero bytes are converted directly to Button enum members. Button(0xFF) raises ValueError before callbacks are dispatched, so the valid STOP/RESET value in the same packet is dropped. In the live device loop that exception reaches the generic retry handler, closes the current HID guard, reports a disconnect, and reconnects.

The parser already tolerates transient unknown rotary-axis and step-selector values, but not unknown button values: button parsing, device-loop propagation, retry/reconnect handler.

Impact

One malformed, noisy, or transient button byte can produce a visible pendant disconnect/reconnect and can discard a valid STOP or RESET indication paired in that report. This report demonstrates the controller failure deterministically; it does not claim a particular hardware frequency.

Regression proof

A four-case test matrix covers STOP and RESET with the unknown value in each slot. Against the pinned base it fails all four cases with ValueError: 255 is not a valid Button.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions