jnweiger / led-name-badge-ls32

Upload tool for an led name tag with USB-HID interface
GNU General Public License v2.0
223 stars 81 forks source link

[featurerequest] cross-platform support?! #2

Closed s-light closed 5 years ago

s-light commented 5 years ago

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?! ;-) )

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 :crying_cat_face:

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 ;-)

jnweiger commented 5 years ago

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.

s-light commented 5 years ago

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 ? []()
jnweiger commented 5 years ago

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.

s-light commented 5 years ago

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

jnweiger commented 5 years ago

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.

s-light commented 5 years ago

memo :memo:

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

jnweiger commented 5 years ago

Commit https://github.com/jnweiger/led-badge-44x11/commit/c47bc9a03a34f5f15705bbf9c90036bf056b82b0 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.

jnweiger commented 5 years ago

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

s-light commented 5 years ago

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 :

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

jnweiger commented 4 years ago

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

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