Fail to initialization PCAN-ISO-TP.dll (ver 3.4) in Python

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)
Post Reply
Godel
Posts: 4
Joined: Tue 25. Apr 2023, 07:14

Fail to initialization PCAN-ISO-TP.dll (ver 3.4) in Python

Post by Godel » Tue 2. May 2023, 08:36

Hi all,

I am trying to wrap PCAN-ISO-TP.dll (ver 3.4) into LabVIEW VIs on the Win10 environment.
There is a language construct called "call library function node" in LabVIEW responsible for loading and interfacing dll.
The "call library function node" fails to load PCAN-ISO-TP.dll (ver 3.4) but succeeds to load PCAN-ISO-TP.dll (ver 2.2).
The PCANBasic.dll, the dependency of PCAN-ISO-TP.dll, is placed in the same folder.

Then, I executes the Python sample code "07_classic_can_read_write" (Python 3.10.11 64bit interpreter) on Visual Studio Code.
The same thing happened.
Ver 3.4 fails to initialization, but initialization of Ver 2.2 is ok.
Fail to Initialize PCAN-ISO-TP.dll (ver 3.4).png
Fail to Initialize PCAN-ISO-TP.dll (ver 3.4).png (333.93 KiB) Viewed 5797 times
The PCAN-ISO-TP.dll (ver 3.4) and PCANBasic are put inside System32.
I also tried to put them inside a local folder and invoked them from the local folder, but everything is the same.

Any suggestion on or further experiment for resolving this problem?

Thank you for any help you can provide.

Godel

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Fail to initialization PCAN-ISO-TP.dll (ver 3.4) in Python

Post by K.Wagner » Tue 2. May 2023, 08:57

Hello,

we do not work with LabVIEW so we cannot give much help on this, but it seems like you may be mixing the x86 and x64 bit libraries. As you are using Python 64-Bit, then you should assert that you are using the x64 version of the dlls (PCAN-ISO-TP.dll and PCANBasic.dll). You can see this by showing the details of the file properties on the dlls. In the decription of the file you will see if it is the x86 or x64 version.
Best regards,
Keneth

Godel
Posts: 4
Joined: Tue 25. Apr 2023, 07:14

Re: Fail to initialization PCAN-ISO-TP.dll (ver 3.4) in Python

Post by Godel » Tue 2. May 2023, 09:14

Hi Wagner,

I am quite sure that the two x64 version dlls (PCAN-ISO-TP.dll (ver3.4) and PCAN-Basic.dll (ver4.3)) are put inside System32.
And Python fails to initialization.

Godel

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Fail to initialization PCAN-ISO-TP.dll (ver 3.4) in Python

Post by K.Wagner » Tue 2. May 2023, 11:51

Hello,

please note that the current version of PCAN-ISO-TP offers support for Python v2.7 and v3.8.
PCAN-ISO_TP_Python.PNG
PCAN-ISO_TP_Python.PNG (9.5 KiB) Viewed 5788 times
Please try with a version of Python equals or older than v3.8.
Last edited by K.Wagner on Tue 2. May 2023, 11:52, edited 1 time in total.
Reason: Extract of the Python header file of PCAN-ISO-TP
Best regards,
Keneth

Godel
Posts: 4
Joined: Tue 25. Apr 2023, 07:14

Re: Fail to initialization PCAN-ISO-TP.dll (ver 3.4) in Python

Post by Godel » Wed 3. May 2023, 04:56

Hi,

Testing on Python 3.8.10 64bit, and result is the same. (Antivirus is turned off.)
Test on Python 3.8.10 64bit.png
Test on Python 3.8.10 64bit.png (274.83 KiB) Viewed 5777 times

K.Wagner
Software Development
Software Development
Posts: 1080
Joined: Wed 22. Sep 2010, 13:36

Re: Fail to initialization PCAN-ISO-TP.dll (ver 3.4) in Python

Post by K.Wagner » Wed 3. May 2023, 13:55

Hello again,

we have tested the PCAN-ISO-TP example "07_classic_can_read_write" on a clean Windows 11 PC, using the latest PCAN-ISO-TP and having installed the latest device drivers and PCAN-Basic API (using the PEAK-Drivers Setup) and also installed the latest Python version, v3.11.3, and with some adjusment we were able to successfully run the sample.

First of all, it seems there is a change in the way how external library paths are resolved, beginning with Python v3.8, as described in the article "DLL not found after switching from Python 3.7.6 to Python 3.10.3" from stackoverflow. Moreover, a new function was included to handle with library paths, os.add_dll_directory. The help of it states:
.
DLL_Loading.PNG
DLL_Loading.PNG (37.1 KiB) Viewed 5766 times

The sample ran by removing the PCAN-ISO-TP.dll from the project folder and copying it into the WIndows\System32 folder. Note that the PEAK-Drivers Setup also copies the needed PCAN-Basic.dll into this folder. Having these two libraries in this folder the sample application works as expected.

You mentioned alraedy, that you are copying the files in the WIndows\System32 folder, so this workaround may not work for you, and you may be experimenting a different or additional problem we are not aware of. Unfortunatelly, we cannot reproduce this. Do you have the possibility to test this using a different PC?
Best regards,
Keneth

Post Reply