Git Product home page Git Product logo

Comments (14)

jeffglancy avatar jeffglancy commented on July 19, 2024 1

My workaround is to catch the error for every event.
try:
kbd.press(key)
except OSError:
This prevents the RP2040 from crashing while the PC is asleep with the downside of not waking the PC.

from adafruit_circuitpython_hid.

dhalbert avatar dhalbert commented on July 19, 2024

Try inserting a delay of a few seconds before creating the Keyboard() object. Internally, the constructor has a delay: it tries once, and if that fails, it tries again, after waiting one second, but that may not be enough.

# Do a no-op to test if HID device is ready.
# If not, wait a bit and try once more.
try:
self.release_all()
except OSError:
time.sleep(1)
self.release_all()

from adafruit_circuitpython_hid.

dillondriskill avatar dillondriskill commented on July 19, 2024

I see whats going on.

I also see now that this was mentioned in #93 and #15

Would it be possible to put this try/except statement in a while loop and break if it succeeds?

from adafruit_circuitpython_hid.

dillondriskill avatar dillondriskill commented on July 19, 2024

So I've done some tests on my side, and found some interesting results...

I was intent on solving the issue at the root, so I downloaded the source and downloaded mpy-cross and made the edit I suggested in the previous comment, and still nothing changed.

After some trial and error with that, I decided to just do what you said and add a sleep(10) before I initialize the keyboard, and yet the issue persists. I do believe that still putting the while loop may fix this issue in some instances, however I do not believe that is the issue here.

from adafruit_circuitpython_hid.

dhalbert avatar dhalbert commented on July 19, 2024

Yes, this could be a Windows sleep issue, somehow we are not recovering properly from that. I feel it also used to work for me (I have a Trinket M0 connected as a volume control), and sometimes I see problems now, but it's on Linux. I will try some experiments on Windows.

from adafruit_circuitpython_hid.

dillondriskill avatar dillondriskill commented on July 19, 2024

Interesting. During my testing on my mac and windows machine i found that the issue would happen on windows both when I tell it to sleep from the power menu, or if it goes to sleep from being idle, whereas i was unable to replicate the issue on my M1 MacBook Air.

from adafruit_circuitpython_hid.

isacben avatar isacben commented on July 19, 2024

This is also happening to me with a KB2040 with CircuitPython on a MacBook Pro. I built the keyboard as a Split keyboard, with two KB2040 connected with a TRRS cable.

I will try to experiment as well on a fix!

from adafruit_circuitpython_hid.

dillondriskill avatar dillondriskill commented on July 19, 2024

@isacben any ideas? Have been AFK for a while, but looking to resolve this issue

from adafruit_circuitpython_hid.

jeffglancy avatar jeffglancy commented on July 19, 2024

I have the same issue with a RP2040 as a custom USB keyboard controller. The keyboard will wake the PC from sleep, but then stops working and additionally hangs the computer for a while or gives a BSOD (driver power state failure or DPC watchdog violation). If I unplug the RP2040 device before putting the PC to sleep I have no issues.
CircuitPython 7.3.2, Windows 11

from adafruit_circuitpython_hid.

Xitee1 avatar Xitee1 commented on July 19, 2024

Aren't there any fixes/workarounds yet? I'm having the same problem.

from adafruit_circuitpython_hid.

Xitee1 avatar Xitee1 commented on July 19, 2024

My workaround is to catch the error for every event. try: kbd.press(key) except OSError: This prevents the RP2040 from crashing while the PC is asleep with the downside of not waking the PC.

Thank you, that did work perfectly.

from adafruit_circuitpython_hid.

dslrcnc avatar dslrcnc commented on July 19, 2024

My workaround is to catch the error for every event.
try:
kbd.press(key)
except OSError:
This prevents the RP2040 from crashing while the PC is asleep with the downside of not waking the PC.

Thanks for the solution. I am having the same problem but before applying the code the rp2040 wasn't able to wake up the PC. were you able to wake up your PC sending the keyboard.press before caching the error?

from adafruit_circuitpython_hid.

jeffglancy avatar jeffglancy commented on July 19, 2024

Thanks for the solution. I am having the same problem but before applying the code the rp2040 wasn't able to wake up the PC. were you able to wake up your PC sending the keyboard.press before caching the error?

It would wake the PC some of the time, but then often hang Windows with a BSOD, and the RP2040 would require a reboot.

from adafruit_circuitpython_hid.

dhalbert avatar dhalbert commented on July 19, 2024

We have an open issue for this: it's something to do in the CircuitPython core: adafruit/circuitpython#5380

from adafruit_circuitpython_hid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.