I have CAN Dll program for my application, which was separately used. Now I have included the Drivers program into my application Program and I am having this error System Access Violation Exception:Attempted to read or write protected memory
. What is error for? I am attaching the Dll code and Application code which is throwing this error.
The CAN Dll Code
int receive_data(unsigned char *data_output, int *MsgId, XLportHandle g_xlPortHandle){
XLstatus xlStatus, xlStatus_new;
XLevent xlEvent;
unsigned int msgsrx=RECEIVE_EVENT_SIZE;
char *local_data ="11111111";
DWORD status;
xlStatus_new = xlSetNotification(g_xlPortHandle, &h, 1);
WaitForSingleObject(h,1);
xlStatus = XL_SUCCESS;
while(!xlStatus){
msgsrx = RECEIVE_EVENT_SIZE;
xlStatus = xlReceive(g_xlPortHandle, &msgsrx, &xlEvent);---------->Here is the error
if ( xlStatus!=XL_ERR_QUEUE_IS_EMPTY ) {
memcpy(data_output,xlEvent.tagData.msg.data,8);
*MsgId = xlEvent.tagData.msg.id;
return 0;
}
else{
return XL_ERR_QUEUE_IS_EMPTY;
}
}
}
So this program builded successfully and while executing it I am getting the error as
Receive thread quit Unexpectedly
system Access violation Exception:Attempted to read or write protected memory.This is often an indication that other memory is corrupt at
xlreceive(int32,Uint32*,s_xl_event*)
at receive_data(Byte*data_output,int32*MsgId,Int32 g_xlPortHandle).