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

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

?? serialcomm.asp

?? 這是一個關于手機短信的源代碼,是用Java語言編寫的代碼.
?? ASP
?? 第 1 頁 / 共 3 頁
字號:
<%@ Language=VBScript %>
<!-- #include file="../../ArticleAccess.asp" -->
<!-- #include file="../../GetAccessCount.asp" -->
<%
 PrintArticleAccessCount 45
 AccessArticle  45
 %>
 <html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title> Serial Communication in Windows </title>
</head>

<body>

<p align="center">&nbsp;</p>
<p align="center"><font face="Verdana" size="2"><b>[<u> </u></b></font><font size="2" face="Verdana"><b><u>Serial Communication in Windows</u></b></font><font face="Verdana" size="2"><b><u>
</u>]<br>
</b><a href="mailto:ashishdhar@hotmail.com"><i>ashish dhar</i></a></font></p>
<table borderColor="#ffffff" height="4318" cellSpacing="0" borderColorDark="#ffffff" width="99%" borderColorLight="#ffffff" border="1">
  <tbody>
    <tr>
      <td vAlign="top" width="11%" bgColor="#538ab3" height="4314">
        <div align="justify">
          <table borderColor="#538ab3" height="4654" cellSpacing="4" borderColorDark="#000000" width="100%" borderColorLight="#538ab3" border="4">
            <tbody>
              <tr>
                <td vAlign="top" borderColorLight="#538ab3" width="100%" bgColor="#538ab3" borderColorDark="#538ab3" height="4650"><br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                  <br>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </td>
      <td vAlign="top" borderColorLight="#e8e9e2" width="69%" bgColor="#ffffff" borderColorDark="#f0f0f0" height="4314">&nbsp;

<p><font size="2" face="Verdana"><a href="../Source.zip">Source code</a><b><br>
<br>
</b>This article is meant to give you a jump start on doing serial communication
in Windows (NT family). The article will provide a class called
CSerialCommHelper which you can use directly to do serial communication in your
application. The class that is provided here with this article does uses
overlapped IO. You donot need to know much about serial communication or
overlapped IO for this article. However, you need to know some about the
synchronization objects like Events and some Windows APIs like
WaitForSingleObject and WaitForMultipleObject etc. Also some basic understanding
of windows threads is required - like thread creation and <i>termination</i>.</font></p>
<p><font size="2" face="Verdana"><b>Introduction<br>
</b>In order for your computer to be able to do serial communication, computer
has to have a serial port. Most of the computers have at least one serial port
also known as COM port ( communication port ) and are generally called COM1 COM2
etc. Then there are the device drivers for the serial ports. If you think it
over, all you that you need to do in serial communication is either send data or
receive data. In other words, you are doing input/output (IO) to the serial
port. The same IO is done with disk based files. Hence there is no surprise that
the APIs for reading and writing to a file apply to serial ports as well. When
you send data to the serial port its in terms of bytes but when it leaves the
serial port it is in the form of bits. Similarly, when the data arrives at the
serial port, its in bit format and when you get data you get it in bytes.&nbsp;<br>
Without any further discussion lets get started.<br>
<br>
<b>Opening the COM port<br>
</b>The first and the foremost step in doing a serial communication is to open
the desired port. Lets say you have your device hooked to COM1 you can open the
COM port using following API:</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#EEE8EE">
  <tr>
    <td width="100%">
      <pre><font size="2">HANDLE m_hCommPort = ::<font color="#0000FF">CreateFile</font>(	szPortName,
					GENERIC_READ|GENERIC_WRITE,//access ( read and write)
					0,	//(share) 0:cannot share the COM port						
					0,	//security  (None)				
					OPEN_EXISTING,// creation : open_existing
					FILE_FLAG_OVERLAPPED,// we want overlapped operation
					0// no templates file for COM port...
					);</font></pre>
    </td>
  </tr>
