Jump to content
OMRON Forums

Flora

Members
  • Posts

    4
  • Joined

  • Last visited

Flora's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. But I have not received any response yet.
  2. But I have not received any response yet.
  3. I did send the email one week ago, but so far there has been no reply from the group.
  4. I wrote my program using PcommServer based on MFC in Visual Studio 2010. It worked very well until I put the pmacDevice.GetResponseEx into the callback function of timeSetEvent, which is a multi-media timer in winmm.lib. Once it runs to GetResponseEx, exceptions as following will be shown: "First-chance exception at 0x00000000 in ***.exe: 0xC0000005: Access violation reading location 0x00000000." "Unhandled exception at 0x00000000 in ***.exe: 0xC0000005: Access violation reading location 0x00000000." And I add CoInitialize(NULL) in the callback function, it still doesn't work. My question is how to use pmacDevice.GetResponseEx in the timeSetEvent callback function? I attach the code as: timeSetEvent: void CTestDlg::OnBnClickedBtntimer() { TIMECAPS timecaps; UINT wAccuracy_Test,TimerID_Test; if(timeGetDevCaps(&timecaps,sizeof(TIMECAPS))==TIMERR_NOERROR) { wAccuracy_Test= min(max(timecaps.wPeriodMin,1),timecaps.wPeriodMax); timeBeginPeriod(wAccuracy_Test); while (( TimerID_Test = timeSetEvent(1000, wAccuracy_Test,(LPTIMECALLBACK) TestProc, (DWORD)this,TIME_PERIODIC)) == NULL) ;// } } callback function: UINT CTestDlg::TestProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2 ) { CoInitializeEx(NULL); char cmdbuf[255]; BSTR retbuf = ::SysAllocString(L""); BOOL pStatus; ((CTestDlg*)theApp.m_pMainWnd)->pmacDevice.GetResponse(0, "I122=3",FALSE, &retbuf,&pStatus); ::SysFreeString(retbuf); CoUninitialize(); return 0; } Open device: void CTestDlg::OnBnClickedBtnopen() { CoInitialize(NULL); testInterface = pmacDevice.CreateDispatch(_T("PcommServer.PmacDevice.1")); if (!testInterface) { AfxMessageBox("Fail to open library!"); return; } BOOL ret; pmacDevice.SelectDevice(NULL,&m_nDevice,&ret); int pbDriverOpen; pmacDevice.Open(m_nDevice, &pbDriverOpen); if(!pbDriverOpen) { AfxMessageBox("Fail to open Device!"); } else { pmacDevice.GetDPRAvailable(m_nDevice); } }
×
×
  • Create New...