labelle-org / labelle

Label printing software
Apache License 2.0
27 stars 4 forks source link

Evaluate switching from pyusb to hidapi #17

Closed maresb closed 4 months ago

maresb commented 4 months ago

All the work we currently go through to set up permissions to be able to access the USB device is pretty ridiculous, and I never understood why it should be necessary. It's just a USB device after all!

While messing around on #5, I discovered this SO post saying to use hidapi instead of libusb. There seems to be a canonical Python wrapper here.

It'd be great if we could switch away from libusb and simplify device access.

tomers commented 4 months ago

@maresb doesn't this package also require udev rules configuration? See https://github.com/trezor/cython-hidapi?tab=readme-ov-file#udev-rules

maresb commented 4 months ago

Ah, great catch!

But maybe this would allow things to "just work" on Windows and Mac?

tomers commented 4 months ago

I will try to find some time to try...

tomers commented 4 months ago

I have preliminary work in tshalev-hidapi branch, https://github.com/labelle-org/labelle/tree/tshalev-hidapi. It supposably able to write, but not to read. My Linux machine is currently dead, and I am working in Windows for the mean time. I did not succeed to print in Windows yet. @maresb, it would be nice if you could play with this branch, and try to find what is missing in order to perform a successful print.

maresb commented 4 months ago

Wow, thanks so much for investigating this @tomers!

This week will be extremely busy for me, and using Windows involves me messing around with a virtual machine, so it's neither quick nor easy. Realistically, I won't be able to spend any more time on this until the weekend.

On Windows in order to get pyusb to work I used Zadig and set the driver to WinUSB. Perhaps that's also necessary with hidapi, but then apart from possibly supporting MacOS, it doesn't seem like hidapi offers much benefit. But perhaps Zadig would at least give you a starting point? (It should at least work with pyusb.)

tomers commented 4 months ago

I don't see any point in keeping this effort. Newer Dymo models expose printer USB class, and not HID. I believe HID to be used only by some obsolete models. I guess it would be better to keep existing implementation which can be used in newer models too.

maresb commented 4 months ago

Ah, that's too bad. Thanks a lot for looking into this!!!