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

📄 +=

📁 串口 串口 串口 串口 串口 串口
💻
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0060)http://roaringwind.best.163.com/scomm/sc2serialportclass.htm -->
<HTML><HEAD><TITLE>简单而强大的多线程串口编程工具CserialPort类</TITLE>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
<META 
content=roaringwind,roaringwind.best.163.com,啸峰工作室,龚建伟,串口调试助手,VC/C编程,移动机器人,matlab仿真 
name=keywords>
<META content=串口、端口、网络通信技术,VC、C编程技术,轮式移动机器人控制相关技术,Matlab仿真及数据处理 
name=DESCRIPTION>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<STYLE type=text/css>A:link {
	COLOR: #006666; TEXT-DECORATION: none
}
A:visited {
	COLOR: #006666; TEXT-DECORATION: none
}
A:active {
	COLOR: #33cc00; TEXT-DECORATION: none
}
A:hover {
	COLOR: #33cc00; TEXT-DECORATION: underline
}
BODY {
	COLOR: #006666; FONT-FAMILY: 宋体; FONT-SIZE: 9pt
}
TABLE {
	FONT-FAMILY: 宋体; FONT-SIZE: 9pt
}
.H1 {
	FONT-SIZE: 9pt; LINE-HEIGHT: 9pt; align: center
}
TD {
	FONT-FAMILY: "宋体", "Arial", "Times New Roman"; FONT-SIZE: 9pt
}
P {
	FONT-FAMILY: "宋体", "Arial", "Times New Roman"; FONT-SIZE: 9pt
}
</STYLE>

<META content="Microsoft FrontPage 4.0" name=GENERATOR></HEAD>
<BODY background=简单而强大的多线程串口编程工具CserialPort类.files/background.gif 
bgColor=#ffffff leftMargin=0 topMargin=6 marginwidth="0" marginheight="0">
<TABLE align=center bgColor=#33ccff border=0 cellPadding=0 cellSpacing=0 
height=70 width=758>
  <TBODY>
  <TR bgColor=#99cccc vAlign=center>
    <TD align=middle height=60 width=151>
      <P align=center><A href="http://roaringwind.best.163.com/index.htm"><IMG 
      border=0 height=60 src="简单而强大的多线程串口编程工具CserialPort类.files/roaringlogo.jpg" 
      width=120></A></P></TD>
    <TD bgColor=#00ccff height=60 width=475>
      <P align=center><IMG border=0 height=60 
      src="简单而强大的多线程串口编程工具CserialPort类.files/coldfirexfs.gif" width=400> </P>
    <TD align=middle bgColor=#cbe4e4 height=60 width=132>
      <DIV align=center>
      <TABLE border=1 borderColorDark=#ffffff borderColorLight=#000000 
      cellPadding=2 cellSpacing=2 height=60 width=68>
        <TBODY>
        <TR bgColor=#dfeeee>
          <TD bgColor=#33ccff height=53>
            <DIV align=center>
            <SCRIPT language=javascript>                 <!---                     today = new Date();                     var hours = today.getHours();                     var minutes = today.getMinutes();                     var seconds = today.getSeconds();                     function initArray(){                     this.length=initArray.arguments.length                     for(var i=0;i<this.length;i++)                     this[i+1]=initArray.arguments[i] }                     var d=new initArray("<font color=red>星期天","星期一","星期二","星期三","星期四","星期五","<font color=GREEN>星期六");                      document.write(today.getYear(),"年","<br>",today.getMonth()+1,"月",today.getDate(),"日</FONT>","<br>",d[today.getDay()+1]," "); //-->                 </SCRIPT>
            </DIV></TD></TR></TBODY></TABLE></DIV></TD></TR></TBODY></TABLE>
<TABLE align=center background=简单而强大的多线程串口编程工具CserialPort类.files/top.gif 
bgColor=#99cccc border=0 cellPadding=0 cellSpacing=0 height=22 width=758>
  <TBODY>
  <TR>
    <TD height=23 width=25>
      <DIV align=center></DIV></TD>
    <TD height=23 width=74>
      <DIV align=center>
      <P align=center><A 
      href="http://roaringwind.best.163.com/index.htm">首页</A></P></DIV></TD>
    <TD height=23 width=18>&nbsp;</TD>
    <TD height=23 width=73>
      <P align=center><A href="http://roaringwind.best.163.com/article.htm" 
      target=_blank>发表论文</A></P></TD>
    <TD height=23 width=17>&nbsp;</TD>
    <TD height=23 width=73>
      <DIV align=center><A href="http://roaringwind.best.163.com/myprogram.htm" 
      target=_blank>自制软件</A></DIV></TD>
    <TD height=23 width=17>&nbsp;</TD>
    <TD height=23 width=74>
      <DIV align=center><A href="http://roaringwind.best.163.com/serialcomm.htm" 
      target=_blank>串口通讯</A></DIV></TD>
    <TD height=23 width=17>&nbsp;</TD>
    <TD height=23 width=72>
      <DIV align=center><A href="http://roaringwind.best.163.com/vcandindex.htm" 
      target=_blank>VC/C编程</A></DIV></TD>
    <TD height=23 width=17>&nbsp;</TD>
    <TD height=23 width=72>
      <DIV align=center>网络通讯</DIV></TD>
    <TD height=23 width=18>&nbsp;</TD>
    <TD height=23 width=74>
      <DIV align=center>机器人控制</DIV></TD>
    <TD height=23 width=18>&nbsp;</TD>
    <TD colSpan=2 height=23>
      <DIV align=center><A 
      href="http://roaringwind.best.163.com/matlabindex.htm" 
      target=_blank>MATLAB</A></DIV></TD>
    <TD height=23 width=29>&nbsp;</TD></TR></TBODY></TABLE>
