Skip to content
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

Windows requires byte prepended to data #417

Open
JnyJny opened this issue Nov 26, 2024 · 3 comments
Open

Windows requires byte prepended to data #417

JnyJny opened this issue Nov 26, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@JnyJny
Copy link
Owner

JnyJny commented Nov 26, 2024

Also, as a separate note, I had to deploy on Windows and to make it work I had to send an additional 0 to the devices. Then everything was working; without it the lights were ignoring any commands. I have no idea why it works with the 0.
And I had 2 different devices, a Luxafor ORB and a Kuando, and both behaved the same.

if "WINDOWS" in platform.system().upper():

    def patched_write_strategy(instance: lightslib.Light, data: bytes) -> int:
        data = bytes([0]) + data
        return instance.device.write(data)

    lightslib.Light.write_strategy = patched_write_strategy

Originally posted by @aponoran in #416 (comment)

@JnyJny JnyJny self-assigned this Nov 26, 2024
@JnyJny
Copy link
Owner Author

JnyJny commented Nov 26, 2024

@aponoran I created a new issue to track the Windows extra byte problem.

As I mentioned in #416, we need to preserve the write_strategy property which encodes which write method a device needs: write or send_feature_report. I mentioned making the windows check in the __bytes__ magic method but I think it makes more sense to check for windows in the method: busylight.lights.light.Light.update. I'm going to commit an update in a second with a terrible first pass check for Windows.

JnyJny added a commit that referenced this issue Nov 26, 2024
I added a check to the method `busylight.lights.light.Light.update`
that prepends a zero byte to the bytes object that will be sent to
a device if the current platform is Windows. This is necessary because
the Windows HID API requires a report ID to be sent with the data and
the underlying hidapi library doesn't seem to handle this for us on Windows
but does handle it on Linux and macOS.
@JnyJny JnyJny added the bug Something isn't working label Nov 29, 2024
@JnyJny
Copy link
Owner Author

JnyJny commented Nov 29, 2024

Possible fix for #87 and #56.

@aponoran
Copy link

aponoran commented Dec 1, 2024

I tested on Windows with the above commit and everything works fine! Used a Luxafor ORB and a Kuando Omega.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants