利用MSCOMM与单片机通讯,调不通
时间:2011-11-12
来源:互联网
             哪位高手帮看一下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, MSCommLib_TLB, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
MSComm1: TMSComm;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure mscomm1comm(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
mscomm1.PortOpen:=true;
button1.Enabled:=false;
button2.Enabled:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
mscomm1.InBufferCount:=0;
{mscomm1.InBufferCount:=1; }
mscomm1.InputLen:=0;
mscomm1.RThreshold:=1;
mscomm1.CommPort:=2;
mscomm1.Settings:='9600,n,8,1';
button2.Enabled:=false;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
mscomm1.portopen:=false;
button1.Enabled:=true;
button2.Enabled:=false;
end;
procedure TForm1.mscomm1comm(Sender: TObject);
var
restr:olevariant;
begin
memo1.text:='1200';
if mscomm1.commevent=2 then
begin
restr:=mscomm1.input;
memo1.text:=memo1.text+restr;
end;
end;
end.
            unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, MSCommLib_TLB, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
MSComm1: TMSComm;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure mscomm1comm(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
mscomm1.PortOpen:=true;
button1.Enabled:=false;
button2.Enabled:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
mscomm1.InBufferCount:=0;
{mscomm1.InBufferCount:=1; }
mscomm1.InputLen:=0;
mscomm1.RThreshold:=1;
mscomm1.CommPort:=2;
mscomm1.Settings:='9600,n,8,1';
button2.Enabled:=false;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
mscomm1.portopen:=false;
button1.Enabled:=true;
button2.Enabled:=false;
end;
procedure TForm1.mscomm1comm(Sender: TObject);
var
restr:olevariant;
begin
memo1.text:='1200';
if mscomm1.commevent=2 then
begin
restr:=mscomm1.input;
memo1.text:=memo1.text+restr;
end;
end;
end.
作者: WYS_2000 发布时间: 2011-11-12
             调试不通是指没反应?            
            作者: wangwei244157887 发布时间: 2011-11-13
 相关阅读 更多  
      
    热门阅读
-   office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具 office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具阅读:74 
-   如何安装mysql8.0 如何安装mysql8.0阅读:31 
-   Word快速设置标题样式步骤详解 Word快速设置标题样式步骤详解阅读:28 
-   20+道必知必会的Vue面试题(附答案解析) 20+道必知必会的Vue面试题(附答案解析)阅读:37 
-   HTML如何制作表单 HTML如何制作表单阅读:22 
-   百词斩可以改天数吗?当然可以,4个步骤轻松修改天数! 百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!阅读:31 
-   ET文件格式和XLS格式文件之间如何转化? ET文件格式和XLS格式文件之间如何转化?阅读:24 
-   react和vue的区别及优缺点是什么 react和vue的区别及优缺点是什么阅读:121 
-   支付宝人脸识别如何关闭? 支付宝人脸识别如何关闭?阅读:21 
-   腾讯微云怎么修改照片或视频备份路径? 腾讯微云怎么修改照片或视频备份路径?阅读:28 















