⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 在delphi中用spcomm实现串口编程.htm

📁 GPS对讲机接收
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0063)http://cs.nju.edu.cn/yangxc/dcc2003.files/jszc-sub/comif-42.htm -->
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v = 
"urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word"><HEAD><TITLE>在Delphi中用SPCOMM实现串口编程</TITLE>
<META http-equiv=Content-Type content="text/html; charset=GB2312">
<META content=Word.Document name=ProgId>
<META content="MSHTML 6.00.2900.3395" name=GENERATOR>
<META content="Microsoft Word 9" name=Originator><LINK 
href="./comif-42.files/filelist.xml" rel=File-List><LINK 
href="./comif-42.files/editdata.mso" rel=Edit-Time-Data><!--[if !mso]>
<STYLE>v\:* {
	BEHAVIOR: url(#default#VML)
}
o\:* {
	BEHAVIOR: url(#default#VML)
}
w\:* {
	BEHAVIOR: url(#default#VML)
}
.shape {
	BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]--><!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>xcyang</o:Author>
  <o:LastAuthor>xcyang</o:LastAuthor>
  <o:Revision>2</o:Revision>
  <o:TotalTime>3</o:TotalTime>
  <o:Created>2003-05-18T02:45:00Z</o:Created>
  <o:LastSaved>2003-05-18T02:45:00Z</o:LastSaved>
  <o:Pages>6</o:Pages>
  <o:Words>547</o:Words>
  <o:Characters>3123</o:Characters>
  <o:Company>DCS,Nanjing University</o:Company>
  <o:Lines>26</o:Lines>
  <o:Paragraphs>6</o:Paragraphs>
  <o:CharactersWithSpaces>3835</o:CharactersWithSpaces>
  <o:Version>9.2812</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:PunctuationKerning/>
  <w:DrawingGridHorizontalSpacing>5.25 磅</w:DrawingGridHorizontalSpacing>
  <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
  <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
  <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:UseFELayout/>
  </w:Compatibility>
 </w:WordDocument>
</xml><![endif]-->
<STYLE>@font-face {
	font-family: 宋体;
}
@font-face {
	font-family: @宋体;
}
@page  {mso-page-border-surround-header: no; mso-page-border-surround-footer: no; }
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 89.85pt 72.0pt 89.85pt; mso-header-margin: 42.55pt; mso-footer-margin: 49.6pt; mso-paper-source: 0; layout-grid: 15.6pt; }
P.MsoNormal {
	TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify; mso-style-parent: ""; mso-pagination: none; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt
}
LI.MsoNormal {
	TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify; mso-style-parent: ""; mso-pagination: none; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt
}
DIV.MsoNormal {
	TEXT-JUSTIFY: inter-ideograph; FONT-SIZE: 10.5pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Times New Roman"; TEXT-ALIGN: justify; mso-style-parent: ""; mso-pagination: none; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt
}
DIV.Section1 {
	page: Section1
}
</STYLE>
</HEAD>
<BODY lang=ZH-CN style="TEXT-JUSTIFY-TRIM: punctuation; tab-interval: 21.0pt">
<DIV class=Section1 style="LAYOUT-GRID:  15.6pt none">
<P class=MsoNormal><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN 
lang=EN-US>Delphi</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中用</SPAN><SPAN 
lang=EN-US>SPCOMM</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现串口编程</SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">出处</SPAN><SPAN 
lang=EN-US>: http://www.ccw.com.cn/htm/app/aprog/01_1_8_4.asp<SPAN 
style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
<P class=MsoNormal><SPAN 
lang=EN-US><![if !supportEmptyParas]><![endif]>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
<P class=MsoNormal><SPAN 
lang=EN-US><![if !supportEmptyParas]><![endif]>&nbsp;<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US>Delphi</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是一种具有功能强大、简便易用和代码执行速度快等优点的可视化快速应用开发工具,它在构架企业信息系统方面发挥着越来越重要的作用,许多程序员愿意选择</SPAN><SPAN 
lang=EN-US> Delphi</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">作为开发工具编制各种应用程序。但是,美中不足之处是</SPAN><SPAN 
lang=EN-US> Delphi</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">没有自带的串口通信控件,在它的帮助文档里也没有提及串口通信,这就给编制通信程序的开发人员带来许多不便。</SPAN><SPAN 
lang=EN-US> </SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
<P class=MsoNormal><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">目前,利用</SPAN><SPAN 
lang=EN-US> Delphi</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现串口通信的常用的方法有</SPAN><SPAN 
lang=EN-US> 3</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">种:一是利用控件,如</SPAN><SPAN 
lang=EN-US> MSCOMM</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件和</SPAN><SPAN 
lang=EN-US> SPCOMM</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件;二是使用</SPAN><SPAN 
lang=EN-US> API</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">函数;三是调用其他串口通信程序。其中利用</SPAN><SPAN 
lang=EN-US> API</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编写串口通信程序较为复杂,需要掌握大量的通信知识。相比较而言,利用</SPAN><SPAN 
lang=EN-US> SPCOMM</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件则相对较简单,并且该控件具有丰富的与串口通信密切相关的属性及事件,提供了对串口的各种操作,而且还支持多线程。下面本文结合实例详细介绍</SPAN><SPAN 
lang=EN-US> SPCOMM</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件的使用。</SPAN><SPAN 
lang=EN-US> </SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
<P class=MsoNormal><SPAN lang=EN-US>SPCOMM</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的安装</SPAN><SPAN 
lang=EN-US> </SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
<P class=MsoNormal><SPAN lang=EN-US>1</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">.选择下拉菜单</SPAN><SPAN 
lang=EN-US> Component</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</SPAN><SPAN 
lang=EN-US> Install Component</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">选项,弹出如图</SPAN><SPAN 
lang=EN-US> 1</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所示的窗口。</SPAN><SPAN 
lang=EN-US> </SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes">&nbsp;</SPAN></SPAN><SPAN lang=EN-US 
style="FONT-SIZE: 9pt; COLOR: black"><!--[if gte vml 1]><v:shapetype 
id=_x0000_t75 coordsize = "21600,21600" o:preferrelative = "t" o:spt = "75" 
filled = "f" stroked = "f" path = " m@4@5 l@4@11@9@11@9@5 xe"> <v:stroke 
joinstyle = "miter"></v:stroke><v:formulas><v:f eqn = 
"if lineDrawn pixelLineWidth 0 "></v:f><v:f eqn = "sum @0 1 0 "></v:f><v:f eqn = 
"sum 0 0 @1 "></v:f><v:f eqn = "prod @2 1 2 "></v:f><v:f eqn = 
"prod @3 21600 pixelWidth "></v:f><v:f eqn = 
"prod @3 21600 pixelHeight "></v:f><v:f eqn = "sum @0 0 1 "></v:f><v:f eqn = 
"prod @6 1 2 "></v:f><v:f eqn = "prod @7 21600 pixelWidth "></v:f><v:f eqn = 
"sum @8 21600 0 "></v:f><v:f eqn = "prod @7 21600 pixelHeight "></v:f><v:f eqn = 
"sum @10 21600 0 "></v:f></v:formulas><v:path o:extrusionok = "f" 
gradientshapeok = "t" o:connecttype = "rect"></v:path><o:lock aspectratio="t" 
v:ext="edit"></o:lock></v:shapetype><v:shape id=_x0000_i1025 
style="WIDTH: 300pt; HEIGHT: 169.5pt" type = "#_x0000_t75" coordsize = 
"21600,21600" alt = ""><v:imagedata src = "./comif-42.files/image001.jpg" o:href 
= 
"http://www.gjwtech.com/pic/picserial/scdelphisp01.jpg"></v:imagedata></v:shape><![endif]--><![if !vml]><img width=400 height=226
src="./comif-42.files/image001.jpg" v:shapes="_x0000_i1025"><![endif]></SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
<P class=MsoNormal><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图</SPAN><SPAN 
lang=EN-US> 1 </SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><SPAN 
style="mso-spacerun: yes"></SPAN></SPAN>&nbsp;</P>
<P class=MsoNormal><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</SPAN><SPAN 
lang=EN-US> Unit file name</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">处填写</SPAN><SPAN 
lang=EN-US> SPCOMM</SPAN><SPAN 
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">控件所在的路径,其他各项可用默认值,点击</SPAN><SPAN 
lang=EN-US> OK</SPAN><SPAN 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -