SAE J2534_1_2004 code template

Pass-Thru API and connection of Pass-Thru software to PEAK CAN interfaces.
Post Reply
MrDPotter
Posts: 4
Joined: Wed 6. Nov 2019, 20:03

SAE J2534_1_2004 code template

Post by MrDPotter » Wed 6. Nov 2019, 22:12

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).

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: SAE J2534_1_2004 code template

Post by M.Heidemann » Thu 7. Nov 2019, 08:59

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
---
Marvin Heidemann
PEAK-Support Team

MrDPotter
Posts: 4
Joined: Wed 6. Nov 2019, 20:03

Re: SAE J2534_1_2004 code template

Post by MrDPotter » Thu 7. Nov 2019, 20:55

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);
Last edited by K.Wagner on Fri 8. Nov 2019, 08:53, edited 1 time in total.
Reason: Code formatting for better reading

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: SAE J2534_1_2004 code template

Post by PEAK-Support » Fri 8. Nov 2019, 08:13

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://learn.microsoft.com/en-us/windo ... ic-linking
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

MrDPotter
Posts: 4
Joined: Wed 6. Nov 2019, 20:03

Re: SAE J2534_1_2004 code template

Post by MrDPotter » Thu 14. Nov 2019, 16:37

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

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: SAE J2534_1_2004 code template

Post by PEAK-Support » Fri 15. Nov 2019, 08:23

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.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

Post Reply