pythonauto-py-to-exe

Etas dll NULL pointer exception


I do have a problem with the following code when converting it to an .exe.

from can.interfaces.etas import EtasBus


if __name__ == "__main__":
    channels = EtasBus._detect_available_configs()
    for entry in channels:
        print("{channel}".format(**entry))

Running it from the console works fine.

This is the command for my .exe:

pyinstaller --noconfirm --onefile --windowed --add-binary "C:/Program Files/ETAS/BOA_V2/Bin/x64/Dll/Framework/dll-csiBind.dll;." --add-binary "C:/Program Files/ETAS/BOA_V2/Bin/x64/Dll/Framework/dll-ocdProxy.dll;." --paths "C:/Program Files/ETAS/BOA_V2/Bin/x64/Dll/Framework"  "<Path-to-script>run.py"

Running the binary I do get this error message:

Traceback (most recent call last):
  File "run.py", line 5, in <module>
  File "can\interfaces\etas\__init__.py", line 312, in _detect_available_configs
  File "can\interfaces\etas\__init__.py", line 300, in _findNodes
ValueError: NULL pointer access

Solution

  • I had same issue and find something now.

    In (your env)\Lib\site-packages\can\interfaces\etas\boa.py It try load dll("dll-csiBind", "dll-ocdProxy") with path("C:\Program Files\ETAS\BOA_V2\Bin\x64\Dll\Framework") first, and additionally try load dll with path when file not be found.

    try:
        # try to load libraries from the system default paths
        _csi = ctypes.windll.LoadLibrary("dll-csiBind")
        _oci = ctypes.windll.LoadLibrary("dll-ocdProxy")
    except FileNotFoundError:
        # try to load libraries with hardcoded paths
        if ctypes.sizeof(ctypes.c_voidp) == 4:
            # 32 bit
            path = "C:/Program Files (x86)/ETAS/BOA_V2/Bin/Win32/Dll/Framework/"
        elif ctypes.sizeof(ctypes.c_voidp) == 8:
            # 64 bit
            path = "C:/Program Files/ETAS/BOA_V2/Bin/x64/Dll/Framework/"
        _csi = ctypes.windll.LoadLibrary(path + "dll-csiBind")
        _oci = ctypes.windll.LoadLibrary(path + "dll-ocdProxy")
    
    

    When I build and run with original boa.py, it load dll without path and raise NULL pointer access error. In this case, CSI_CreateProtocolTree is not working.

    You can remove "try" and let it load dll with hardcoded path in boa.py

    if ctypes.sizeof(ctypes.c_voidp) == 4:
        # 32 bit
        path = "C:/Program Files (x86)/ETAS/BOA_V2/Bin/Win32/Dll/Framework/"
    elif ctypes.sizeof(ctypes.c_voidp) == 8:
        # 64 bit
        path = "C:/Program Files/ETAS/BOA_V2/Bin/x64/Dll/Framework/"
    _csi = ctypes.windll.LoadLibrary(path + "dll-csiBind")
    _oci = ctypes.windll.LoadLibrary(path + "dll-ocdProxy")
    

    In my case it works with pyinstaller and pyside6.