用delphi7写的程序 要使用串口 软件打开不报错但是在软件里面串口显示无法打开
时间:2011-09-23
来源:互联网
作者: kuby6275 发布时间: 2011-09-23
作者: babydog01 发布时间: 2011-09-23
作者: jyb_9 发布时间: 2011-09-23
贴原码。。。
{初始化串口}
procedure TDataGatherForm.InitComm(Comm: TComm; CommName:String; iBaudRate:Integer;
asByteSize:String; asParity:String; asStopBits:String);
begin
Comm.CommName := CommName;
Comm.BaudRate := iBaudRate;
if asByteSize='8' then
Comm.ByteSize := TByteSize(_8)
else if asByteSize='7' then
Comm.ByteSize := TByteSize(_7)
else if asByteSize='6' then
Comm.ByteSize := TByteSize(_6)
else if asByteSize='5' then
Comm.ByteSize := TByteSize(_5);
if asParity='N' then
Comm.Parity := TParity(None)
else if asParity='O' then
Comm.Parity := TParity(Odd)
else if asParity='E' then
Comm.Parity := TParity(Even);
if asParity='N' then
Comm.Parity := TParity(None)
else if asParity='O' then
Comm.Parity := TParity(Odd)
else if asParity='E' then
Comm.Parity := TParity(Even);
if asStopBits='1' then
Comm.StopBits := TStopBits(_1)
else if asStopBits='1.5' then
Comm.StopBits := TStopBits(_1_5)
else if asStopBits='2' then
Comm.StopBits := TStopBits(_2);
end;
这是源码
作者: kuby6275 发布时间: 2011-09-23
这个只是设置参数,程序里还得判断有没这个串口,串口有没被占用
作者: jankercsdn 发布时间: 2011-09-23
br19200, br38400, br56000, br57600, br115200, br128000, br256000);
TStopBits = (sbOneStopBit, sbOne5StopBits, sbTwoStopBits);
TDataBits = (dbFive, dbSix, dbSeven, dbEight);
TParityBits = (prNone, prOdd, prEven, prMark, prSpace);
这是CPORT的参数类型,你确定你的对?
作者: jankercsdn 发布时间: 2011-09-23
// conversion functions
function StrToBaudRate(Str: string): TBaudRate;
function StrToStopBits(Str: string): TStopBits;
function StrToDataBits(Str: string): TDataBits;
function StrToParity(Str: string): TParityBits;
function StrToFlowControl(Str: string): TFlowControl;
function BaudRateToStr(BaudRate: TBaudRate): string;
function StopBitsToStr(StopBits: TStopBits): string;
function DataBitsToStr(DataBits: TDataBits): string;
function ParityToStr(Parity: TParityBits): string;
function FlowControlToStr(FlowControl: TFlowControl): string;
作者: jankercsdn 发布时间: 2011-09-23
作者: Veron_04 发布时间: 2011-09-23
作者: kuby6275 发布时间: 2011-09-23
http://download.csdn.net/detail/veron_04/1523158
7楼你的资料很不错 正在看 谢谢你哦!
作者: kuby6275 发布时间: 2011-09-23
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28