问题描述
在DEMO中,设备为VCI_USBCAN2,在调试中,不断地在同一个点出现ExecutionEngineException异常,百思不得其解,希望高手给予解答异常排除点在len=(int)CANApi.VCI_Receive(this.mDeviceType,this.mDeviceIndex,this.mCANIndex,refframeInfos[0],1000,200);程序:privatevoidReceiveDataProc(){intlen=0;CANApi.VCI_ERR_INFOerrInfo=newCANApi.VCI_ERR_INFO();errInfo.Passive_ErrData=newbyte[3];CANApi.VCI_CAN_OBJ[]frameInfos=newCANApi.VCI_CAN_OBJ[50];try{while(true){Thread.Sleep(10);if(!this.mConnected)break;len=0;len=(int)CANApi.VCI_Receive(this.mDeviceType,this.mDeviceIndex,this.mCANIndex,refframeInfos[0],1000,200);if(len<=0){//注意:如果没有读到数据则必须调用此函数来读取出当前的错误码,//千万不能省略这一步(即使你可能不想知道错误码是什么)CANApi.VCI_ReadErrInfo(this.mDeviceType,this.mDeviceIndex,this.mCANIndex,referrInfo);}else{for(inti=0;i<len;i++){if(i>=frameInfos.Length)break;CANApi.VCI_CAN_OBJframe=frameInfos[i];//FrameIDstringframeID=string.Format("{0:X8}",frame.ID);//TimeStampstringtimeStamp=string.Empty;if(frame.TimeFlag==0){timeStamp="无";}else{timeStamp=string.Format("{0:X8}",frame.TimeStamp);}//FrameFormatstringframeFormat=string.Empty;if(frame.RemoteFlag==0){frameFormat="数据帧";}else{frameFormat="远程帧";}//FrameTypestringframeType=string.Empty;if(frame.ExternFlag==0){frameType="标准帧";}else{frameType="扩展帧";}//Datastringdata=string.Empty;if(frame.RemoteFlag==0){StringBuildersbData=newStringBuilder();for(intj=0;j<frame.DataLen;j++){if(frame.Data.Length<=j)break;sbData.AppendFormat("{0:X2}",frame.Data[j]);}data=sbData.ToString();}this.NotifyReceiveFrame(newFrameInfo(frameID,timeStamp,frameFormat,frameType,data));}}}}catch(Exceptionee){Console.WriteLine(ee.Message);}}