文件名称:delphi 串口编程
文件大小:238KB
文件格式:RAR
更新时间:2014-05-02 12:38:17
串口编程 delphi
串口 实现 function TFTransForm.OpenPort:Boolean; var ret:Integer; begin OpenPort := false; ret := sio_open(GCommData.Port); if ret <> SIO_OK then begin MxShowError('sio_open',ret); Exit; end; if PortSet() = false then begin sio_close(GCommData.Port); Exit; end; OpenPort := true; GbOpen := true; SwitchMenu(); ShowStatus(); end; procedure TFTransForm.ClosePort; begin sio_close (GCommData.Port); GbOpen := False; SwitchMenu(); ShowStatus(); end; function TFTransForm.PortSet:boolean; var port : LongInt; mode : LongInt; hw,sw : LongInt; ret : LongInt; begin port := GCommData.Port; mode := GCommData.Parity or GCommData.ByteSize or GCommData.StopBits; PortSet := false; if GCommData.Hw then hw := 3 { bit0 and bit1 } else hw := 0; if GCommData.Sw then sw := 12 { bit2 and bit3 } else sw := 0; ret := sio_ioctl(port,GCommData.BaudRate,mode); if ret<>SIO_OK then begin MxShowError('sio_ioctl',ret); Exit; end; ret := sio_flowctrl(port,hw or sw); if ret<>SIO_OK then begin MxShowError('sio_flowctrl',ret); Exit; end; ret := sio_DTR(port,Integer(GCommData.Dtr)); if ret<>SIO_OK then begin MxShowError('sio_DTR',ret); Exit; end; if not GCommData.Hw then begin ret := sio_RTS(port,Integer(GCommData.Rts)); if ret<>SIO_OK then begin MxShowError('sio_RTS',ret); Exit; end; end; ShowStatus(); PortSet := True; end;
【文件预览】:
串口编程
----FTRANS.DPR(740B)
----FSET.DFM(825B)
----FTRANS.exe(477KB)
----FtransM.dcu(9KB)
----FTRANS.dof(2KB)
----DirDlg.~dfm(842B)
----FSTAT.DFM(1KB)
----FSET.PAS(1KB)
----PCOMM.DLL(57KB)
----FTRANS.res(876B)
----FSTAT.PAS(2KB)
----FTRANSM.PAS(7KB)
----FTRANS.cfg(386B)
----FStat.dcu(5KB)
----DirDlg.ddp(51B)
----FTPROC.PAS(5KB)
----DirDlg.pas(1KB)
----DirDlg.dfm(876B)
----DirDlg.dcu(4KB)
----FTRANSM.DFM(981B)
----FSet.dcu(4KB)
----DirDlg.~pas(1KB)
----FtProc.dcu(5KB)