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

Space problems with Python 2.7 #9

Closed semaf closed 5 years ago

semaf commented 5 years ago

Hey,

Just want to inform you that the output of the text "Hello World" is "HelloäWorld".

jnweiger commented 5 years ago

Thanks for the report, it works correctly for me with python-3.6.7 both pyhidapi and usb.core Do you have more details? Linux system, python version, installed pyhidapi or usb.core modules?

semaf commented 5 years ago

PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)" NAME="Raspbian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)"

Python 2.7 pyhidapi (0.0.2) pyusb (1.0.0) python-usb (1.0.0-1)

Seems that I am facing also with caching problems. Is not forwarding always the new text.

jnweiger commented 5 years ago

pyhidapi sees not so relible. I added a patch today to make it better. You may also want to try to disable loading of pyhidapi. Either by uninstalling or by misspelling it in the script, then it will fall back to usb.core.

I wonder why python 2.7 works for you at all. I believe one of the latest patches killed the compatibility. This also needs fixing.

semaf commented 5 years ago

Tested without pyhidapi or usb.core has same result. Installed Python 3.6 solved it.

jnweiger commented 5 years ago

Using pyhidapi with python-2.7 explodes for me like this:

Traceback (most recent call last):
  File "led-badge-11x44.py", line 466, in <module>
    pyhidapi.hid_write(dev, buf)
  File "/usr/local/lib/python2.7/dist-packages/pyhidapi/pyhidapi.py", line 638, in hid_write
    buf[n] = data[n]
TypeError: one character string expected

Where data[n] is a plain integer, oh well, it wants a char. that is bad. Workaround: with pyhton-2.7 we always use usb.core

jnweiger commented 5 years ago

the original issue was caused by python-2.7 interpreting our charmap as ascii-bytes. We have to prefix the strings here with u"" to make them python-2.7 compatible.