kawasaki / pyscrlink

Scratch-link for Linux written in python
BSD 3-Clause "New" or "Revised" License
120 stars 24 forks source link

Unicode decode error #32

Open antoine56100 opened 2 years ago

antoine56100 commented 2 years ago

Hi kawasaki, I'm having trouble trying to link my EV3 to Scratch in Firefox on my Ubuntu desktop. Everything works fine but running scan the terminal indicates the following error

antoine@aldebaran:~$ scratch_link 2022-07-09 15:52:49,216 Certificate is ready in FireFox NSS DB: /home/antoine/.mozilla/firefox/weuf2nuw.default 2022-07-09 15:52:49,222 Certificate is ready in FireFox NSS DB: /home/antoine/.mozilla/firefox/weuf2nuw.default 2022-07-09 15:52:49,323 Certificate is ready for Chrome 2022-07-09 15:52:49,345 Started scratch-link 2022-07-09 15:52:57,703 Start session for web socket path: /scratch/bt Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner self.run() File "/home/antoine/.local/lib/python3.10/site-packages/pyscrlink/scratch_link.py", line 212, in run self.discover() File "/home/antoine/.local/lib/python3.10/site-packages/pyscrlink/scratch_link.py", line 189, in discover discoverer.find_devices(lookup_names=True) File "/home/antoine/.local/lib/python3.10/site-packages/bluetooth/bluez.py", line 434, in find_devices _bt.hci_filter_all_events (flt) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 4: invalid start byte

Any idea ? Best regards, Antoine

kawasaki commented 2 years ago

@antoine56100 Thanks for the report. Unfortunately, this issue looks difficult to resolve. It means that pyscrlink is not working for EV3 now. The error was reported by pybluez, but it is not well maintained (I don't have much time to maintain pyscrlink recently, either). Certain amount of issues are reported for pybluez but they are not resolved.

Maybe pyscrlink should stop relying on pybluez. I'm not sure if I can allocate my time to purge pybluez from pyscrlink and switch to other newer bluetooth python library.

As a memorandom, here I note what I observed. I tried Bluetooth device search on my system, and I observed similar, but different error.

$ scratch_link
2022-07-16 12:00:22,270 Certificate is ready in FireFox NSS DB: /home/shin/.mozilla/firefox/nnysaloj.default
2022-07-16 12:00:22,739 Certificate is ready in FireFox NSS DB: /home/shin/.mozilla/firefox/nnysaloj.default/chrome_debugger_profile
2022-07-16 12:00:22,759 Certificate is ready for Chrome
2022-07-16 12:00:22,803 Started scratch-link
2022-07-16 12:02:55,435 Start session for web socket path: /scratch/bt
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/shin/.local/lib/python3.10/site-packages/pyscrlink/scratch_link.py", line 212, in run
    self.discover()
  File "/home/shin/.local/lib/python3.10/site-packages/pyscrlink/scratch_link.py", line 189, in discover
    discoverer.find_devices(lookup_names=True)
  File "/usr/lib/python3.10/site-packages/bluetooth/bluez.py", line 433, in find_devices
    flt = _bt.hci_filter_new ()
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

I also tried to install pybluez again, but failed to install pybluez from pip.

$ sudo pip install pybluez
Collecting pybluez
  Using cached PyBluez-0.23.tar.gz (97 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in PyBluez setup command: use_2to3 is invalid.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

This means that, pyscrlink really needs fixes.