アプリケーション用の CAN Dll プログラムを別に使用しました。Drivers プログラムをアプリケーション Program に含めましたが、このエラーが発生していますSystem Access Violation Exception:Attempted to read or write protected memory
。エラーとは何ですか?このエラーをスローしている Dll コードとアプリケーション コードを添付しています。
CAN Dll コード
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;
}
}
}
したがって、このプログラムは正常にビルドされ、実行中にエラーが発生します
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).