</table>
<p><font size="2" face="Verdana">The third fifth and seventh parameters have to be what they
are in the above example by law. We want to open the file ( the COM port ) in an
overlapped fashion - that's why the sixth param is FILE_FLAG_OVERLAPPED. We will
get into the details of overlapped IO a bit later. As you must have guessed from
the name , CreateFile() API can be used to create a file (disk based) and also
it can be used to open an existing file.&nbsp;<br>
To Windows a serial port or a disk based file both are IO devices . So, in order
to open an existing file ( serial port ) all we need to know the name of the
device ( COM1) and pass the creation flags as OPEN_EXISTING.<br>
If a COM port is opened successfully, the API returns handle to the com port
just like a handle to a file. However, if the system could not open the COM
port, it would return INVALID_HANDLE_VALUE . And you can get the reason by
calling GetLastError(). One of the common errors while opening a COM port is
that the COM port is already opened by some other application and in that case
you would get ERROR_ACCESS_DENIED (5). Similarly if you by mistake opened a COM
port that doesnot exist , you would get ERROR_FILE_NOT_FOUND&nbsp; as the last
error.<br>
<u>Note: Remember not to do make any function calls (like ASSERT) before calling
GetLastError() or you would get 0</u>.<u><br>
</u>Once you have opened the com port all you need to do now is to start using
it.<br>
<br>
<b>Reading and Writing<br>
</b>Now, once you have a com port open, you may want to send&nbsp; some data to
the connected device. For example, lets say you want to send &quot;Hello&quot;
to the device(e.g., another PC). When you want to send the data across the
serial port, you need to write to the serial port just like you would write to a
file. You would use following API:<br>
</font></p>
<table border="0" cellspacing="1" width="100%">
  <tr>
    <td width="100%" bgcolor="#C0C0C0"><font size="2" face="Verdana">iRet = WriteFile (m_hCommPort,data,dwSize,&amp;dwBytesWritten  ,&amp;ov);&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
  </tr>
</table>
<p><font size="2" face="Verdana">where data contains &quot;Hello&quot; .&nbsp;<br>
Lets say in response to your &quot;Hello&quot; , the device sends you
&quot;Hi&quot; . So you need to read the data. Again ,you would&nbsp; use
following API:</font></p>
<table border="0" cellspacing="1" width="100%">
  <tr>
    <td width="100%" bgcolor="#C0C0C0"><font size="2" face="Verdana">abRet = ::ReadFile(m_hCommPort,szTmp
      ,sizeof(szTmp ),&amp;dwBytesRead,&amp;ovRead) ;</font></td>
  </tr>
</table>
<p><font size="2" face="Verdana"><i>For now do not try to understand everything.We will get to
all this later.<br>
</i>All this sounds very simple. Right? <br>
Now lets start digging into issues. </font></p>
<p><font size="2" face="Verdana"><b>Issues with serial communication</b><br>
Just now I said, in response to your &quot;Hello&quot;, the device may send you
&quot;Hi&quot; back and you would like to read that. But the problem here is
that you don't know when the device is going to respond? Or will it ever
respond? When should you start to read from the port. One option is that as soon
as you made call to WriteFile, you make call to ReadFile . If no data is there
you need to make read again later on. This leads to what is called polling. You
keep polling the port for data. This model does not really&nbsp; seem to be a
good one. It would be nice if somehow you were notified by the system when data
has arrived and only then would you make call to ReadFile. This is event driven
approach and fits well into Windows programming. And good news is that such a
model is possible . <br>
<br>
<br>
<br>
Another issue with the serial communication is that since it always occurs
between two devices, the two devices need to agree on how they talk to each
other. Each side needs to follow certain protocols to conduct business. Since
its the serial port that actually carries out the communication, we need to
configure the serial port. There is an API available for exact same purpose.
Following is the API:</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#C0C0C0">
  <tr>
    <td width="100%"><font size="2" face="Verdana">SetCommState ( HANDLE hFile, LPDCB lpDCB)</font></td>
  </tr>
