10000 get_last_received_report() always return None when use a USB HUB · Issue #10373 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

get_last_received_report() always return None when use a USB HUB #10373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
meng89 opened this issue May 25, 2025 · 4 comments
Open

get_last_received_report() always return None when use a USB HUB #10373

meng89 opened this issue May 25, 2025 · 4 comments
Labels
Milestone

Comments

@meng89
Copy link
meng89 commented May 25, 2025

CircuitPython version and board name

CircuitPython 9.2.7, rpi pico rp2040

Code/REPL

class RGBLockStatus(LockStatus):
    def set_lock_leds(self):
        if self.get_caps_lock():
            print("Never print this when use a USB HUB")

    def after_hid_send(self, sandbox):
        super().after_hid_send(sandbox)
        print("always None when use a USB HUB: ", self.hid.get_last_received_report())
        if self.report_updated:
            self.set_lock_leds()

Behavior

pass

Description

No response

Additional information

I use KMK as the firmware for the keyboard I made, but when I use a USB HUB, the Caps Lock light will not synchronize with other keyboards. The other two manufacturers' keyboards I tested can synchronize the Caps Lock light when using USB HUB. I read the definition of Class LockStatus and did some tests and found that get_last_received_report() always returns None when using USB HUB.
The above code is just a test code, please forgive me for not knowing how to trim KMK to minimize the executable code.

@meng89 meng89 added the bug label May 25, 2025
@samblenny
Copy link

There have been a lot of USB improvements between CircuitPython 9.2.7 and 10.0.0-alpha.6. Does anything change if you try your code with CircuitPython 10.0.0-alpha.6?

If you want to try writing a minimal program to reproduce the problem in CircuitPython (without KMK), these guides talk about how to use the usb_hid library:

@meng89
Copy link
Author
meng89 commented May 27, 2025

The problem persists when using CircuitPython 10.0.0-alpha.6. The simple test code is as follows:

# code.py
# While this code is running, press the Caps Lock key on another keyboard once a second and observe if the output is different.


import time
import usb_hid

while True:
    time.sleep(1)
    print()
    for device in usb_hid.devices:
        x = device.get_last_received_report()
        print(x)

After doing some tests, I found that this problem only occurs when this USB HUB is connected to the USB port on the front panel of the computer. Even if the HUB connected to my monitor in the middle, there will still be problems.

But when I plug the USB HUB into the USB port on the back of the computer and a laptop, there is no problem.

The strange thing is that the keyboard produced by another manufacturer works normally no matter how it is connected.

I will find a different USB HUB and test it again.

@dhalbert
Copy link
Collaborator

@meng89 Try adding a delay of several seconds before the while True loop of several seconds, to give time for USB enumeration.

@meng89
Copy link
Author
meng89 commented May 27, 2025

After inserting time.sleep(10) before the while true loop, the problem still exists.

@dhalbert dhalbert added this to the 10.0.0 milestone May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
0