Page 1 of 1

SAE J2534_1_2004 code template

Posted: Wed 6. Nov 2019, 22:12
by MrDPotter
Do you have any examples of the constructs needed
to access the PassThruAPI functions using C or C++, using Visual Studio 2019?

Also, what is the proper project setup to be able to find the .dll without necessarily having to store it in
the directory where .exe file is.
I can copy the PCAN basic C++_MFC examples and get it to run using the PCAN basic .dll.


Do I have to extract the basics out of those examples and figure out how to create the PassThrough version?
I have a copy of the SAE J2534 specifications (both 2004 and 2015 versions).

Re: SAE J2534_1_2004 code template

Posted: Thu 7. Nov 2019, 08:59
by M.Heidemann
Hello,

We do not offer examples for the PassThru-API due to the fact that our API is mainly intended to enable communication with our hardware with already existing software.

You can aquire the necessary information in our documentation for the PassThru-API, which you can read here:

https://www.peak-system.com/produktcd/P ... an_eng.pdf

You can also refer to your SAE J2534 specifications for further information.
Also, what is the proper project setup to be able to find the .dll without necessarily having to store it in
the directory where .exe file is.
You dont need to configure this, if you use the setup of the PassThru-API the necessary files will be accessible to your project.
Do I have to extract the basics out of those examples and figure out how to create the PassThrough version?
You could use the PCANBasic-Example as a basis for a PassThru-API application, yes.

Best Regards

Marvin

Re: SAE J2534_1_2004 code template

Posted: Thu 7. Nov 2019, 20:55
by MrDPotter
I have tried to follow your Pass-Thru API document, and the J2534 _1 2004 standard document; However,
I still get linker errors.

Below are two different ways I tried to declare the function prototypes,
and 3 different ways that tried to implement the PassThruOpen function.
I still get linker errors.
I use the PCANPT32.dll from:
C:\Program Files (x86)\PEAK-System\PCAN-PassThru API\64, and Visual Studio 2019
LINK1120 1 unresolved externals
LNK2019 unresolved external symbol "unsigned long __cdecl PassThruOpen(void *,unsigned long *)" (?PassThruOpen@@YAKPEAXPEAK@Z) referenced in function main project3 D:\PCAN\PCAN programs\C_programs\project3\project3\test_code.obj 1
Below are 2 different trials of function prototype declarations and 3 different trials to implement the function call:

//Example 1 function prototype

Code: Select all

extern "C" long WINAPI PassThruOpen
(
	void *pName,
	unsigned long *pDeviceID
);
/// Example 2 function prototye

Code: Select all

TPCANStatus __stdcall PassThruOpen
(
	void* pName,
	unsigned long *pDeviceID
);
//3 different attempts to call open function

Code: Select all

OpenResponse = PassThruOpen( NULL, &deviceID);
//OpenResponse = PassThruOpen(&pName, &deviceID);
//OpenResponse = PassThruOpen("J2534-2:PEAK 0x51", &deviceID);

Re: SAE J2534_1_2004 code template

Posted: Fri 8. Nov 2019, 08:13
by U.Wilhelm
You need to add the *.lib to your project to get the DLL linked to your code - or use LoadLibrary(..) and then for every function GetProcAdress(...) see Microsoft Documentation how to use standard DLLs in own Projects.
see https://docs.microsoft.com/es-mx/window ... ic-linking

Re: SAE J2534_1_2004 code template

Posted: Thu 14. Nov 2019, 16:37
by MrDPotter
Thanks for the information. :!:

I found the following link very useful. For using the Peak DLL you can obviously fast forward past the
section on creating the DLL.
https://docs.microsoft.com/en-us/cpp/bu ... ew=vs-2019

Re: SAE J2534_1_2004 code template

Posted: Fri 15. Nov 2019, 08:23
by U.Wilhelm
Your link is more for people who want to create a own DLL - my link is for people who want to use a already developped DLL in a C/C++ environment. As i wrote in C/C++ you also could simply add the LIB (created with your development environment using the DLL) to your project and use the static linking of a DLL.