Python example?

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)
Locked
ValeV
Posts: 24
Joined: Mon 17. Dec 2018, 10:35

Python example?

Post by ValeV » Mon 17. Dec 2018, 11:03

Hi,
is there any example of using ISO-TP API in Python? I am not familiar with C#, C++ and VB.

For PCAN-BASIC there is Python example, so I'd expect there is one for ISO-TP as well.

I am looking for a simple sample to show how to initiate(), send() and receive() messages, just to get me started.

Cheers,
ValeV

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

Re: Python example?

Post by K.Wagner » Mon 17. Dec 2018, 11:10

Hello,

no, sorry, there is no example on python for this since there is no any PCAN-ISO-TP python unit. If you want to use PCAN-ISO-TP API with python you will need to start first by writing a wrapper to import and use all ISO-TP functions.
Best regards,
Keneth

ValeV
Posts: 24
Joined: Mon 17. Dec 2018, 10:35

Re: Python example?

Post by ValeV » Mon 17. Dec 2018, 12:33

I see, thank you for replying. Would you be willing ti assist me with starting writing a wrapper? Or maybe it's unrelated to PEAK systems.

First I try to load DLL:

Code: Select all

from ctypes import *
mydll = cdll.loadLibrary("C:\\Users\\M0097932\\Desktop\\python app\\PCAN-ISO-TP.dll")
which gives me error "OSError: [WinError 126] The specified module could not be found". Are you familiar with this problem? I googled it, but didn't find any simple solution.

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

Re: Python example?

Post by K.Wagner » Mon 17. Dec 2018, 12:44

Hello,

yes, this problem is not related to PEAK-System. Check the PCANBasic.py, it can be used as sample for your own wrapper. Otherwise, look in internet for "Using DLL from Python"; there are plenty of samples for it.
ValeV wrote:Are you familiar with this problem? I googled it, but didn't find any simple solution.
you are using cdll. This is needed for importing functions with cdecl calling convention. Since all our APIs use the stdcall convention, you have to import the library with WinDLL. (see Loading dynamic link libraries)
Best regards,
Keneth

ValeV
Posts: 24
Joined: Mon 17. Dec 2018, 10:35

Re: Python example?

Post by ValeV » Wed 9. Jan 2019, 08:13

Sorry I didn't write back. Ofcourse I fixed the problem, as you described, I should have used windll.

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

Re: Python example?

Post by K.Wagner » Wed 9. Jan 2019, 08:28

Thanks for the feedback. Closed.
Best regards,
Keneth

Locked