关于串口通讯的问题???(100分)

  • 主题发起人 主题发起人 dxj1976
  • 开始时间 开始时间
D

dxj1976

Unregistered / Unconfirmed
GUEST, unregistred user!
1、为什么在DELPHI里的DCB结构里找不到FPARITY这个属性啊?但帮助里有,很是挠头啊???请高手们释疑????
2、还有在DELPHI里做串口编程的程序:用RS232和RS485有什么区别吗?应该注意那些方面
 
FPARITY是Flags的一个比特
没啥区别,只管进行RS232操作,具体转换由RS232-RS485转换器负责
 
真的没有区别吗?RS485好象比RS232多个势能脚,在设计串口程序时是不是要将它给打开呀。
我们公司以前用VC++设计了一个有关RS485串口通讯的程序,据老的程序员说就是用DCB.FPARITY打开势能脚的。还有以前我们用的RS485是自己做的。
请问LABELSOFT在DELPHI中应该怎样设DCB.FPARITY这个位????急!!!!!
 
看看SPComm:
procedure TComm._SetCommState;
var
dcb: Tdcb;
commprop: TCommProp;
fdwEvtMask: DWORD;
begin
// Configure the comm settings.
// NOTE: Most Comm settings can be set through TAPI, but this means that
// the CommFile will have to be passed to this component.

GetCommState( hCommFile, dcb );
GetCommProperties( hCommFile, commprop );
GetCommMask( hCommFile, fdwEvtMask );

// fAbortOnError is the only DCB dependancy in TapiComm.
// Can't guarentee that the SP will set this to what we expect.
{dcb.fAbortOnError := False; NOT VALID}

dcb.BaudRate := FBaudRate;

dcb.Flags := 1; // Enable fBinary

if FParityCheck then
dcb.Flags := dcb.Flags or 2; // Enable parity check

// setup hardware flow control

if FOutx_CtsFlow then
dcb.Flags := dcb.Flags or 4;

if FOutx_DsrFlow then
dcb.Flags := dcb.Flags or 8;

if FDtrControl = DtrEnable then
dcb.Flags := dcb.Flags or $10
else if FDtrControl = DtrHandshake then
dcb.Flags := dcb.Flags or $20;

if FDsrSensitivity then
dcb.Flags := dcb.Flags or $40;

if FTxContinueOnXoff then
dcb.Flags := dcb.Flags or $80;

if FOutx_XonXoffFlow then
dcb.Flags := dcb.Flags or $100;

if FInx_XonXoffFlow then
dcb.Flags := dcb.Flags or $200;

if FReplaceWhenParityError then
dcb.Flags := dcb.Flags or $400;

if FIgnoreNullChar then
dcb.Flags := dcb.Flags or $800;

if FRtsControl = RtsEnable then
dcb.Flags := dcb.Flags or $1000
else if FRtsControl = RtsHandshake then
dcb.Flags := dcb.Flags or $2000
else if FRtsControl = RtsTransmissionAvailable then
dcb.Flags := dcb.Flags or $3000;

dcb.XonLim := FXonLimit;
dcb.XoffLim := FXoffLimit;

dcb.ByteSize := Ord( FByteSize ) + 5;
dcb.Parity := Ord( FParity );
dcb.StopBits := Ord( FStopBits );

dcb.XonChar := FXonChar;
dcb.XoffChar := FXoffChar;

dcb.ErrorChar := FReplacedChar;

SetCommState( hCommFile, dcb )
end;
 
labelsoft说的对,没啥区别,只管进行RS232操作,具体转换由RS232-RS485转换器负责
 

Similar threads

后退
顶部