<TABLE align=center bgColor=#ffffff border=0 cellPadding=0 cellSpacing=0 
height=443 width=758>
  <TBODY>
  <TR>
    <TD align=middle background=简单而强大的多线程串口编程工具CserialPort类.files/bck_broad.gif 
    bgColor=#cbe4e4 rowSpan=2 vAlign=top width=30> </TD>
    <TD align=left height=443 rowSpan=2 vAlign=top width=4>&nbsp;</TD>
    <TD align=middle rowSpan=2 vAlign=top width=450>
      <TABLE border=0 cellPadding=1 cellSpacing=1 height=220 width=550>
        <TBODY>
        <TR>
          <TD width=543>
            <P align=center><IMG border=0 height=3 
            src="简单而强大的多线程串口编程工具CserialPort类.files/headline1.gif" width=480> 
          </P></TD></TR>
        <TR>
          <TD width=543>
            <H1 align=center><FONT 
            face=黑体>简单而强大的多线程串口编程工具CserialPort类(附VC基于MFC单文档协议通讯源程序及详细编程步骤)</FONT></H1>
            <P align=center>作者:龚建伟&nbsp; <IMG border=0 height=37 
            src="简单而强大的多线程串口编程工具CserialPort类.files/flowerblowser.gif" 
            width=41>2001.11.09(任意转载,请注明来自啸峰工作室及网址)</P>
            <P align=center> </P></TD></TR>
        <TR>
          <TD width=543>
            <P align=center><IMG border=0 height=3 
            src="简单而强大的多线程串口编程工具CserialPort类.files/headline1.gif" 
          width=480></P></TD></TR>
        <TR>
          <TD align=middle vAlign=top width="100%">
            <P align=left><BR><BR>&nbsp;&nbsp;&nbsp; 
            老有人觉得MSComm通讯控件很土,更有人大声疾呼:忘了它吧。确实当我们对串口编程有了一定的了解后,应该用API函数写一个属于自己的串口程序,由于编程者对程序了解,对程序修改自如。但我一直没有停止过用MSComm通讯控件,那么简单的东西,对付简单的任务完全可以,但当我们需要在程序中用多个串口,而且还要做很多复杂的处理,那么最好不用MSComm通讯控件,如果这时你还不愿意自己编写底层,就用这个类:CserialPort类。<BR><BR>这是Remon 
            Spekreijse写的一个串口类, 地址在:&nbsp;
            <P align=left>&nbsp;<A 
            href="http://codeguru.earthweb.com/network/serialport.shtml" 
            target=_blank>http://codeguru.earthweb.com/network/serialport.shtml</A><BR><BR>类作者Remon 
            Spekreijse已作了一个基于对话框的同时检测4个串口示例的程序,在上面的网址和我主页的串口源码下载页也可以找到。我在这儿主要介绍如何将这个类应用到VC中基于文档的程序中。为了加深对串口数据处理的了解,我们利用这个类解决如下问题: 

            <P align=left><BR><B>问题:</B></P>
            <P 
            align=left><BR>串口2(COM2)每隔1秒向串口1(COM1)发送的NEMA格式的报文:串头为$,串尾为*,中间为一个xxxx的整数( 
            比如2345,不足4位则前面以0代替代),最后是hh校验,规定hh为xxxx四个数的半BYTE校验和,最后加上回车&lt;CR&gt;与换行&lt;LF&gt;。整个数据包为$xxxx*hh&lt;CR&gt;&lt;LF&gt;。<BR>串口1收到上述报文后,校验正确后,将发来的数据显示在视窗中,并记下发来的正确帧数和错误帧数,若正确,还向串口2发送Y,串口2收到Y后将收到的Y的计数显示在视窗中。<BR>测试方法:<BR>将三线制串口线联接上同一台计算机的两个串口,编好程序后就可测试。如果没有两个串口的微机,自己改改程序。<BR><BR>好了,你可以先下载源程序: 
            <A 
            href="http://roaringwind.best.163.com/download/scporttest.zip">scporttest.zip(大小:49KB,VC6,WIN9X/2000,SerialPort.h 
            SerialPort.cpp是两个类文件)</A><BR><BR><B>编程步骤:</B></P>
            <P align=left><BR>◆1. 

⌨️ 快捷键说明

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