Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pcommserver in timeSetEvent
#1
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);
}
}
Reply
#2
Please contact our technical support group for help on this issue at: support@deltatau.com.
Reply
#3
(10-06-2014, 10:57 AM)steve.milici Wrote: Please contact our technical support group for help on this issue at: support@deltatau.com.

I did send the email one week ago, but so far there has been no reply from the group.
Reply
#4
and the response would be good to post here for others to learn from....
Reply
#5
(10-10-2014, 07:12 AM)MClement Wrote: and the response would be good to post here for others to learn from....

But I have not received any response yet.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)