KarlHlmgrn / crypto-oled

Crypto price graph for Steelseries Apex Pro/7/5 OLED display
MIT License
7 stars 0 forks source link

Running from WSL #1

Open tolsadus opened 3 years ago

tolsadus commented 3 years ago

Hello Karl,

Would it be possible to make it run from the WSL, or does it need to be done only directly from W10 ?

KarlHlmgrn commented 3 years ago

That is a good question I haven't tested it on anything other than W10. It could cause compatibility issues when trying to connect to the HID but I'm not quite sure. It would be really nice if you could test it and then send me the error codes if there are any.

tolsadus commented 3 years ago

Well it seems that it just doesn't find any devices, so...

➜  crypto-oled git:(main) ✗ python3.7 crypto-graphing.py 
No devices found, exiting.

I've been trying (also) to install the https://github.com/libusb/hidapi but without any success in W10. (see below) Much easier to do on Debian 👍

%systemroot%\SysWoW64\regsvr32 C:\path\to\x64\hidapi.dll

Gives the following

The module hidapi.dll was loaded but the entry-point DllRegisterServer was not found.
Make sure that hidapi.dll is a valid DLL or OCX file and then try again.

Would love to know how did you managed to do so? Even adding the .dll (the x86) directly in C:\Windows\System32 the python script you wrote can't load due to error 0xc1

KarlHlmgrn commented 3 years ago

Which keyboard do you use?

tolsadus commented 3 years ago

https://www.amazon.fr/gp/product/B07XLNX4ZN - SteelSeries Apex 7

tolsadus commented 3 years ago

If you have Apex Pro TKL or Apex 7 please give me the VID and PID which can be found in device manager and I will add it in the next version.

Ok just read that on the readme.

KarlHlmgrn commented 3 years ago

Please post them here and I will happily add it to the code!

tolsadus commented 3 years ago

Not sure however which PID should be used.

https://imgur.com/a/Y4Unuhr

(Top left = first one in the list Top right = second Bottom left = third Bottom right = fourth)

KarlHlmgrn commented 3 years ago

I think it's the top one. I will commit an update with that VID and PID making Apex 7 compatible!

KarlHlmgrn commented 3 years ago

Test the new code I committed and see if it works.

tolsadus commented 3 years ago

Still No devices found, exiting. but that's not a surprise since lsusb doesn't return anything from the WSL. (maybe due to the virtualization that microsoft is doing?)

Let me see if I can find a way to load/add that hidapi library 👍

KarlHlmgrn commented 3 years ago

I'm so sorry you're having this problem, I am not quite experienced with WSL but I will gladly help you if you need further help!

KarlHlmgrn commented 3 years ago

Do you have hidapi.dll in the same directory as where you are running the code from?

tolsadus commented 3 years ago

Yeah no worries. I was trying to play around with it since I usually like it better to run stuff contained directly from the WSL. (more like safety measure?)

-- easyhid (Windows also needs hidapi.dll which you can fetch from: https://github.com/libusb/hidapi/releases)

How did you installed the .dll and .lib files on your machine? The latest release doesn't seem to work.

Yes, still nothing. (with x64 and x86)

OSError: cannot load library 'hidapi.dll': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'hidapi.dll'

Only difference is if I just plain copy/paste the .ddl in system32, but I just get an error saying that the lib can't load due to error 0xc1

KarlHlmgrn commented 3 years ago

You don't have to install the .dll to System32 it just has to be in the same directory as you're running the script from.

tolsadus commented 3 years ago
PS C:\Users\tolsadus\Desktop\crypto-oled-main> ls

    Directory: C:\Users\tolsadus\Desktop\crypto-oled-main

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         3/28/2021  12:51 AM                x64
d-----        11/24/2020   1:45 PM                x86
-a----         3/28/2021  11:23 AM           7609 crypto-graphing.py
-a----         3/27/2021  10:31 AM        1951812 get-pip.py
-a----        11/24/2020   1:45 PM          95744 hidapi.dll
-a----        11/24/2020   1:45 PM           5790 hidapi.lib
-a----        11/24/2020   1:45 PM        2912256 hidapi.pdb
-a----          3/8/2021  12:19 PM           1067 LICENSE
-a----          3/8/2021  12:19 PM         217276 OpenSans-Regular.ttf
-a----          3/8/2021  12:19 PM           1433 README.md

PS C:\Users\tolsadus\Desktop\crypto-oled-main> python -V
Python 3.9.2

PS C:\Users\tolsadus\Desktop\crypto-oled-main> pip list
Package         Version
--------------- ---------
certifi         2020.12.5
cffi            1.14.5
chardet         4.0.0
cycler          0.10.0
easyhid         0.0.10
hidapi          0.10.1
idna            2.10
keyboard        0.13.5
kiwisolver      1.3.1
matplotlib      3.4.0
numpy           1.20.1
Pillow          8.1.2
pip             21.0.1
pycparser       2.20
pyparsing       2.4.7
python-dateutil 2.8.1
pytz            2021.1
requests        2.25.1
six             1.15.0
urllib3         1.26.4
wheel           0.36.2

PS C:\Users\tolsadus\Desktop\crypto-oled-main> python .\crypto-graphing.py
Traceback (most recent call last):
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\easyhid\easyhid.py", line 53, in <module>
    hidapi = ffi.dlopen('hidapi.dll')
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: cannot load library 'hidapi.dll': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'hidapi.dll'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\tolsadus\Desktop\crypto-oled-main\crypto-graphing.py", line 5, in <module>
    from easyhid import Enumeration
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\easyhid\__init__.py", line 8, in <module>
    from easyhid.easyhid import *
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\easyhid\easyhid.py", line 55, in <module>
    hidapi = ffi.dlopen(ctypes.util.find_library('hidapi.dll'))
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "C:\Users\tolsadus\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\cffi\api.py", line 821, in _load_backend_lib
    raise OSError("dlopen(None) cannot work on Windows for Python 3 "
OSError: dlopen(None) cannot work on Windows for Python 3 (see http://bugs.python.org/issue23606)```

Sorry I went to bed it was quite late on my timezone. That doesn't seems to work either?

KarlHlmgrn commented 3 years ago

Hmmm, I would really like to help you but this seems more like a problem with hidapi. The last thing I could think of is trying to place the files in the same directory as the Python executable.