Unhandled exception, access violation writing location

0

I'm writing a program in C++ using Visual Studio 2012. The program requires two devices to be connected to it: a pressure sensor and driver that controls a motorized platform. The program worked fine when I wrote all the driver code in main. The motors moved and the pressure sensor indicated the value. However, I wanted to simplify the program and apply objects/classes to make it neater and more manageable. I'm using a .lib and a .dll file, and for whatever reason, when I started to use objects, the program didn't like calling the functions from an object.

This is the error I get:

"Unhandled exception at 0x1000AAD2 (Ldcnlib.dll) in motors.exe: 0xC0000005: Access violation writing location 0x00000025."

I'm thinking maybe I have my #includes wrong? But I can't figure it out. I've provided by project folder Motors.rar if anyone cares to look. If you do, the program runs until

if((!driverA.setParameter()) || (!driverB.setParameter()) || (!driverC.setParameter()))

in main. Debugging, I find the problem occurs exactly at

int Driver::setParameter(){ 
   if(!StepSetParam(PicoAddr, Mode, MinSpeed, RunCurrent, HldCurrent, ADLimit, EmAcc))  
      return 0;
}

in driver.cpp.

I took that code out of main, and I get the same problem further down when I try to call .loadTraj. If I try to do the !StepSetParam directly in main, bypassing the class, same error.

(EDIT: It probably goes without saying, but the program won't work at all because you don't have the necessary devices connected to the COM ports, but I hope someone can help just by looking) Code: Main stdafx.h driver.h driver.cpp stepper.h

c++
exception
access-violation
unhandled-exception
asked on Stack Overflow Jul 17, 2012 by Robert Joseph Dacunto • edited Dec 15, 2017 by Vadim Kotov

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0