UDS Client Sample Project DLL problem in Visual studio 2017

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
Shail
Posts: 49
Joined: Tue 28. Apr 2020, 10:09

UDS Client Sample Project DLL problem in Visual studio 2017

Post by Shail » Tue 28. Apr 2020, 13:15

Hello,

we are using PCAN-UDS.lib in sample project PCAN UDS (C++)API Package.
(1) How to make use of PCAN-UDS.dll in visual studio 2017?
Stpes already tried to make use of dll :
(1) Right Click on PCAN_Client Solution.
Configuration Properties -> General -> Additional directories -> Path of DLL Added
(2) Right Click on PCAN_Client Solution.
Configuration Properties -> Linker-> input-> Additional dependencies-> Path of DLL Added
Configuration Properties -> Linker -> General -> Additional Library directories-> Path of DLL Added

Still We are Not able to make use of PCAN-UDS.dll.

(2) How we can import DLL Library ? Please provide steps using example.
When I am using this way DLL = LoadLibrary(_T("PCAN-UDS.dll?")); We are getting hrReturnVal = ERROR_DELAY_LOAD_FAILED.

(3) How we can use external(3rd party) DLL xxxx.dll with PCAN UDS project in visual studio 2017?
We only need to call function from external dll to main project PCAN UDS

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

Re: UDS Client Sample Project DLL problem in Visual studio 2017

Post by M.Heidemann » Tue 28. Apr 2020, 14:39

Hello,

Thank you for your request:

1)
Make sure that you copied the correct architecture of the dlls in SysWOW64 and System32, on a 64 bit Windows it will be:
- System32: copy the x64 dlls,
- SystemWOW64: copy the Win32 dlls.

Also check if both PCANBasic and the PCAN-ISO TP API are both correctly installed.

2) and 3) Bot of these questions are related to development concepts in C++. You should read up on them online.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Shail
Posts: 49
Joined: Tue 28. Apr 2020, 10:09

Re: UDS Client Sample Project DLL problem in Visual studio 2017

Post by Shail » Wed 29. Apr 2020, 15:02

Hello,

Thanks for reply.

PCANBasic and the PCAN-ISO TP API are both correctly installed.
we have put dlls in SysWOW64 and System32, on a 64 bit Windows it will be:
- System32: copy the x64 dlls,
- SystemWOW64: copy the Win32 dlls.

1) Can u tell where we need to placed PCAN-UDS.dll?
2) Example how to use UDS_Initialize function using PCAN-UDS.dll?

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

Re: UDS Client Sample Project DLL problem in Visual studio 2017

Post by M.Heidemann » Wed 29. Apr 2020, 16:26

Hello,


Did you have a look at the examples supplied with the PCAN_UDS-API?

If yes, do you use one of these as a basis?


You could have a look at /SAMPLES/PCAN-UDS/C++/PCUCLIENT/PCUClient.cpp:

It includes the PCAN-UDS Header file for c++

Code: Select all

#include "PCAN-UDS.h"
UDS_Initialize used in line 1176

Code: Select all


	// Set the PCAN-Channel to use (PCAN-USB Channel 1)
	Channel = PUDS_USBBUS1;
	// Initializing of the UDS Communication session 
	Status = UDS_Initialize(Channel, PUDS_BAUD_250K, 0, 0, 0);
	printf("Initialize UDS: %i\n", (int)Status);

	// Define Address
	iBuffer = PUDS_SERVER_ADDR_TEST_EQUIPMENT;
	Status = UDS_SetValue(Channel, PUDS_PARAM_SERVER_ADDRESS, &iBuffer, 1);
	printf("  Set ServerAddress: %i (0x%02x)\n", (int)Status, iBuffer);
	// Define TimeOuts
	ulBuffer = 2000;
	Status = UDS_SetValue(Channel, PUDS_PARAM_TIMEOUT_REQUEST, &ulBuffer, sizeof(ulBuffer));
	printf("  Set TIMEOUT_REQUEST: %i (%d)\n", (int)Status, ulBuffer);
	Status = UDS_SetValue(Channel, PUDS_PARAM_TIMEOUT_RESPONSE, &ulBuffer, sizeof(ulBuffer));
	printf("  Set TIMEOUT_REQUEST: %i (%d)\n", (int)Status, ulBuffer);
	waitGetch();

	// Define Network Address Information used for all the tests
	N_AI.SA = PUDS_SERVER_ADDR_TEST_EQUIPMENT;
	N_AI.TA = PUDS_ISO_15765_4_ADDR_ECU_1;
	N_AI.TA_TYPE = PUDS_ADDRESSING_PHYSICAL;
	N_AI.RA = 0x00;
	N_AI.PROTOCOL = PUDS_PROTOCOL_ISO_15765_2_11B;
	
may you could tell me, what exactly you need to do in case i misunderstand your request.


Best Regards


Marvin
---
Marvin Heidemann
PEAK-Support Team

Shail
Posts: 49
Joined: Tue 28. Apr 2020, 10:09

Re: UDS Client Sample Project DLL problem in Visual studio 2017

Post by Shail » Wed 29. Apr 2020, 18:19

Hello,

(1) Did you have a look at the examples supplied with the PCAN_UDS-API? : Yes
(2) If yes, do you use one of these as a basis?
You could have a look at /SAMPLES/PCAN-UDS/C++/PCUCLIENT/PCUClient.cpp:
Yes. Same one

may you could tell me, what exactly you need to do in case i misunderstand your request.
In same example PCUClient.cpp code using PCAN-UDS.lib as library.

AS Check by Configuration Properties-> General->linker->Input-> Additional Dependencies->Libs\x64\PCAN-UDS.lib;%(AdditionalDependencies)

(3) Que: In placed of PCAN-UDS.lib how we can make use of only PCAN-UDS.dll?
What are the changes required to make use of PCAN-UDS.dll?
is not possible or not supported to only make use of PCAN-UDS.dll?

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

Re: UDS Client Sample Project DLL problem in Visual studio 2017

Post by M.Heidemann » Thu 30. Apr 2020, 09:38

Hello,

You cannot use the .lib as a library.

the .lib file contains a list of the exported functions and data elements from the library and to which DLL they are associated. When the linker builds the final executable then if anything from the library is used then the linker adds a reference to the DLL and adds entries to the executables import table so that calls to the referenced functions is redirected to the DLL.

It is not required to use a .lib file to use a DLL, but without it you'll not be able to use functions from the DLL as regular functions in your code. In this case you have to manually call LoadLibrary to load the DLL.
You will need to use GetProcAddress to get the address of the function or data item in the DLL. You must then cast the returned address to an appropriate pointer-to-function in order to use it.
(Use FreeLibrary to free the loaded library afterwards).

If you want to use the .DLL exclusively in the example you will have the change the whole code accordingly, that means everytime a data item or a function of the library is used you`ll need to manually load the library, get the adress of the data item or function in that DLL, the returned address needs to be cast as the right pointer-to-function. Then free the loaded library once you are done with it.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Post Reply