亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? serialcomm.asp

?? 這是一個關于手機短信的源代碼,是用Java語言編寫的代碼.
?? ASP
?? 第 1 頁 / 共 3 頁
字號:
      <pre>threadFn...

	WaitCommEvent(m_hCommPort,&amp;dwEventMask, &amp;ov) ;
	if ( WaitForSingleObject(ov.hEvent,INFINITE) == WAIT_OBJECT_0)
	{	
		char szBuf[100];
		memset(szBuf,0,sizeof(szBuf));
		do
		{
			ReadFile( hPort,szBuf,sizeof(szBuf),&amp;dwBytesRead,&amp;ov);
		}while (dwBytesRead &gt; 0 );	
	}	</pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">ReadFile API has following signature:<br>
</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#DADADA">
  <tr>
    <td width="100%">
      <pre><font face="Verdana" size="2">BOOL ReadFile( HANDLE<i> <a class="synParam" onclick="showTip(this)" href>hFile</a></i>, // handle to file 
</font>		<font face="Verdana" size="2">LPVOID<i> <a class="synParam" onclick="showTip(this)" href>lpBuffer</a></i>, // data buffer 
		DWORD<i> <a class="synParam" onclick="showTip(this)" href>nNumberOfBytesToRead</a></i>, // number of bytes to read 
		LPDWORD<i> <a class="synParam" onclick="showTip(this)" href>lpNumberOfBytesRead</a></i>, // number of bytes read 
		LPOVERLAPPED<i> <a class="synParam" onclick="showTip(this)" href>lpOverlapped</a></i> // overlapped buffer );</font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana"><br>
<br>
The first parameter is as usual the com port, the last parameter is the
overlapped structure. Again we need to create a manual reset event and pass the
overlapped structure to the ReadFile function. Again if you issue a read for say
10 bytes and there is no data available , ReadFile will return FALSE and
GetLastError() will return ERROR_IO_PENDING and the system will set the
overlapped event when the overlapped operation(read ) completes.&nbsp;<br>
As you can see ReadFile returns dwBytesRead which as is clear returns the number
of bytes read. If there are no bytes remaining, the dwBytesRead will return 0.
Lets say there are 11 bytes that have arrived and you read 10&nbsp; characters
in the first go in while loop. In the first go 10 characters will be returned in
dwBytesRead. In the second go with while loop, the dwBytesRead will return 1.
Now in the third go the dwBytesRead will return 0 and you will break out of the
while loop. This allows you to read all the data. In this approach ,if you
noticed,we never really took advantage of the overlapped structure that we
passed to the ReadFile function but we still need to pass it because we opened
the COM port in Overlapped manner.<br>
<br>
<br>
And finally when you want to send data to other device, you need to call
WriteFile. WriteFile is not even worth discussing.<br>
<br>
<br>
There is one more thing that needs to be taken into account before we move on
and that is communication <b>timeouts</b>. Its important to set the timeout to
proper values for things to work. The API to do so is:&nbsp;
</font></p>
<p><font size="2" face="Verdana">SetCommTimeouts ( HANDLE hCommPort,
LPCOMMTIMEOUTS lpCommTimeOuts)<br>
<br>
<br>
&nbsp;COMTIMEOUTS is a structure with following members:<br>
</font></p>
<table border="0" cellspacing="1" width="70%" bgcolor="#DADADA">
  <tr>
    <td width="100%">
      <pre class="syntax"><font face="Verdana" size="2">typedef struct _COMMTIMEOUTS {  
  DWORD <a class="synParam" onclick="showTip(this)" href>ReadIntervalTimeout</a>; 
  DWORD <a class="synParam" onclick="showTip(this)" href>ReadTotalTimeoutMultiplier</a>; 
  DWORD <a class="synParam" onclick="showTip(this)" href>ReadTotalTimeoutConstant</a>; 
  DWORD <a class="synParam" onclick="showTip(this)" href>WriteTotalTimeoutMultiplier</a>; 
  DWORD <a class="synParam" onclick="showTip(this)" href>WriteTotalTimeoutConstant</a>; 
} COMMTIMEOUTS,*LPCOMMTIMEOUTS; </font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">&nbsp;&nbsp;
<br>
For a description of all these fields consult MSDN documentation. But one thing
I want to point out is this:&nbsp;<br>
&quot;...A value of MAXDWORD, combined with zero values for both the <b>ReadTotalTimeoutConstant</b>
and <b>ReadTotalTimeoutMultiplier</b> members, specifies that the read operation
is to return immediately with the characters that have already been received,
even if no characters have been received...&quot;<br>
This is exactly what we want . We do NOT want the ReadFile to get stuck if there
is no data available as we will know with WaitCommEvent() API.<br>
and also &quot;...A value of zero for both the <b>WriteTotalTimeoutMultiplier</b>
and <b>WriteTotalTimeoutConstant</b> members indicates that total time-outs are
not used for write operations...&quot; is what we want. In short we need to do
this:</font></p>
<table border="0" cellspacing="1" width="70%" bgcolor="#DADADA">
  <tr>
    <td width="100%">
      <pre>		COMMTIMEOUTS timeouts;
		timeouts.ReadIntervalTimeout		= MAXDWORD; 
		timeouts.ReadTotalTimeoutMultiplier	= 0;
		timeouts.ReadTotalTimeoutConstant	= 0;
		timeouts.WriteTotalTimeoutMultiplier	= 0;
		timeouts.WriteTotalTimeoutConstant	= 0;
		
		if (!SetCommTimeouts(m_hCommPort, &amp;timeouts))
		{
			ASSERT(0);
			TRACE ( &quot;CSerialCommHelper :  Error setting time-outs. %d&quot;,GetLastError());
			return E_FAIL;
		}
</pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana"><br>
Now we have discussed almost everything that needs to be discussed for the sake
of this article.<br>
<b><br>
Putting it all together&nbsp;<br>
</b>All this I have put together in a form of two classes:&nbsp;<br>
The main class is <b>CSerialCommHelper</b> - the main class that does performs
all the communication .<br>
The helper class called <b>CSerialBuffer</b> that is an internal buffer used by
the CSerialCommHelper.<br>
<br>
Here is the main API of the <b>CSerialCommHelper:<br>
</b></font></p>
<table border="0" cellspacing="1" width="70%" bgcolor="#DADADA">
  <tr>
    <td width="100%">
      <pre><font face="Verdana" size="2">inline bool IsInputAvailable()
inline bool IsConnection() {return m_abIsConnected ;}
inline void SetDataReadEvent() { SetEvent ( m_hDataRx ); }
HRESULT Read_N (std::string&amp; data,long alCount,long alTimeOut);
HRESULT Read_Upto (std::string&amp; data,char chTerminator ,long* alCount,long alTimeOut);
HRESULT ReadAvailable(std::string&amp; data);
HRESULT Write (const char* data,DWORD dwSize);
HRESULT Init(std::string szPortName, DWORD dwBaudRate,BYTE byParity,BYTE byStopBits,BYTE byByteSize);
HRESULT Start();
HRESULT Stop();
HRESULT UnInit();</font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">and the interface for CSerialBuffer is :<br>
</font></p>
<table border="0" cellspacing="1" width="70%" bgcolor="#DADADA">
  <tr>
    <td width="100%">
      <pre><font size="2" face="Verdana">inline void LockBuffer(); 
inline void UnLockBuffer();
void AddData( char ch ) ;
void AddData( std::string&amp; szData ) ;
void AddData( std::string&amp; szData,int iLen ) ;
void AddData( char *strData,int iLen ) ;
std::string GetData() ;
void Flush();
long Read_N( std::string &amp;szData,long alCount,HANDLE&amp; hEventToReset);
bool Read_Upto( std::string &amp;szData,char chTerm,long &amp;alBytesRead ,HANDLE&amp; hEventToReset);
bool Read_Available( std::string &amp;szData,HANDLE &amp; hEventToReset);
inline long GetSize() ;
inline bool IsEmpty() ;</font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">&nbsp;</font></p>
<p><font size="2" face="Verdana">Here is the logic and working behind the
classes:</font></p>
<p><font size="2" face="Verdana">First of let me show you how to use the class.
In your application create an object of CSerialCommHelper like this:</font></p>
<p><font size="2" face="Verdana">CSerialCommHelper m_theCommPort;<br>
<br>
Call m_theCommPort.Init() passing in the necessary information. If you want you
can use default values.<br>
Next call m_theCommPort.Start()&nbsp;</font></p>
<p><font size="2" face="Verdana">If you want to get notification about when the
some data is available you can get the kernel event object to wait on by
calling&nbsp; m_theCommPort.GetWaitForEvent().</font></p>
<p><font size="2" face="Verdana">What CSerialCommHelper does is that on call to
Init(), it opens the specified COM port and also starts a thread. The thread
starts &quot;listening&quot; for any incoming data and once the data has been
received it reads&nbsp; all the data into a local buffer which is of type
CSerialBuffer . Once its done reading all the data it sets the event in case you
want to get the notification. Now you have three options </font></p>
<ul>
  <li><font size="2" face="Verdana">read all the data by calling ReadAvailable()
    which reads all the data . </font></li>
  <li><font size="2" face="Verdana">read up to some character by calling
    Read_Upto and passing character upto which you want to read.</font></li>
  <li><font size="2" face="Verdana">read N character calling Read_N passing the
    numbers to be read. </font></li>
</ul>
<p><font size="2" face="Verdana">There is one more thing that needs to be paid
attention. If you want to read 10 characters&nbsp; but there are only 5
characters in the local buffer, the read_N makes a blocking call and waits for
the timeout passed as the last parameter .&nbsp; Same is true for Read_Upto.</font></p>
<p><font size="2" face="Verdana">One more thing. If there are 10 characters in
the local buffer but you made a call to Read_N() for 5 characters you will be
returned first 5 characters. If you made a next call Read_N() for 5 characters
again, it would returned next 5 characters.<br>
<br>
Thats all there is to it. </font></p>
<p><font size="2" face="Verdana">If you think I have left something please feel
free to email me at <a href="mailto:ashishdhar@hotmail.com">ashishdhar@hotmail.com</a>
<br>
<br>
&nbsp;</font></p>

      </td>
    </tr>
  </tbody>
</table>
<hr width="70%" color="#000000">
<p align="center"><font face="Verdana" size="1">copyright 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国v精品久久久网| av毛片久久久久**hd| 国产午夜精品福利| 欧美日韩国产高清一区二区| 国产一区二区中文字幕| 亚洲精选免费视频| 久久久国际精品| 51精品久久久久久久蜜臀| 91老司机福利 在线| 韩国v欧美v亚洲v日本v| 无吗不卡中文字幕| 亚洲日本在线看| 久久久蜜桃精品| 欧美va亚洲va| 欧美人体做爰大胆视频| 99国产精品99久久久久久| 黄色资源网久久资源365| 视频在线观看91| 一区二区三区在线观看视频| 国产欧美精品一区二区色综合朱莉| 欧亚一区二区三区| 91偷拍与自偷拍精品| 国产成人免费9x9x人网站视频| 日韩高清在线不卡| 亚洲国产综合人成综合网站| 一区免费观看视频| 中文字幕乱码亚洲精品一区| 久久久精品国产免大香伊| 精品乱码亚洲一区二区不卡| 91精品国产综合久久久久久久久久 | 在线一区二区三区四区五区| 国产精品123| 国产高清不卡一区| 国产精品亚洲人在线观看| 国产乱一区二区| 国产福利一区二区三区| 国产精品12区| 成人黄色小视频| 白白色亚洲国产精品| 成人午夜在线播放| av亚洲精华国产精华精华| 国产成人精品免费看| 国产成人精品免费| 波波电影院一区二区三区| 99国产精品久| 欧美在线制服丝袜| 欧美男人的天堂一二区| 欧美年轻男男videosbes| 91精品在线免费观看| 日韩一级免费观看| 2014亚洲片线观看视频免费| 国产亚洲精品超碰| 国产精品家庭影院| 一区二区三区不卡视频在线观看| 亚洲一区二区三区四区的| 午夜激情综合网| 日韩电影在线一区二区| 久久99精品视频| 成人在线一区二区三区| 91影院在线免费观看| 91国产免费看| 日韩一二三区视频| 久久精品视频在线看| 亚洲欧美怡红院| 一区二区日韩av| 免费精品99久久国产综合精品| 国产精品一区二区无线| 91丨porny丨户外露出| 在线播放国产精品二区一二区四区 | 91丨九色丨蝌蚪丨老版| 欧美日韩综合在线免费观看| 日韩欧美电影一区| 国产欧美日韩在线| 亚洲永久免费视频| 九九**精品视频免费播放| 菠萝蜜视频在线观看一区| 欧美日韩国产免费| 中国av一区二区三区| 亚洲一区免费在线观看| 狠狠色丁香婷婷综合| 91免费版在线| 2023国产精品自拍| 亚洲情趣在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 色综合久久久久久久久| 精品少妇一区二区三区视频免付费 | 成人性生交大片免费| 欧美日韩的一区二区| 亚洲国产电影在线观看| 日韩精品亚洲专区| 成人激情校园春色| 日韩一区二区精品葵司在线| 中文字幕在线不卡一区二区三区| 日韩激情在线观看| 波多野结衣欧美| www一区二区| 日韩黄色免费电影| 色综合中文字幕国产 | 亚洲动漫第一页| 日韩成人dvd| 91免费版在线| 国产日产欧美一区二区三区| 日韩高清一区二区| 色94色欧美sute亚洲线路二| 久久综合久久鬼色| 日韩影院在线观看| 91久久人澡人人添人人爽欧美| 久久久不卡网国产精品一区| 视频一区二区三区中文字幕| 91网站在线观看视频| 久久看人人爽人人| 久久精品国产亚洲aⅴ| 欧美亚洲综合色| 亚洲欧洲另类国产综合| 国产成人精品三级| 精品日韩在线一区| 蜜臀精品一区二区三区在线观看| 色视频成人在线观看免| 国产精品久99| 成人国产亚洲欧美成人综合网| 欧美va亚洲va香蕉在线| 免费在线看成人av| 欧美老人xxxx18| 亚洲高清免费一级二级三级| 91久久久免费一区二区| 最新国产の精品合集bt伙计| 国产 欧美在线| 亚洲国产成人私人影院tom| 国产精品1区2区3区在线观看| 精品嫩草影院久久| 国产主播一区二区三区| 精品黑人一区二区三区久久| 另类专区欧美蜜桃臀第一页| 欧美一级理论性理论a| 性做久久久久久| 欧美精品1区2区3区| 日韩av一区二区三区四区| 91精品国产色综合久久不卡蜜臀| 亚洲福利一二三区| 欧美精品乱码久久久久久| 午夜精品在线视频一区| 精品1区2区3区| 日日嗨av一区二区三区四区| 91精品福利在线一区二区三区| 日韩1区2区日韩1区2区| 精品噜噜噜噜久久久久久久久试看 | 久久国产综合精品| 欧美精品一区二区三区四区| 国产真实乱对白精彩久久| 亚洲国产精品二十页| 成人ar影院免费观看视频| 亚洲精品一卡二卡| 欧美日韩国产精品自在自线| 日韩高清一级片| 久久精品夜色噜噜亚洲aⅴ| 高清不卡一区二区在线| 亚洲欧洲中文日韩久久av乱码| 欧美日韩一级视频| 免费av成人在线| 久久精品亚洲一区二区三区浴池| 成人美女视频在线观看| 亚洲激情图片小说视频| 欧美喷潮久久久xxxxx| 激情图片小说一区| 中文字幕一区二区三区乱码在线| 欧美日韩视频在线观看一区二区三区| 日韩不卡一二三区| 中文字幕的久久| 在线观看免费亚洲| 黄色小说综合网站| 亚洲免费资源在线播放| 91精品国产综合久久久蜜臀粉嫩| 国模无码大尺度一区二区三区| 中文字幕日韩精品一区| 91精品国产综合久久香蕉的特点| 国产成人精品综合在线观看| 亚洲最新在线观看| 久久亚洲精华国产精华液| 色激情天天射综合网| 久久激情综合网| 亚洲美女视频在线观看| 日韩一区二区电影在线| 99久久综合99久久综合网站| 日韩av一区二| 亚洲乱码中文字幕| 精品国产91久久久久久久妲己| 色哟哟在线观看一区二区三区| 老汉av免费一区二区三区| 亚洲人妖av一区二区| 欧美xxxx在线观看| 欧美午夜精品久久久| 国产成人精品三级| 免费观看日韩av| 亚洲一区二区三区在线播放| 国产日韩欧美麻豆| 欧美一二区视频| 欧美视频中文字幕| 99久久99久久综合| 国内成+人亚洲+欧美+综合在线| 亚洲成人综合在线|