英文:
Etas dll NULL pointer exception
问题
以下是代码部分的中文翻译:
from can.interfaces.etas import EtasBus
if __name__ == "__main__":
channels = EtasBus._detect_available_configs()
for entry in channels:
print("{channel}".format(**entry))
这是用于创建 .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" "<脚本路径>run.py"
在运行二进制文件时,我遇到以下错误消息:
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
英文:
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
答案1
得分: 1
I had the same issue and found a solution now.
In (your env)\Lib\site-packages\can\interfaces\etas\boa.py
, it tries to load the DLLs "dll-csiBind" and "dll-ocdProxy" with the path "C:\Program Files\ETAS\BOA_V2\Bin\x64\Dll\Framework" first. Additionally, it tries to load the DLLs with a path when the file is not 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 the original boa.py
, it loads the DLLs without a path and raises a NULL pointer access error. In this case, CSI_CreateProtocolTree
is not working.
You can remove the "try" block and let it load the DLLs with the 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.
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论