jnweiger / led-name-badge-ls32

Upload tool for an led name tag with USB-HID interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[featurerequest] cross-platform support?!

s-light opened this issue · comments

idea: would be nice to have a easy way (for a normal end-user) to install this cross-platform.

this is a collection of things i found during my search & how it could work -
all untested yet...

libusb

currently the script uses libusb to access the HID-Device.
its easy to install for linux but a little bit harder for Mac OS or windows:
(as fare as i found - please proof me wrong?! ;-) )

  • Linux (Ubuntu or other debian based...)
    simple as sudo apt install python3-usb (as written in the current instructions)
    this installs libusb and pyusb (info from package description)
  • macOS
    according to this answer libusb should be working with Homebrew
    brew install libusb
    additionally we need pyusb: pip3 install pyusb
  • Windows
    there is a libusb Windows WikiPage that tells us that there are Binary Snapshots as 7zip in the releases
    but these just containing the dlls - no installer:
    image
    so we need to copy theme to the correct location so the
    pyusb lib can find them?! (i have no clue 🙈 )

there is libusb at pypi (github) that states:

Requirements
It is fully independent package.
All necessary things are installed during the normal installation process.
ATTENTION: currently works and tested only for Windows.

and yes- if you look at the source it includes the dll.
but as mentioned - only for windows 😿

other option: switch library ?

the libusb FAQ also recommends the HIDAPI library for HID things.
but it seems this lib is a bit in a unmaintained state currently..
on my search i found cython-hidapi as a python API for this. (called hidapi at pypi)
→ this would mean Cython as dependency..
i also found pyhidapi (named hid in pypi)
but installation in osx seems trouble some too...

result

there is no easy to install solution already out there?

hope someone else has better news on this ;-)

Thanks for the research. Please compare with https://github.com/jnweiger/inkscape-silhouette/blob/master/silhouette/Graphtec.py#L30 and the issues in this repo regarding cross platform support.

this comment is just a list / overview of the different python hid packages i found during research:

pypi source apt
hid pyhidapi ?
hidapi cython-hidapi python-hid
hidapi-cffi hidapi-cffi python-hidapi
pyhidapi pyhidapi ?

For windows there is also pywinusb, which can be used like this:

#
#    (install python from python.org)
#      [x] install Launcher for all Users
#      [x] Add Python 3.7 to PATH
#    pip install pywinusb
#
import pywinusb.hid as hid
filter = hid.HidDeviceFilter(vendor_id=0x0416, product_id=0x5020)
dev = filter.get_devices()[0]
print(dev)
dev.open()
report = dev.find_output_reports()[0]
print(report)
buffer= [0x00]*65
buffer[0]=0x0
buffer[1]=0x01
buffer[2]=0x00
buffer[3]=0x01
report.send(buffer)
dev.close()

But the send buffer must be exactly 65 bytes. Probably not raw enough for us.

for a windows and a 'raw' usb version (no special hid library) we could try a ifelse handling with
libusb (source)
it should install all needed things for windows with pip install libusb

pywinusb has a report.set_raw_data() method, but that is still not sufficiently raw. wireshark shows only some parts of my message getting through, with other data intermixed. Not suitable for us.

memo 📝

if packaging is consider: have a look at this stackoverflow question for some options..
likely gets complicated with this hole librarie things...

Commit c47bc9a
should bring in windows10 support.

@AnnabelleLee1987, @s-light The installation procedures on Ubuntu, Mac, and Windows are now all described in the README. None of them are trivial, sorry. Please test, if that gets you going. Thanks!

pyinstaller and py2exe from the stackoverflow link above may help to simplify this. For me the current state seems good enough for now.

Should we close here, or keep this open for reference?

i think we can close this - as the original request is - at least partly - solved.


just some closing thoughts:
currently i think we know that the only way to streamline all this is :

  • get libusb from this repository to include and work cross platform...
  • or write a wrapper similar to libusb but based on the available hid libs...

→ but i don't know if one of this is in any way easy possible..

inf-wizard seems to explode under windows 7, without installing any drivers.

  1. Start als "admin"
  2. <Next>
  3. Choose the entry with "0x0416 0x5020 LS32 Custm HID" + <Next>
  4. Confirm where it says "Vendor ID=0x12AB" + <Next>
  5. <Save>
  6. "Unknown Error: 1" :-(
    ... now the only choice is
  7. <Cancel>