</table>
<p><font size="2" face="Verdana">The first parameter is the handle to COM port and the second
paramter is what is called device control block (DCB) . The DCB is a struct
defined in winbase.h and has 28 data members. For example, we need to specify
baud rate at which the COM port operates, you need to set the <b>BaudRate </b>member
of the struct . Baud rate is usual 9600 (bps) . But the two devices have to use
the same baud rate to conduct business. Similarly if you want to use parity you
need to set <b>Parity</b> member of the struct. Again the two devices have to
use same parity. Some of the data members are reserved and have to be 0. I have
found it easier to get the current DCB struct and then set those members which
we are interested in changing. Following code gets the current dcb and sets some
of the fields:<br>
<br>
</font></p>
<table border="0" cellspacing="1" width="100%" bgcolor="#EEE8EE">
  <tr>
    <td width="100%">
      <pre><font size="2" face="Verdana">DCB dcb = {0};
dcb.DCBlength = sizeof(DCB);

if (!::<font color="#0000FF">GetCommState </font>(m_hCommPort,&amp;dcb))
{
	TRACE ( &quot;CSerialCommHelper : Failed to Get Comm State Reason: %d&quot;,GetLastError());
	return E_FAIL;
}

dcb.BaudRate	= dwBaudRate;
dcb.ByteSize	= byByteSize;
dcb.Parity		= byParity;
if ( byStopBits == 1 )
	dcb.StopBits	= ONESTOPBIT;
else if (byStopBits == 2 ) 
	dcb.StopBits	= TWOSTOPBITS;
else 
	dcb.StopBits	= ONE5STOPBITS;


