社区
Delphi
帖子详情
comm1.parity:=None;
zhang_kingrose
2010-05-19 11:33:11
comm1.parity:=None;
我的程式里面提示 incompatible types:'SPCOMM.TPARITY 'AND 'UMAIN.TPARITY'
我看了 别人程式中的 是这样设置的,我的这样就提示错误
Comm1.parity:=Tparity(none);
这样也不行 不知道怎么搞的
高手 指点下吧!谢谢!
...全文
249
2
打赏
收藏
comm1.parity:=None;
comm1.parity:=None; 我的程式里面提示 incompatible types:'SPCOMM.TPARITY 'AND 'UMAIN.TPARITY' 我看了 别人程式中的 是这样设置的,我的这样就提示错误 Comm1.parity:=Tparity(none); 这样也不行 不知道怎么搞的 高手 指点下吧!谢谢!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
bdmh
2010-05-19
打赏
举报
回复
怎么不行,就得转一下Tparity
Kstudy
2010-05-19
打赏
举报
回复
main里要uses spcomm
sp
com
m 3.0 串口通信控件
使用示例: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, SP
Com
m, TeEngine, Series, ExtCtrls, TeeProcs, Chart; type TFor
m1
= class(TForm)
Com
m1
: T
Com
m;
Com
boBox1: T
Com
boBox;
Com
boBox2: T
Com
boBox;
Com
boBox3: T
Com
boBox;
Com
boBox4: T
Com
boBox;
Com
boBox5: T
Com
boBox; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Button1: TButton; Memo1: TMemo; procedure
Com
m1
ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var For
m1
: TFor
m1
; Viewstring:string; i:integer; rbuf,sbuf:array[1..6] of byte; implementation {$R *.dfm} procedure TFor
m1
.
Com
m1
ReceiveData(Sender: TObject; Buffer: Pointer; BufferLength: Word); var i:integer; begin viewstring:=' '; move(buffer^,pchar(@rbuf)^,bufferlength); for i:=1 to bufferlength do viewstring:=viewstring+inttohex(rbuf[i],2)+' '; viewstring:='接受'+viewstring; memo1.lines.add(viewstring); memo1.lines.add(' '); end; procedure TFor
m1
.Button1Click(Sender: TObject); begin //判断按键的状态可以便面打开串口出错时,要按两次按键 if Button1.Caption = '打开串口' then begin // 串口初始化 //Enum
Com
Ports(
Com
boBox1.Items);//得到串口列表
Com
m1
.
Com
mName :=
Com
boBox1.Text;
Com
m1
.BaudRate := StrToInt(
Com
boBox2.Text);
Com
m1
.
Parity
:= None; //
Com
boBox3.Text
Com
m1
.ByteSize := _8; //
Com
boBox4.Text
Com
m1
.StopBits := _1; //
Com
boBox5.Text //###########################################
Com
m1
.Start
Com
m;//打开串口 Button1.Caption := '关闭串口';
Com
boBox1.Enabled := false;
Com
boBox2.Enabled := false;
Com
boBox3.Enabled := false;
Com
boBox4.Enabled := false;
Com
boBox5.Enabled := false; //btnSend.Enabled := true; //ImageOff.Visible := false; //ImageOn.Visible := true; end else begin //##############################################
Com
m1
.Stop
Com
m; // 关闭串口 Button1.Caption := '打开串口';
Com
boBox1.Enabled := true;
Com
boBox2.Enabled := true;
Com
boBox3.Enabled := true;
Com
boBox4.Enabled := true;
Com
boBox5.Enabled := true; //btnSend.Enabled := false; //ImageOn.Visible := false; //ImageOff.Visible := true; end; end; end.
一个实用的matlab串口接收程序查询方式接收-matlab_serial_port.rar
一个实用的matlab串口接收程序查询方式接收-matlab_serial_port.rar 运行方式:下载,解压,运行serial
com
m函数即可 是最完整的,Matlab实用的串口程序,测试可以运行。 确认你的串口已经接好,要不然会出现time out现象。 clear;clc; %清除变量 g=serial; %创建串口对象 g.baudrate=2400; %设置波特率,缺省9600bit/s g.
parity
='none'; %无奇偶校验 g.stopbits=1; %停止位 g.timeout=0.5; %设置读操作完成时间为1s,缺省10s g.inputbuffersize=256; %输入缓冲区为32b,缺省值为512b %设置 ......见附件 复制代码 matlab_serial_port.rar matlab串口,接收程序
定时器的用法的心得体会
在ClassWizard中响应ID为~Dlg中的WM_TIMER消息。 使用SetTimer(nIDEvent,time,NULL)来建立一个定时器,关闭定时器用KillTimer(nIDEvent)函数。 然后可以响应ON_WM_TIMER消息来响应一个定时器完成一次记时后的程序。 响应方式如下: void CTimeDlg::OnTimer(UINT nIDEvent) { if(nIDEvent==1000)//间隔为5秒 { //处理事件 } elseif(nIDEvent==1001)//间隔为10秒 { //处理事件 } CDialog::OnTimer(nIDEvent); } 以下是给出一个串口通信定时检查接收数据的部分代码 void CMyDlg::OnOpen
Com
() { // TODO: Add your control notification handler code here if( f_open_
com
==true ) { f_open_
com
= false; GetDlgItem(IDC_OPEN_
COM
)->SetWindowText("打开通信端口"); CloseHandle(h
Com
m); KillTimer(1000); /// 关闭定时器 return ; } SetTimer(1000, 1000, NULL); ///nIDEvent==1000,time=5000ms const char *
Com
No; DCB dcb; string temp("CO
M1
");
Com
No = temp.c_str(); h
Com
m = CreateFile(
Com
No , GENERIC_READ|GENERIC_WRITE , 0 , NULL , OPEN_EXISTING , 0 , 0); if( h
Com
m==INVALID_HANDLE_VALUE ) /// 如果端口未打开 { MessageBox("打开通信端口出错!" , "
Com
m Error" , MB_OK); return ; } /// 将dcb地址传入,以取得通信参数 Get
Com
mState(h
Com
m,&dcb); /// 得知目前通信状态 dcb.BaudRate = CBR_9600; dcb.ByteSize = 8; /// 字节为8 dcb.
Parity
= NO
PARITY
; ///
Parity
为None dcb.StopBits = ONESTOPBIT; /// 1个停止位 if( !Set
Com
mState( h
Com
m , &dcb)){ MessageBox("通信端口设置出错!" , "Set Error" , MB_OK ); CloseHandle(h
Com
m); return; } GetDlgItem(IDC_OPEN_
COM
)->SetWindowText("关闭通信端口"); f_open_
com
= true; } void CMyDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default char inbuff[1024]; DWORD nBytesRead , dwError;
COM
STAT cs; /// 取得状态 Clear
Com
mError( h
Com
m , &dwError , &cs); /// 数据是否大于所准备的缓冲区 if( cs.cbInQue > sizeof(inbuff) ) { Purge
Com
m(h
Com
m , PURGE_RXCLEAR ); /// 清除通信端口数据 return ; } ReadFile(h
Com
m , inbuff , cs.cbInQue , &nBytesRead , NULL ); //接收通信端口的数据 inbuff[cs.cbInQue] = '\0'; MessageBox("打开通信端口出错!" , "
Com
m Error" , MB_OK); m_Receive.Format("%s",inbuff); UpdateData(false); CDialog::OnTimer(nIDEvent); } 李杨: for(int i=0; ;i++ ) { ... Sleep(5); if(i>...) {AfxMessageBox("错误XXX"); return;} }//跳出后记得停止一些机器动作
delphi中使用sp
com
m来实现串口通讯
(2012-02-22 22:14:41)转载▼标签: 杂谈分类: Delphi转自——飘雪的世界最近两天一直在研究sp
com
m控件的使用,之前也是很不太明白,看了很多的例子,可是按照网上很多的例子它们多少都有点瑕疵,运行不了,鉴于自己在做这方面的项目,也用了645规约试验了下,现在终于明白了一点。不过要想精通还再要学习!先把我的学习经验跟大家分享下,也让很多新手快点上手。其实相对于ms
com
m来...
serialio java_如何解决错误java.io.IOException:串行通信的nativeavailable输入/输出错误?...
我有Arm处理器,它是AllWinner A13,RAM-512mb和OS-Linaro 13.01 Ubuntu(意思是debian).现在我正在为/ dev / ttyS0制作串行通信程序.我使用netbeans在java中为双向串行通信制作了简单的程序.在我的处理器中,我将ttyS0的rx-tx缩短为环回连接检查.意味着我通过串口发送的东西,我回来了.但我得到错误.我在我的处理器上安装了op...
Delphi
5,388
社区成员
262,731
社区内容
发帖
与我相关
我的任务
Delphi
Delphi 开发及应用
复制链接
扫一扫
分享
社区描述
Delphi 开发及应用
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章