Re: setting some parametrers for RS232 communication
Jeff Wormsley <[email protected]> Tue, 05 Jun 2007 09:22:44 -0400
| Newsgroups | gmane.comp.lang.delphi.jedi |
|---|---|
| Message-ID | <[email protected]> |
niko svako wrote:
>
> I ddid not some parameters.
>
> The paramters must be :
> StopBits: 1 Parity: NONE WordLength: 8
> EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
> Shake:80000009 Replace:80000080 XonLimit:80 XoffLimit:200
> RI:10 RM:0 RC:0 WM:0 WC:5000
> Mask: RLSD ERR
>
> But my parameters (I saw this with portman)
> StopBits: 1 Parity: NONE WordLength: 8
> EOF:0 ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
> Shake:10 Replace:c4 XonLimit:80 XoffLimit:200
> InSize: 2048 OutSize: 2048
> RI:10 RM:0 RC:0 WM:0 WC:5000
>
> How can I set these parameters?
> Shake:80000009 Replace:80000080 XonLimit:80 XoffLimit:200
> Mask: RLSD ERR
>
> regards,
>
> niko svako
>
If you want to use the low level API for this instead of a component,
then you'll need to look up and use the following functions:
var tms: TCOMMTIMEOUTS;
dcb: TDCB;
dwAction: DWORD;
ComStat : TComStat;
Handle := CreateFile(PChar(Com_PortName),
GENERIC_READ or GENERIC_WRITE,
0, // Not shared
nil, // No security attributes
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0 // No template
) ;
// Set dcb fields for handshake, etc.
SetCommState( Handle, dcb );
// Set dwAction for which buffers to purge
PurgeComm( Handle, dwAction );
// Setup buffers size
SetupComm( Handle, 1024, 1024);
// Set tms fields for various timeout values
SetCommTimeOuts( Handle, tms );
GetCommTimeouts(Handle, tms);
ReadFile(Handle, Buffer, BufLen, NumRead, nil);
ClearCommError(Handle, ErrCode, @ComStat);
WriteFile(Handle, Buffer, bufLen, NumWritten, nil);
// turn off DTR
EscapeCommFunction( Handle, CLRDTR);
GetCommModemStatus(Handle, dwStatus);
CloseHandle(Handle );
This isn't any kind of working code, but these are the tools you'll need
to set up and operate the serial port from the raw Windows API.
Hope this helps,
Jeff.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Delphi-JEDI/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/Delphi-JEDI/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[email protected]
mailto:[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/