if (!::<font color="#0000FF">SetCommState</font> (m_hCommPort,&amp;dcb))
{
	ASSERT(0);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
奇米888四色在线精品| 日韩码欧中文字| 国产一区二区精品久久| 中文字幕乱码一区二区免费| 91官网在线观看| 国产一区在线看| 一区二区在线观看视频| 久久无码av三级| 欧美挠脚心视频网站| 99精品国产视频| 国产精品综合在线视频| 免费成人性网站| 亚洲国产人成综合网站| 中文字幕在线观看不卡视频| 欧美videofree性高清杂交| 欧美专区亚洲专区| 波多野结衣中文字幕一区| 激情久久五月天| 日日噜噜夜夜狠狠视频欧美人| 国产精品美女久久久久高潮| 欧美成人精精品一区二区频| 欧美日韩精品欧美日韩精品| 91免费看视频| 91一区一区三区| 成人精品免费看| 国产成人精品亚洲日本在线桃色 | 亚洲福利视频导航| 男女性色大片免费观看一区二区| 欧美一级搡bbbb搡bbbb| 欧美亚洲日本国产| 色噜噜狠狠成人中文综合| 成人免费高清在线| 岛国精品在线播放| 国产一区福利在线| 国产自产2019最新不卡| 韩国欧美国产1区| 麻豆国产一区二区| 日本v片在线高清不卡在线观看| 亚洲精品中文字幕乱码三区| 久久久99久久| 欧美国产欧美亚州国产日韩mv天天看完整 | 久久成人久久爱| 蜜臀va亚洲va欧美va天堂 | 精品久久免费看| 精品国产乱码久久久久久1区2区| 欧美精品自拍偷拍动漫精品| 欧美亚洲动漫另类| 欧美性猛片xxxx免费看久爱| 在线观看中文字幕不卡| 欧美色倩网站大全免费| 欧美人体做爰大胆视频| 欧美一区国产二区| 精品国产污网站| 久久久久久久久久美女| 国产精品私人影院| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美三级在线看| 欧美一区二区三区人| 精品美女一区二区三区| 久久久久国产精品厨房| 国产精品天天摸av网| 亚洲三级在线播放| 亚洲123区在线观看| 秋霞午夜鲁丝一区二区老狼| 国产综合成人久久大片91| 国产精品一区免费视频| 97久久超碰精品国产| 欧美网站一区二区| 欧美一区二区三区免费在线看| 精品少妇一区二区| 国产精品欧美久久久久一区二区| 国产精品久久久久久久久免费桃花 | 奇米精品一区二区三区四区 | 国产精品18久久久久| 91视视频在线观看入口直接观看www | 日韩avvvv在线播放| 经典三级在线一区| 成人免费毛片嘿嘿连载视频| 欧洲一区在线电影| 欧美r级电影在线观看| 国产欧美日本一区二区三区| 亚洲精选视频免费看| 奇米综合一区二区三区精品视频| 国产91精品一区二区麻豆亚洲| 色天天综合色天天久久| 欧美色区777第一页| 精品国产一区二区在线观看| 亚洲色图19p| 久久91精品久久久久久秒播| 91蝌蚪porny成人天涯| 日韩午夜在线观看| 亚洲精品日韩一| 国产精品一二三四五| 欧美日韩不卡在线| 国产精品久久久久久久久免费相片 | 亚洲天堂免费看| 久久精品久久99精品久久| 日本久久电影网| 久久综合九色综合97婷婷女人| 一区二区三区在线高清| 国产又黄又大久久| 91精品在线观看入口| 综合婷婷亚洲小说| 国产一区二区中文字幕| 欧美日本一区二区在线观看| 中文字幕一区二区三中文字幕| 蜜桃视频在线一区| 欧美无砖砖区免费| 亚洲色图在线播放| 国产剧情av麻豆香蕉精品| 777亚洲妇女| 亚洲一区二区三区中文字幕在线 | 捆绑变态av一区二区三区| 在线观看一区日韩| 国产精品久久国产精麻豆99网站| 麻豆成人久久精品二区三区红| 欧美性猛交xxxxxx富婆| 国产精品三级在线观看| 国产精品影视网| 精品国产sm最大网站免费看| 丝袜美腿亚洲一区| 色婷婷综合久久久中文字幕| 国产精品久久久久aaaa| 国产一区二区三区久久久| 91精品欧美一区二区三区综合在 | 亚洲男人的天堂在线aⅴ视频| 国产精品白丝av| 久久品道一品道久久精品| 日韩1区2区3区| 欧美精品一二三四| 亚洲第一激情av| 欧美亚洲一区二区三区四区| 一区二区三区四区精品在线视频| 91色婷婷久久久久合中文| 国产精品热久久久久夜色精品三区| 久久av老司机精品网站导航| 91精品国产黑色紧身裤美女| 日日摸夜夜添夜夜添精品视频| 欧美人妖巨大在线| 秋霞电影一区二区| 精品日韩在线观看| 韩国女主播一区| 国产亚洲成年网址在线观看| 国产一区二区三区在线观看免费视频| 日韩欧美一区电影| 国产一区二区三区四| 日本一区免费视频| 不卡大黄网站免费看| 亚洲色图欧洲色图婷婷| 欧美日韩在线三区| 日韩成人一区二区三区在线观看| 日韩一区二区在线看| 国产美女娇喘av呻吟久久| 国产精品丝袜久久久久久app| www.亚洲精品| 亚洲精品五月天| 91精品国产福利| 韩国在线一区二区| 亚洲色图20p| 3d成人h动漫网站入口| 国产又粗又猛又爽又黄91精品| 国产精品你懂的在线| 色哟哟在线观看一区二区三区| 一区二区三区av电影| 欧美一级精品大片| 成人国产精品免费观看视频| 亚洲午夜激情网页| 日韩一区二区三区在线| 成人午夜精品一区二区三区| 亚洲另类春色校园小说| 日韩欧美国产一区在线观看| 成人午夜av电影| 亚洲国产欧美日韩另类综合| 欧美mv和日韩mv的网站| 一本一本久久a久久精品综合麻豆| 亚洲网友自拍偷拍| 久久女同互慰一区二区三区| 91热门视频在线观看| 久久99精品久久久久久国产越南| 国产精品福利影院| 欧美一区2区视频在线观看| 成人黄色网址在线观看| 亚洲第一会所有码转帖| 久久久久久亚洲综合| 欧美午夜片在线观看| 国产剧情一区在线| 视频一区视频二区中文| 国产精品久久久久影院| 欧美四级电影在线观看| 成人性生交大片免费看在线播放| 午夜一区二区三区视频| 国产精品伦理一区二区| 欧美一级国产精品| 色综合久久综合网欧美综合网 | 国产99久久久久| 亚洲福利电影网| 国产精品久久看| 337p日本欧洲亚洲大胆精品| 欧美日韩一区不卡| 99久久精品免费看|