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

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

?? serialcomm.asp

?? 這是一個關于手機短信的源代碼,是用Java語言編寫的代碼.
?? ASP
?? 第 1 頁 / 共 3 頁
字號:
	TRACE ( "CSerialCommHelper : Failed to Set Comm State Reason: %d",GetLastError());
	return E_FAIL;
}
TRACE ( "CSerialCommHelper : Current Settings, (Baud Rate %d; Parity %d; Byte Size %d; Stop Bits %d", dcb.BaudRate, 
</font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">Most of the time you won't need to change the
other fields of this structure. But if you need to change the structure you need
to be very careful about the fields as changing the fields will affect the
behavior of the serial communication and hence you should be very sure what you
want to change.&nbsp;<br>
<b><br>
Event Driven Approach<br>
</b>Coming back to our earlier problem with the reading of data. If we do not
want to&nbsp; keep polling the COM port for any data then we need to have some
kind of event mechanism available. Fortunately there is a way that you can ask
the system to notify you when certain events happen. The API to use is
</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#C0C0C0">
  <tr>
    <td width="100%"><font size="2" face="Verdana">SetCommMask( HANDLE
      hHandle,DWORD dwEvtMask)</font></td>
  </tr>
</table>
<p><font size="2" face="Verdana">The first parameter is the handle to the open
COM port. The second parameter is used to specify a list of events which we are
interested in. <br>
The events that need to be specified in the mask depends upon the application
needs. For simplicity, lets say we are interested in getting&nbsp; notified
whenever a character arrives at the serial port, we would need to specify
EV_RXCHAR as the event mask. Similarly if we are interested to know when all the
data has been sent, we need to specify EV_TXEMPTY flag also. So out call would
look like this:
</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#DADADA">
  <tr>
    <td width="100%"><font size="2" face="Verdana">SetCommMask(
      m_hCommPort,EV_TXTEMPTY|EV_RXCHAR);</font></td>
  </tr>
</table>
<p><font size="2" face="Verdana">&nbsp; The interesting thing here is that
although we told system about the events of our interest, we did not however
told system what to do when these events occur. Like how would system let us
know that a particular event occurred. An obvious thing seems to be a callback
mechanism. But there is not such mechanism available. Here is when things get a
little tricky. In order for system to let us know about the communication event
occurrence, we need to call <b>WaitCommEvent</b> This function waits for the
events specified in SetCommMask. But if your think a little more, it sounds like
we are turning a notification mechanism back to polling mechanism. Actually its
even worse that than . WaitCommEvent blocks till an event occurs. So whats the
use of WaitCommEvent ? Well , the answer lies in overlapped IO.<br>
If you look at the WaitCommEvent signature it looks like this:
</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#DADADA">
  <tr>
    <td width="100%"><font face="Verdana" size="2">BOOL</font><font face="Verdana" size="2" color="#0000FF">
      WaitCommEvent</font><font face="Verdana" size="2">(HANDLE hCommPort,
      LPDWORD dwEvtMask,LPOVERLAPPED lpOverlapped);</font></td>
  </tr>
</table>
<p><font size="2" face="Verdana">&nbsp;&nbsp;&nbsp; The third parameter is the
key here.&nbsp;<br>
Think of overlapped IO as asynchronous IO. Whenever a function makes a call and
specifies the overlapped IO structure, it means that try to do the current
operation but if you are not able to complete it immediately let me know when
you are done with this IO. The way system lets you know about the completion is
by setting an kernel event object that is part of the lpOverlapped structure.
So, all you do is spawn a thread and make the thread wait for that event object
using one of the WaitForSingleObject() APIs.<br>
Lets look at the overlapped structure:<br>
</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#DADADA">
  <tr>
    <td width="100%">
      <pre><font size="2" face="Verdana"><font color="#0000FF">typedef struct </font>_OVERLAPPED {
DWORD Internal;
DWORD InternalHigh;
DWORD Offset;
DWORD OffsetHigh;
<b>HANDLE hEvent</b>;
} OVERLAPPED, *LPOVERLAPPED;</font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">The last parameter is the event handle that you
need to create . This event is generally a manual reset event. When you make a
call like WaitCommEvent () passing overlapped structure as the last parameter,
and the system could not complete call meaning it did not see any characters at
the port, it would return immediately but would return FALSE. If you now make a
call to GetLastError() you would get ERROR_IO_PENDING which means that the call
has been accepted but no characters have yet arrived at the COM port. Also it
means whenever the characters will arrive, the system will set the hEvent of the
overlapped structure that you passed in. So if your thread would wait for single
object on hEvent and you pass INFINITE, then whenever your Wait fn. returns
WAIT_OBJECT_0 it means some character has arrived&nbsp; or all the data in the
output buffer has been sent.<br>
In our current case since we are interested in more than one events we would
need to check what event did we get by making call to GetCommMask and checking
the dword against each event.Following&nbsp; pseudo code will explain it:</font></p>
<p><font size="2" face="Verdana">&nbsp;You can read the data from the com port
and reset the event and make the call to WaitCommEvent again and so on.
</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#EEE8EE">
  <tr>
    <td width="100%">
      <pre><font face="Verdana" size="2" color="#417194">unsigned __stdcall CSerialCommHelper::ThreadFn(void*pvParam)
{
	OVERLAPPED ov;
	memset(&amp;ov,0,sizeof(ov));
	ov.hEvent = CreateEvent( 0,true,0,0);
	HANDLE arHandles[2];
	arHandles[0] = apThis-&gt;m_hThreadTerm;

	DWORD dwWait;
	SetEvent(apThis-&gt;m_hThreadStarted);
	while (  abContinue )
	{
		
</font><font face="Verdana" size="2">		BOOL abRet = ::WaitCommEvent(apThis-&gt;m_hCommPort,&amp;dwEventMask, &amp;ov) ;
</font><font face="Verdana" size="2" color="#417194">		if ( !abRet )
		{
			
			ASSERT( GetLastError () == ERROR_IO_PENDING);
		}

		
		arHandles[1] = ov.hEvent ;
		
		dwWait = WaitForMultipleObjects (2,arHandles,FALSE,INFINITE);
		switch ( dwWait )
		{
		case WAIT_OBJECT_0:
			{
				_endthreadex(1);
			}
			break;
		case WAIT_OBJECT_0 + 1:
			{
				</font><font face="Verdana" size="2">DWORD dwMask;
				if (GetCommMask(apThis-&gt;m_hCommPort,&amp;dwMask) )
				{
				   if ( dwMask &amp; EV_TXEMPTY )
				   TRACE(&quot;Data sent&quot;);
				   ResetEvent ( ov.hEvent );
				   continue;
				}<font color="#417194">
				</font>else  
				{
				   //read data here and reset ov.hEvent
				}
</font><font color="#417194"><font face="Verdana" size="2">			}
		}//switch
	}//while
return 0;
}</font></font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">&nbsp;If you understood the above code , you
will understand the whole of this article and the source code provided.<br>
&nbsp;The above piece of code is simple using the overlapped IO method to do its
job.<br>
Once we have received the indication that the data has arrived we need to read
the data. Important thing to note here is that the when data arrives at the
serial port, it is copied over to system buffer.&nbsp; The data is removed from
the system buffer only when you have read the data using API such as ReadFile.&nbsp;
Like any buffer, system buffer has a limited size. So if you do not read the
data from the buffers quick enough the system buffers can be become full if more
data is arriving. What happens to further data depends upon the configuration
that you have set in the device configuration block (in call to SetCommState ).
Usually the applications do some kind of handshaking at the application level
but you can also make configurations such that the com port does not accept any
further data upon buffer-full events. But all that is beyond the scope of this
discussion. If possible its always better to have applications themselves
implementing some kind of handshaking&nbsp; - like do not send next block of
data until you get okay for the first block. Generally this kind of handshaking
is implemented using some sort of ACK / NAK&nbsp; and ENQ protocol.<br>
<br>
In order for us to read data we need to use ReadFile() API. ReadFile API has to
specify how much data to read. Lets say we are monitoring character arrivals and
10 characters arrive at the port. As soon as first character arrives at the port
the system will set the overlapped structure's event object and out
WaitSingleObject will return. Next we would need to read the data. So how much
data should we read? Should we read 1 byte or&nbsp; 10 bytes? That is a good
question.&nbsp;&nbsp; The way it works is as follows (Note:this
is not documented anywhere but this is what I have found by research on
Win2K,NT4.0)&nbsp; :<br>
When one (or more) characters arrive at the port, the event object associated with the
overlapped structure set once. Now lets say that you made a call to read and you
read 1 character. After reading 1 character , you would finally Reset the
overlapped structure's event object. Now you would go back to the WaitCommEvent
but it would return false since no &quot;new&quot; character has arrived. So you
will not be able to read any more characters.&nbsp; Now when another character
arrives, system will set the overlapped event and you would read one more
character but this time it will be the character that had arrived earlier and
you never read. This clearly is a&nbsp; problem.<br>
So what is the solution? The easiest solution is that as soon as you got the
event object indicating the arrival of a character, you should read all the
characters that are present in the port. (<i>If you are familiar with win API
MsgWaitForMultipleObjects you can draw a analogy here.</i>) </font></p>
<p><font size="2" face="Verdana">So again the question remains how many
characters to read. The answer is read all the characters in a loop using
ReadFile().
<br>
Here is the pseudo code</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#DADADA">
  <tr>
    <td width="100%">

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美中文在线| 亚洲综合久久久| 欧美亚洲另类激情小说| 成人av电影免费在线播放| 国内外精品视频| 久久av资源网| 激情伊人五月天久久综合| 精品无人码麻豆乱码1区2区| 激情文学综合插| 国产成人免费xxxxxxxx| av一区二区久久| 色94色欧美sute亚洲线路一ni | 国产精品乱码久久久久久| 精品日产卡一卡二卡麻豆| 精品国产髙清在线看国产毛片| 欧美肥妇bbw| 2020国产精品| 国产精品久久久久久久久快鸭| 亚洲免费在线视频一区 二区| 亚洲乱码国产乱码精品精98午夜| 亚洲线精品一区二区三区八戒| 日韩国产欧美三级| 国产资源在线一区| 一本久久综合亚洲鲁鲁五月天| 91麻豆精品国产91久久久久久 | 婷婷六月综合亚洲| 日韩成人午夜电影| 国产69精品久久久久毛片| 91啦中文在线观看| 欧美巨大另类极品videosbest | 一区二区中文字幕在线| 一区二区欧美视频| 极品美女销魂一区二区三区免费| 成人激情免费视频| 538在线一区二区精品国产| 久久久久久亚洲综合影院红桃| 亚洲欧美激情视频在线观看一区二区三区 | 成人国产精品免费观看动漫 | 国产伦精品一区二区三区视频青涩| 成人av高清在线| 制服丝袜在线91| 亚洲三级久久久| 狠狠色狠狠色合久久伊人| 91啪在线观看| 国产亚洲精品福利| 日本怡春院一区二区| av午夜一区麻豆| 精品国产一区久久| 亚洲成人av电影| 91美女在线看| 国产欧美日产一区| 激情国产一区二区| 制服.丝袜.亚洲.中文.综合| 亚洲视频图片小说| 国产成人在线观看| 国产精品灌醉下药二区| 美女爽到高潮91| 欧美怡红院视频| 亚洲欧美在线观看| 国产传媒久久文化传媒| 日韩免费在线观看| 五月激情综合色| 91精彩视频在线观看| 综合电影一区二区三区| 丰满白嫩尤物一区二区| 欧美成人一区二区| 麻豆成人在线观看| 日韩免费看的电影| 毛片不卡一区二区| 欧美成va人片在线观看| 日本欧美一区二区三区乱码| 欧美日韩一区在线| 水蜜桃久久夜色精品一区的特点| 色婷婷香蕉在线一区二区| 国产精品高潮呻吟| 91美女视频网站| 亚洲综合男人的天堂| 欧美日韩亚洲综合在线| 午夜精品久久久久久不卡8050| 色噜噜狠狠色综合中国| 一区二区三区在线视频免费观看 | 久久99国内精品| 欧美精品一区二区蜜臀亚洲| 精品一区二区三区免费观看| 久久久久国产精品麻豆ai换脸| 国产精品亚洲午夜一区二区三区 | 日韩精品一区国产麻豆| 久久av老司机精品网站导航| 欧美一区二区在线观看| 久久er精品视频| 国产精品久久久久久久久动漫| 成人aa视频在线观看| 有坂深雪av一区二区精品| 欧美日韩黄色一区二区| 美国av一区二区| 国产精品天干天干在观线| 99精品欧美一区二区三区小说| 亚洲夂夂婷婷色拍ww47| 日韩亚洲电影在线| 成人精品国产福利| 亚洲一区二区三区三| 日韩免费视频一区二区| 成人动漫一区二区| 亚洲午夜一区二区| 欧美精品一区二区三区蜜臀| 成人av免费网站| 日本欧美一区二区三区乱码| 欧美极品另类videosde| 欧美日本国产视频| 国产精品一区二区三区四区 | 欧美一级日韩免费不卡| 国产乱国产乱300精品| 亚洲伦理在线免费看| 日韩一区二区在线免费观看| 床上的激情91.| 日韩综合小视频| 国产精品久线在线观看| 日韩一区二区三区观看| av影院午夜一区| 久久99热这里只有精品| 亚洲激情在线播放| 久久久精品人体av艺术| 88在线观看91蜜桃国自产| 不卡的av中国片| 一本大道av一区二区在线播放| 日本女人一区二区三区| 亚洲欧美视频在线观看视频| 久久夜色精品一区| 欧美一区二区三区视频在线观看| 91社区在线播放| 国产宾馆实践打屁股91| 免费观看在线综合色| 亚洲成人先锋电影| 亚洲精品老司机| 国产精品久久久久四虎| 久久精品水蜜桃av综合天堂| 在线播放一区二区三区| 欧美性做爰猛烈叫床潮| 91免费视频观看| 成人av免费观看| 国产iv一区二区三区| 国产九色sp调教91| 精品一区二区久久| 美国毛片一区二区三区| 青青青爽久久午夜综合久久午夜| 亚洲激情图片qvod| 国产精品免费免费| 国产精品欧美精品| 欧美激情在线一区二区三区| 国产色91在线| 国产日韩欧美电影| 久久久久久亚洲综合影院红桃 | 亚洲综合激情另类小说区| 国产视频亚洲色图| 亚洲国产精品成人综合| 国产亚洲精品久| 国产女同互慰高潮91漫画| 国产精品国产自产拍高清av| 日本一区免费视频| 国产精品私人自拍| 亚洲三级在线免费观看| 亚洲男同性恋视频| 亚洲一区二区四区蜜桃| 性久久久久久久| 久久福利资源站| 国产精品一区二区在线观看不卡| 高清不卡一区二区在线| www.久久久久久久久| 日韩一区二区三区免费观看| 精品国产乱码久久久久久夜甘婷婷| 日韩免费视频一区| 国产欧美日韩亚州综合 | 欧美电影免费提供在线观看| 精品成人一区二区三区| 欧美韩国一区二区| 亚洲人成网站色在线观看| 亚洲一区二区三区视频在线| 日韩精品电影在线| 国产高清不卡一区| 色乱码一区二区三区88| 91麻豆精品国产91久久久久| 精品少妇一区二区三区| 国产精品乱码妇女bbbb| 午夜婷婷国产麻豆精品| 国产精品乡下勾搭老头1| 色八戒一区二区三区| 91精品国产入口| 中文在线免费一区三区高中清不卡| 亚洲精品老司机| 国产精品一区二区x88av| 欧美最新大片在线看| 久久综合久久久久88| 亚洲综合一区二区三区| 国产精品中文字幕一区二区三区| 91成人国产精品| 国产嫩草影院久久久久| 蜜臀精品一区二区三区在线观看 | 国产乱码精品一区二区三区忘忧草 | 欧美日韩成人综合天天影院| 欧美精品一区二区三区蜜桃|