Page 1 of 1

Buffer overrun exception

Posted: Fri 3. Jul 2015, 10:30
by lingfors
I try to use PCAN-UDS using MS Visual Studio 2013 on Windows. However, I get a buffer overrun exception after calling UDS_Initialize:
bufferoverrun.png
bufferoverrun.png (23.18 KiB) Viewed 7875 times
I have tried other versions of Visual Studio, with the same result.

I get the same buffer overrun exception if I try to run the PCUClient sample project.

I have successfully used PCAN-Basic and PCAN-ISO-TP.

Minimum application to trigger the exception (based on example code from the manual):

Code: Select all

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include "PCAN-UDS.h"

int main( void )
{
  UDS_Initialize(PUDS_USBBUS1, PUDS_BAUD_500K);

  while( true );

  return 0;
}
What am I doing wrong?

Re: Buffer overrun exception

Posted: Mon 6. Jul 2015, 08:46
by PEAK-Support
Please use our Demo and study the Documentation.

Calling

Code: Select all

UDS_Initialize(PUDS_USBBUS1, PUDS_BAUD_500K);
is not the problem...
but

Code: Select all

  while( true );
mhhh..no comment....

Re: Buffer overrun exception

Posted: Mon 6. Jul 2015, 09:28
by lingfors
U.Wilhelm wrote:Please use our Demo and study the Documentation.
If you are going to give an answer like this, at least take the time to read my entire post. Especially this part:
I get the same buffer overrun exception if I try to run the PCUClient sample project.
The code

So, tell me. What is the problem with the PCUClient project?

Or this code:

Code: Select all

#include <Windows.h>

#include "PCAN-UDS.h"

int main( void )
{
  TPUDSStatus result;
  // The Plug & Play Channel (PCAN-USB) is initialized
  result = UDS_Initialize(PUDS_USBBUS1, PUDS_BAUD_500K);

  if (result != PUDS_ERROR_OK)
  {
    MessageBox(NULL, "Initialization failed", "Error", MB_OK);
  }  
  else
  {
    MessageBox(NULL, "PCAN-USB (Ch-1) was initialized", "Success", MB_OK);
  }
  
  // All initialized channels are released
  UDS_Uninitialize(PUDS_NONEBUS);
}
Same problem.

Re: Buffer overrun exception

Posted: Mon 6. Jul 2015, 09:59
by PEAK-Support
Are you sure you use the correct DLL? You know .Net Applications use the DLL depending of the used OS (32/64) if you did not change it in project workspace.

Re: Buffer overrun exception

Posted: Mon 6. Jul 2015, 10:11
by K.Wagner
Hello,

Using VS2008, VS2010, and VS2012 did not show any problems in our test system. Unfortunatelly we don't have VS2013.

Are you using the libraries in 64-Bit plattform? It is possible that one or more dlls are in the wrong place (System32 and/or SysWOW64).

We can check one plattform an see if the problem is there. Please try the following:
  • Open the project PCUClient and check its configuration (Visual Studio Menu/ Build/Configuration manager)
  • Check that the Project PCUClient plattform is set to Win32
  • Compile the project
  • Create a new folder, Test32, anywhere
  • Copy in Test32 the dlls PCANBasic.dll, PCAN-ISO-TP.dll, adn PCAN-UDS.dll from their respective Win32 folders (downloaded package of each API).
  • Copy in Test32 the compiled PCUClient.exe and start it. Do you see the problem there too?
If the problem persists please let us know the following information:
  • Operating System and plattform being used
  • Version of each API being used
  • A zip with a minimalistic project that shows the problem