Meka
July 30th, 2005, 03:45 AM
Hi Friends,
Iam new to vc++.
I have fired an event from the thread in the control using
SendMessage();
I am reading data from the USB Device using USBXpress.dll
I fired an event when ever i receive the data from USB Device,And I
want to check the received data in the client side,
I don't know how to catch this event from the client side,and how to check this data in the client...
My thread function follows...
#define WM_THREADFIREEVENT WM_USER+101
ON_MESSAGE(WM_THREADFIREEVENT,FireOnUSBRead)
UINT WorkerThreadProc(LPVOID Param)
{
HWND hwnd=(HWND)Param;
DWORD i=10000;
while(i>1)
{
SI_SetTimeouts( i,10000);
short rbuffer = 0;
DWORD dwbr=1;
DWORD dwbs=0;
SI_STATUS openstatus=SI_SUCCESS;
DWORD d=0;
//To Get Number of Devices Connected
SI_GetNumDevices(&d);
HANDLE m_thUSBDevice = INVALID_HANDLE_VALUE;
for(DWORD j=0;j<d;j++)
{
openstatus=SI_Open(j,&m_thUSBDevice);
}
SI_STATUS r=SI_SUCCESS;
r=SI_Read(m_thUSBDevice,&rbuffer,dwbr,&dwbs);
SI_STATUS fs=SI_FlushBuffers(m_thUSBDevice,0,1);
if(r==SI_SUCCESS && fs==SI_SUCCESS)
{
AfxMessageBox("Success");
SendMessage(hwnd,WM_THREADFIREEVENT,(WPARAM)rbuffer,(LPARAM)NULL);
}
SI_Close(m_thUSBDevice);
i++;
}
return TRUE;
}
void CUSBXPressCtrlCtrl::StartThread()
{
// TODO: Add your dispatch handler code here
AfxBeginThread(WorkerThreadProc,this,THREAD_PRIORITY_LOWEST,0,0,NULL);
}
Please help me....
Regards,
Sindhu
Iam new to vc++.
I have fired an event from the thread in the control using
SendMessage();
I am reading data from the USB Device using USBXpress.dll
I fired an event when ever i receive the data from USB Device,And I
want to check the received data in the client side,
I don't know how to catch this event from the client side,and how to check this data in the client...
My thread function follows...
#define WM_THREADFIREEVENT WM_USER+101
ON_MESSAGE(WM_THREADFIREEVENT,FireOnUSBRead)
UINT WorkerThreadProc(LPVOID Param)
{
HWND hwnd=(HWND)Param;
DWORD i=10000;
while(i>1)
{
SI_SetTimeouts( i,10000);
short rbuffer = 0;
DWORD dwbr=1;
DWORD dwbs=0;
SI_STATUS openstatus=SI_SUCCESS;
DWORD d=0;
//To Get Number of Devices Connected
SI_GetNumDevices(&d);
HANDLE m_thUSBDevice = INVALID_HANDLE_VALUE;
for(DWORD j=0;j<d;j++)
{
openstatus=SI_Open(j,&m_thUSBDevice);
}
SI_STATUS r=SI_SUCCESS;
r=SI_Read(m_thUSBDevice,&rbuffer,dwbr,&dwbs);
SI_STATUS fs=SI_FlushBuffers(m_thUSBDevice,0,1);
if(r==SI_SUCCESS && fs==SI_SUCCESS)
{
AfxMessageBox("Success");
SendMessage(hwnd,WM_THREADFIREEVENT,(WPARAM)rbuffer,(LPARAM)NULL);
}
SI_Close(m_thUSBDevice);
i++;
}
return TRUE;
}
void CUSBXPressCtrlCtrl::StartThread()
{
// TODO: Add your dispatch handler code here
AfxBeginThread(WorkerThreadProc,this,THREAD_PRIORITY_LOWEST,0,0,NULL);
}
Please help me....
Regards,
Sindhu