���}������ͨӍ���̆��} ����67573���Pע�^���� |
---|
![]() bingdongcha |
1�� ��Ϣ | ���� | �]�� |
![]() ![]() ![]() ![]() |
����ͨӍ���̆��} ![]() DWORD WINAPI CCESerial::ReceiveThreadFunc(LPVOID lparam) {
CCESerial *lpSerial = (CCESerial*)lparam;
DWORD dwEvtMask, dwReadError;
COMSTAT
cmStat;
ULONG nWillLen;
SetCommMask( lpSerial->m_hSer, EV_RXCHAR|EV_ERR );
for( ; ; )
{
printf( "WRITE WRITE WRITE WRITE CHAR \r\n"); /************************************************************************************************ //
if( WaitCommEvent( lpSerial->m_hSer, &dwEvtMask, NULL ) ) //
{ //
SetCommMask( lpSerial->m_hSer, EV_RXCHAR|EV_ERR ); //
// get how many data available in receive buffer //
if( dwEvtMask & EV_RXCHAR ) //
{ //
ClearCommError( lpSerial->m_hSer, &dwReadError, &cmStat );
//ȡ���Ք����L����Ϣ //
nWillLen = cmStat.cbInQue; //
if( nWillLen <=0 ) //
continue; // //
lpSerial->m_lDatLen = 0; //
ReadFile( lpSerial->m_hSer, lpSerial->DatBuf, nWillLen, &lpSerial->m_lDatLen, 0 ); //
//
if( lpSerial->m_lDatLen>0 ) //
{ //
// �{�û��{����̎�����յ��Ĕ��� //
lpSerial->OnReceive( ); //
} //
} //
else if( dwEvtMask & EV_ERR ) //
{ //
// ���e�`��־ //
ClearCommError( lpSerial->m_hSer, &dwReadError, &cmStat ); //
lpSerial->OnError( ); //
} // //
} // //
if( WaitForSingleObject( lpSerial->m_hKillRxThreadEvent, 0 ) == WAIT_OBJECT_0) //
{ //
SetEvent( lpSerial->m_hReceiveCloseEvent ); //
break; //
} *************************************************************************************************/
}
return 0; } ��߅�@������ ����ѭ�h��ӡ�����ǰ�עጵIJ��ִ��_��ֻ���\��һ�δ�ӡ�������Ǿ���ֻ�\����һ�Ρ� ��if( WaitCommEvent( lpSerial->m_hSer, &dwEvtMask, NULL ) )�O�Ô��c����ͣ��Ҳ���܆β��\�С����β�Ҳֱ�Ӿ͆����ˡ� �Ǻ�WaitCommEvent( lpSerial->m_hSer, &dwEvtMask, NULL ) �@���������Pϵô���� ���ڴ��_�r������ͨ�ŷ�ʽ-��������ʽ���_�ġ� m_hComm = CreateFile( szPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
// ����ͨ�ŷ�ʽ-��������ʽ �����и��õķ������F�ھ��̃Ȍ��F�հl��������Ҫ����ѭ�hʽͨӍҎ�s�� [���N���ѽ���������2013-5-21 22:39:56���^]
|
�������� | ���� | �؏� ![]() |
![]() lqk |
2�� ��Ϣ | ���� | �]�� |
![]() ![]() ![]() ![]() |
![]()
WINCE��֧���دBI/Oģʽ�����Բ���ʹ��FILE_FLAG_VOERLAPPED������
WaitCommEvent���������ȴ��������ա� ͨӍҎ�sһ���й̶��ĸ�ʽ����Ҫ����ͨӍҎ�s�����Ք����ڱ��ؾ���̎����Ȼ��������Ք����ăȺˣ��������đ���
|
�������� | ���� | �؏� ![]() |
![]() bingdongcha |
3�� ��Ϣ | ���� | �]�� |
![]() ![]() ![]() ![]() |
![]() �F�����@�ӌ��F�ģ��Ѵ��a�N������ͯЬ�����Խ��b�����B�������¡����^�m������ ���Ҏ�sѭ�h�l��CDT���ģ����ڛ]�����دBI/Oģʽ�����̆���ǰ�Ȱl��һ���ֹ����|�lEV_TXEMPTY�¼����Ժ�Ϳ���ѭ�h�l���ˣ������Д�����r��Ҳ���Խ���̎���� ����һ��Sleep();�����������ĕ��п��D������Sleep();�@������һֱ���\�У���֪���L�r�g�\�Ќ����������Ƿ����Ӱ푡����r�yԇ�]��Ӱ푣�����Sleep();����ˡ� DWORD WINAPI CDTSend(PVOID lparam) {
PVOID lpflag;
lpflag = lparam;
DWORD
dwEvtMask, dwReadError;
COMSTAT
cmStat;
ULONG
nWillLen;
unsigned char buf = 0xff;
BOOL
bReadStatus;
cdt_tx0.OpenPort(CDTA_Port,CDTA_Bate,CDTA_Pn,8,1);
SetCommMask(cdt_tx0.m_hComm, EV_RXCHAR|EV_ERR|EV_TXEMPTY);
cdt_tx0.WritePort(&buf,1);
while(TRUE)
{
// �������ڕr�g һֱ�ȴ��¼��l����
if(WaitCommEvent(cdt_tx0.m_hComm, &dwEvtMask, NULL))
{
SetCommMask(cdt_tx0.m_hComm, EV_RXCHAR|EV_ERR|EV_TXEMPTY);
if( dwEvtMask & EV_RXCHAR )
{
printf( "CDT_TX0 RECV RECV SUCCESS \r\n");
ClearCommError( cdt_tx0.m_hComm, &dwReadError, &cmStat );
//ȡ���Ք����L����Ϣ
nWillLen = cmStat.cbInQue;
// cbInQue����ʾ���վ��_�^�д惦�Ĵ�ReadFile�xȡ���ֹ�����
// cbOutQue����ʾ�l�;��_�^�д惦�Ĵ��l�͵��ֹ�����
if( nWillLen <=0 )
continue;
cdt_tx0.RecvLen = 0;
bReadStatus = ReadFile(cdt_tx0.m_hComm, cdt_tx0.AcceBuf, nWillLen, &cdt_tx0.RecvLen, NULL);
if(cdt_tx0.RecvLen > 0)
cdt_tx0.Acces(cdt_tx0.AcceBuf,cdt_tx0.RecvLen);
}
if(dwEvtMask & EV_TXEMPTY)
{
cdt_tx0.WritePort(cdt_tx0.SendBuf,cdt_tx0.SendLen);
}
else if(dwEvtMask & EV_ERR)
{
// ���e�`��־
ClearCommError(cdt_tx0.m_hComm, &dwReadError, &cmStat);
}
} //
Sleep(99);
// ���̒���r�g99MS �{�ȕr�g1MS ���������\�Еr�g100MS
}
return 0; }
|
�������� | ���� | �؏� ![]() |
![]() lqk |
4�� ��Ϣ | ���� | �]�� |
![]() ![]() ![]() ![]() |
![]()
�����Ľ��պͰl����ȫ�����Ƀɂ����́��քe��ɣ����҂��Wվ����һƪ����RS485�����ϵ�yDL645�f�hҎ�s�Č��F����http://www.huochepiao123.com.cn/article/article2009326.html����������һ�����Ӆ�����
�����ҪԴ�a��Ո�����]�䡣
|
�������� | ���� | �؏� ![]() |
![]() bingdongcha |
5�� ��Ϣ | ���� | �]�� |
![]() ![]() ![]() ![]() |
![]()
�҂�Ҳ��645Ҏ�s��
gyangchina@163.com�@���ҵ��]�䣬���x����Դ�a�� �f�ָ��x����
|
�������� | ���� | �؏� ![]() |
![]() lqk |
6�� ��Ϣ | ���� | �]�� |
![]() ![]() ![]() ![]() |
![]()
�����Ѱl�����]�䣬Ո���ա�
|
�������� | ���� | �؏� ![]() |