Copyright: ComPort Library help file version 2.60.1


About TCustomComPort version 2.61a
About ComPort Library version 2.61a

ComPort Library has been in development more than two years. There has been a lot of work put in this stuff. So i simply need some kind of motivation for further develpoment of ComPort Library. I would be very happy if you could take the time and send me a postcard from your country to my home address. I hope that is not too much to ask from you.

ComPort Library help file version

2.61a.1

Author information

Name: Dejan Crnila

Year of birth: 1978

Occupation: Student of computer and information science in University of Ljubljana

E-mail: dejancrn@yahoo.com

Home page: http://www2.arnes.si/~sopecrni

Home address: Dolenja vas 111, 3312 Prebold, SLOVENIA

Special thanks to Paul Doland (E-mail: pdoland@flash.net), who provided C++ Builder support for ComPort Library.

Key features

•	Platforms: Windows NT 4.0, Windows 2000, Windows 95, Windows 98

•	Languages: Delphi 3, 4, 5 and C++ Builder 3, 4, 5

•	Components: TComPort, TComDataPacket, TComComboBox, TComRadioGroup, TComLed, TComTerminal

•	Asynchronous or synchronous Read/Write operations

•	Detailed flow control settings

•	Read/Write operation timeouts

•	Use of multithreading for monitoring port events

•	Build terminal application without a line of code

•	Source code included (cca 7000 lines)

•	A Delphi context-sensitive help file

•	and much more …


What's new in version 2.61a

ComPort Libarary version 2.60 is not compatible with some older versions. Some methods and properties have been changed, so if you have been using older versions, you will have to change a code of your program a bit.

New in version 2.61a

•	TComTerminal.WantTab property

•	TComDataPacket.AddData method

New in version 2.61

•	TComTerminal LoadFromStream/SaveToStream methods

•	lsConn signal support in TComLed component

•	Custom package forming in TComDataPacket component

New in version 2.60

•	TComTerminal control which emulates VT52, VT100 and ANSI terminals

•	WaitForEvent method in TComPort component


Asynchronous and synchronous operations

Read and write operations on serial port can be performed in two modes, asynchronous or synchronous. In synchronous mode, method that peforms operation on port does not return until operation is completed (or aborted). In asynchronous mode, method returns immidiately and does not wait for the operation to be completed. After calling asynchronous operation, the result of the method might not yet be defined, so the application should call wait method to make sure the operation is completed. Between asynchronous call of operation and wait method, the application can perform any other tasks that are not dependend on asynchronous operation result.

Each asynchronous operation has to be prepared before it is performed. To prepare asynchronous operation, call InitAsync method. This method inits PAsync type paramater. Each method that deals with asynchronous operations has PAsync parameter. Use the same parameter as in InitAsnyc method, since the TCustomComPort has to know which operation it is refering to. After the operation is completed, call DoneAsync method to free the resources.

Example (asynchronous operation)

var

  Operation1: PAsync;

begin

  InitAsync(Operation1);

  try

    ComPort1.WriteStrAsync('Hello', Operation1);

    // do some stuff here

    ComPort1.WaitForAsync(Operation1);

  finally

    DoneAsync(Operation1);

  end;

end;


Opening and closing port

Before most of the TCustomComPort methods can be succesfully called, serial port has to be opened. There are two ways to open serial port. Application can call Open method or set Connected property to True. To end a session, call Close method or set Connected property to False.

Example

begin

  ComPort1.Open; // open serial port

  // do some stuff here

  ComPort1.Close; // end session

end;


Enumerating ports

Before setting serial port number, it is useful to call EnumComPorts procedure to enumerate serial ports on local machine. Application can then assign a member of TStrings result to Port property.

Example

begin

  EnumComPorts(ComboBox1.Items);

  // do some stuff

  if ComboBox1.ItemIndex > -1 then

    ComPort1.Port := ComboBox1.Items[ComboBox1.ItemIndex];

end;


Writing to port

Write operations can be performed very easily when using TCustomComPort. There are four methods that deal with writing data.

Method	Description

Write	Writes non-typed variable to output buffer.

WriteAsync	Writes non-typed variable to output buffer in.

asynchronous mode.

WriteStr	Writes string type variable to output buffer.

WriteStrAsync	Writes string type variable to output buffer in

asnychronous mode.

Application should also properly set write timeouts. See TComTimeouts class for more detailed description.

Example

var

  Str: String;

begin

  Str := 'Hello';

  ComPort1.WriteStr(Str); // string type variable

  ComPort1.Write(Str[1], Length(Str)); // no defined type

end;


Reading from port

Reading from input buffer can be performed in two ways. Usually application calls one of the read methods inside OnRxChar event, which triggers when charachter(s) arrive in input buffer. If read method is called inside OnRxChar event, read timeouts should be set to no wait, that is, read method checks input buffer and returns immidiately, since the number of bytes in input buffer is already known. Application can also call read method outside OnRxChar, but it should set read timeouts properly. See TComTimeouts for more details.

If component is linked to other component that needs incoming data, like TComDataPacket or TCustomComTerminal, OnRxChar event is is not called, however, the component calls OnRxBuf event. The application can not read the data from input buffer inside OnRxBuf event, since it has already been read. The data is placed automatically by the component in Buffer parameter of OnRxBuf event. Whether OnRxChar or OnRxBuf event is called, can be checked with TriggersOnRxChar property.

Method	Description

Read	Reads from input buffer to non-typed variable.

ReadAsync	Reads from input buffer to non-typed variable in

asynchronous mode.

ReadStr	Reads from input buffer to string type variable.

ReadStrAsync	Reads from input buffer to string type variable in

asnychronous mode.

Example (inside OnRxChar)

procedure TForm1.ComPort1RxChar(Sender: TObject; Count: Integer);

var

  Str: String;

begin

  ComPort1.ReadStr(Str, Count);

  // do something with Str variable

end;

Example (outside OnRxChar)

var

  Str: String;

begin

  // set timeouts here or at design time

  ComPort1.ReadStr(Str, NumberOfBytes);

  // do something with Str variable

end;

Example (inside OnRxBuf)

procedure TForm1.ComPort1RxBuf(Sender: TObject; const Buffer; Count: Integer);

begin

  // application does not have to read data from input buffer

  // data is already in buffer parameter

  HandleData(Buffer, Count); // handle data

end;


Aborting asynchronous operations
Aborting asynchronous operation

Asynchronous operations can easily be aborted. Unfortunately, a specific operation cannot be aborted, however, all operations in progress can be aborted simultaneously. If operation is aborted, WaitForAsync method raises EComPort exception with WinCode property set to ERROR_OPERATION_ABORTED.

Example

var

  Operation1: PAsync;

begin

  InitAsync(Operation1);

  try

    ComPort1.WriteStrAsync('Hello', Operation1);

    // some stuff

    if { some condition } then

      ComPort1.AbortAllAsync;

    // some stuff

    ComPort1.WaitForAsync(Operation1);

  finally

    DoneAsync(Operation1);

  end;

end;


Changing properties at runtime

All TCustomComPort properties except SyncMethod can be changed at runtime while application is connected to serial port. Changes are applied immidiately. If Port property is changed while connected, serial port is closed and reopened. If properties are changed between BeginUpdate and EndUpdate methods, changes are not applied until EndUpdate method is called. If you have to change more than one property at once, wrap them inside BeginUpdate, EndUpdate methods.

Example

begin

  ComPort1.Open;

  // do some stuff

  ComPort1.FlowControl.ControlDtr := dtrEnable; // changes are applied

  // do some stuff

  BeginUpdate; // prevent changes from being applied

  ComPort1.Parity.Bits := prOdd;

  ComPort1.FlowControl.XonXoffIn := True;

  EndUpdate; // apply changes

  // do some stuff

  ComPort1.Close;

end;


Storing and loading settings

Application can easily store and load serial port settings using StoreSettings and LoadSettings methods. Settings can be stored into configuration file or registry. StoredProps property determines which properties need to be stored.

Example (Registry)

begin

  // store settings to registry

  ComPort1.StoreSettings(stRegistry, '\HKEY_LOCAL_MACHINE\Software\ComPortTest');

  // load settings

 ComPort1.LoadSettings(stRegistry, '\HKEY_LOCAL_MACHINE\Software\ComPortTest');

end;

Example (Configuration file)

begin

  // store settings to configuration file

  ComPort1.StoreSettings(stIniFile, 'c:\ComPortTest.ini');

  // load settings

  ComPort1.LoadSettings(stIniFile, 'c:\ComPortTest.ini');

end;


Using buffer functions

Application can clear input and/or ouput buffer using ClearBuffer method. Make sure that there is no asynchronous operation in progress while calling ClearBuffer, because it can cause unexpected problems.

Example

begin

  // do some stuff

  if { some condition} then

    ComPort1.ClearBuffer(True, False);  // clear input buffer

  // do some stuff

end;


Detecting signals and port state

Change of signals (CTS, DSR, RLSD) can be detected using OnXChange events. Ring indicator can also be detected using OnRing event. Application can check the state of signals anytime with Signals method.

By calling StateFlags method, application can determine whether the transmission is in progress or in wait state due to some reason.

Example

procedure TForm1.ComPort1CTSChange(Sender: TObject; OnOff: Boolean);

begin

  if OnOff then

    PrintMessage('CTS high')

  else

    if fCtlHold in ComPort1.StateFlags then  // if transmission is waiting

      PrintMessage('CTS low, transmission waiting')

    else

      PrintMessage('CTS low');

end;


Changing output flow control signals

Output flow control signals such as RTS and DTR can be handled manually, unless they are set to rtsHandshake and dtrHandshake. Use SetRTS and/or SetDTR methods to set signals to low or high state. The same thing can be accomplished using FlowControl property during a session, but it is much faster if application uses SetX methods.

Example

begin

  ComPort1.SetRTS(False); // lower RTS signal

  // do some stuff

  ComPort1.SetRTS(True); // set RTS to high

end;


Retrieving error information

When error occurs on serial port, OnError event is triggered. Check Errors parameter of event to get information on error that occured on serial port. If application is not using OnError event, it can check last errors on port using LastErrors method. LastErrors returns a set of error flags which indicate error type and clears error buffer. Therefore, if application calls LastErrors again, it returns empty result set, unless a new error occured between two calls.

Application should not call LastErrors method inside OnError event, since it has already been called in inside TCustomComPort to set Errors parameter.

Example

procedure TForm1.ComPortError(Sender: TObject; Errors: TComErrors);

begin

  if ceRxParity in Errors then

    ShowMessage('Paity error occured');

end;


Waiting for events

When Events property is not empty, a special thread is created for monitoring port events when application calls Open method. This is possible only when you use TComPort component in an application (thread) which creates message loop. Most applications have message loop (GUI, NT services). However, if you want to use TComPort component in a console application, you have to set Events property to empty before calling Open method or your application will crash. To monitor events in console application, you have to use WaitForEvent method.

Example

var

  ComPort: TComPort;

  Events: TComEvents;

begin

  ComPort := TComPort.Create(nil);

  try

    ComPort.Events := [];  // do not create monitoring thread

    ComPort.Open;  // open port

    Events := [evCTS, evDSR, evRLSD];  // define events to wait for

    ComPort.WaitForEvents(Events, nil, WaitInfinite);  // wait until at least one event happens

    if evCTS in Events then

      WriteLn('CTS Changed');  // CTS signal changed state

    ComPort.Close;  // close port

  finally

    ComPort.Free;

  end;

end;


About packets

When application is connected to some sort of serial device like data loggers which constantly send data to PC, data is usually sent in packets. Packet is a string of charachters, usually of constant size, with some start and/or stop charachters. Application can parse incoming data inside OnRxChar event handler, but its much easier to use TComDataPacket component, which does parsing process automatically.

One TCustomComPort can have more than one TComDataPacket components linked, so application can easily recieve packets of different sizes and forms.

When packet is formed OnPacket event is triggered with packet string as parameter. Any data that is discarded during the process of packet forming goes through OnDiscard event.

If TComDataPacket component is linked to TCustomComPort component, OnRxChar event of TCustomComPort is not triggered, so application has to use OnRxBuf event handler if it also needs unparsed incoming data.


Start and stop conditions

Application sets up packet by setting start and stop conditions. This is accomplished by setting StartString, StopString and Size properties of TComDataPacket component.

If StartString property is not empty, packet starts when StartString string has arrived in input buffer. If StartString is empty, packet starts immidiately when any charachter arrives in input buffer.

Stop condition is defined by StopString and Size property. If Size is 0, size stop condition is ignored. If Size is larger than 0, packet is ended when packet size reaches Size charachters. If StopString is not empty, packet stops when StopString string arrives in input buffer. If Size is larger than 0 and StopString is not empty, packet is ended when size of packet reaches Size charachters or StopString string arrives in input buffer. If Size is 0 and StopString is 0 then packet is not defined and OnPacket has the same effect as OnRxBuf event handler.

Example

Some PBX device sends data to PC in packets, starting with STX (start-of-text) charachter and ending with ETX (end-of-text) charachter. Before opening serial port, application should set up start and stop condition like this:

begin

  // set start and stop condition for packet

  ComDataPacket1.StartString := #2;

  ComDataPacket1.StopString := #3;

  // now open the port

  ComPort1.Open;

end;

Note

ComDataPacket1 has to be linked to ComPort1 component.


Custom packets

Some packets have specific form and sometimes application can't use standard start and stop conditions. To form a custom packet, application has write OnCustomStart and/or OnCustomStop event handler of TComDataPacket component. If OnCustomStart event handler is assigned, StartString start condition is ignored and it is defined inside event handler. Simillary, if OnCustomStop event handler is assigned, StopString and Size stop conditions are ignored and defined in OnCustomStop event handler.

Example

Data from serial device is sent to PC in the following format: #packet_size#packet_data

where packet_size is size of packet including header and packet_data is raw data.

var

  CurrentPacketSize: Integer;

procedure ComDataPacket1CustomStart(Sender: TObject; const Str: string; var Pos: Integer);

var

  P1, P2: Integer;

begin

  Pos := 0; // no start position yet

  P1 := System.Pos('#', Str);

  if P1 = 0 then

    Exit; // no start charachter found

  P2 := System.Pos('#', Copy(Str, P1 + 1, Length(Str) – P1)); // second # charachter

  if P2 = 0 then

    Exit;  // no second start charachter found

  P2 := P2 + P1;

  Pos := P1; // start position of packet defined at first # charachter

  try

    // determine packet size

   CurrentPacketSize := StrToInt(Copy(Str, P1 + 1, P2 – P1 - 1));

  except

   CurrentPacketSize := P2 – P1 + 1; // packet size is corrupted, cut only #…# part

  end;

end;

procedure ComDataPacket1CustomStop(Sender: TObject; const Str: string; var Pos: Integer);

begin

  if CurrentPacketSize <= Length(Str) then

    Pos := CurrentPacketSize; // set stop position

end;


 TComPort

Hierarchy       Properties       Methods       Events

TComPort is a serial communication component.

Unit

CPort

Description

Use TComPort component to easily communicate with external devices on RS232 connection, such as modems, bar code readers, PBX and so on. TCustomComPort introduces several properties for detailed setting of serial port, numerous methods to write and read from port and events for monitoring port. Write and read operations can be performed synchronously or asynchronously.


Scope

 Published

 Protected

Accessibility

 Read-only


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TCustomComPort

       |

TComPort


TComPort properties

TComPort     Legend

Derived from TCustomComPort

  BaudRate

  Buffer

  Connected

  CustomBaudRate

  DataBits

  DiscardNull

  EventChar

  Events

  FlowControl

  Handle

  Parity

  Port

  StopBits

  StoredProps

  SyncMethod

  Timeouts

  TriggersOnRxChar


TComPort events

TComPort     Legend

Derived from TCustomComPort

  OnAfterClose

  OnAfterOpen

  OnBeforeClose

  OnBeforeOpen

  OnBreak

  OnCTSChange

  OnDSRChange

  OnError

  OnRing

  OnRLSDChange

  OnRx80Full

  OnRxChar

  OnRxBuf

  OnRxFlag

  OnTxEmpty


TComPort methods

TComPort     Legend

Derived from TCustomComPort

  AbortAllAsync

  BeginUpdate

  ClearBuffer

  Close

  Create

  Destroy

  EndUpdate

  InputCount

  IsAsyncCompleted

  LastErrors

  LoadSettings

  Open

  OutputCount

  Read

  ReadAsync

  ReadStr

  ReadStrAsync

  SetBreak

  SetDTR

  SetRTS

  SetXonXoff

  ShowSetupDialog

  Signals

  StateFlags

  StoreSettings

  TransmitChar

  WaitForAsync

  WaitForEvent

  Write

  WriteAsync

  WriteStr

  WriteStrAsync


TCustomComPort

Hierarchy       Properties       Methods       Events

TCustomComPort is a base class for a serial component.

Unit

CPort

Description

TCustomComPort is a base class for TComPort and other user defined serial components. Do not create an instance of TCustomComPort, but rather use TCustomComPort descendand such as TComPort.


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TCustomComPort


TCustomComPort properties

TCustomComPort     Legend

In TCustomComPort

  BaudRate

  Buffer

  Connected

  CustomBaudRate

  DataBits

  DiscardNull

  EventChar

  Events

  FlowControl

  Handle

  Parity

  Port

  StopBits

  StoredProps

  SyncMethod

  Timeouts

  TriggersOnRxChar


TCustomComPort events

TCustomComPort     Legend

In TCustomComPort

  OnAfterClose

  OnAfterOpen

  OnBeforeClose

  OnBeforeOpen

  OnBreak

  OnCTSChange

  OnDSRChange

  OnError

  OnRing

  OnRLSDChange

  OnRx80Full

  OnRxChar

  OnRxBuf

  OnRxFlag

  OnTxEmpty


TCustomComPort methods

TCustomComPort     Legend

In TCustomComPort

  AbortAllAsync

  ApplyBuffer

  ApplyDCB

  ApplyTimeouts

  BeginUpdate

  ClearBuffer

  Close

  Create

  CreateHandle

  Destroy

  DestroyHandle

  DoAfterClose

  DoAfterOpen

  DoBeforeClose

  DoBeforeOpen

  DoBreak

  DoCTSChange

  DoDSRChange

  DoError

  DoRing

  DoRLSDChange

  DoRx80Full

  DoRxChar

  DoRxFlag

  DoTxEmpty

  EndUpdate

  InputCount

  IsAsyncCompleted

  LastErrors

  LoadIniFile

  LoadSettings

  LoadRegistry

  Open

  OutputCount

  Read

  ReadAsync

  ReadStr

  ReadStrAsync

  SetBreak

  SetDTR

  SetRTS

  SetupComPort

  SetXonXoff

  ShowSetupDialog

  Signals

  StateFlags

  StoreIniFile

  StoreSettings

  StoreRegistry

  TransmitChar

  WaitForAsync

  WaitForEvent

  Write

  WriteAsync

  WriteStr

  WriteStrAsync


TCustomComPort.Handle

TCustomComPort

Provides access to file handle of serial port.

property Handle: THandle

Description

Use Handle property when calling Win32 API functions for serial communication.

Note

Handle property is valid only when Connected property is True.


TCustomComPort.BaudRate

TCustomComPort

Sets charachter transmission speed.

type TBaudRate = (brCustom, br110, br300, br600, br1200, br2400, br4800, br9600,br14400, br19200, br38400, br56000, br57600, br115200);

property BaudRate: TBaudRate;

Description

BaudRate property represents the speed at which charchters are sent or received via RS232 conection. Both sides of connection should have the same BaudRate. If BaudRate has a value of brCustom, CustomBaudRate property is used to set baud rate.


TCustomComPort.CustomBaudRate

TCustomComPort

Sets custom charachter transmission speed.

property CustomBaudRate: Integer;

Description

Use CustomBaudRate property to set custom baud rate for charachter transmission. Ff BaudRate property is not set to brCustom, CustomBaudRate property has no effect.


TCustomComPort.DiscardNull

TCustomComPort

Enables removal of null charachters.

property DiscardNull: Boolean

Description

Specifies whether null bytes are discarded. If this property is True, null bytes are discarded when received.


TCustomComPort.EventChar

TCustomComPort

Specifies the ASCII value of the charachter to signal an event.

property EventChar: Char;

Description

When event charachter is received, both OnRxFlag and OnRxChar events are triggered.


TCustomComPort.StopBits

TCustomComPort

Specifies the number of stop bits to be used.

type TStopBits = (sbOneStopBit, sbOne5StopBits, sbTwoStopBits);

property StopBits: TStopBits;

Description

Sets the number of stop bits per charachter. StopBits can be set to one of the following values:

Value	Meaning

sbOneStopBit	1 stop bit per byte

sbOne5StopBits	1.5 stop bits per byte

sbTwoStopBits	2 stop bits per byte

Note

Use of 5 data bits with 2 stop bits is invalid combination, as is 6, 7 or 8 data bits with 1.5 stop bits.


TCustomComPort.Events

TCustomComPort

Enables or disables event monitoring.

type TComEvent = (evRxChar, evTxEmpty, evRxFlag, evRing, evBreak, evCTS, evDSR, evError, evRLSD, evRx80Full);

type TComEvents = set of TComEvent;

property Events: TComEvents;

Description

Use events property to enable or disable monitoring for specific event. If there is at least one event set, a special thread is created that monitors events on serial port.


TCustomComPort.Connected

TCustomComPort

Indicates whether or not a serial connection is active.

property Connected: Boolean;

Description

Set Connected to True to open serial port. Set Connected to False close connection to serial port. An application can check Connected to determine whether or not a serial port is open. If Connected is True, serial port is open, otherwise it is closed.

Note

Setting Connected to True is the same as calling Open method. Setting connected to False is the same as calling Close method.


TCustomComPort.Timeouts

TCustomComPort

Specifies timeout values for transmission.

property Timeouts: TComTimeouts;

Description

Use Timeouts property to set interval and complete timeout values for read and write operations.


TCustomComPort.DataBits

TCustomComPort

Specifies the number of bits in a byte.

type TDataBits = (dbFive, dbSix, dbSeven, dbEight);

property DataBits: TDataBits;

Description

Sets the number of bits in the bytes transmitted and received.

Note

Use of 5 data bits with 2 stop bits is invalid combination, as is 6, 7 or 8 data bits with 1.5 stop bits.


TCustomComPort.Buffer

TCustomComPort

Specifies the size of serial port buffer

property Buffer: TComBuffer;

Description

Use Buffer property to set the size of input and output buffer of serial port.

Note

Buffer sizes are only recommended to serial driver. The serial driver is free to use any other size.


TCustomComPort.FlowControl

TCustomComPort

Sets flow control type.

property FlowControl: TComFlowControl;

Description

Use FlowControl property to set flow control type to hardware, software or none.


TCustomComPort.Parity

TCustomComPort

Sets parity settings.

property Parity: TComParity

Description

Use Parity property to enable or disable parity checking, error replacement and parity type.


TCustomComPort.SyncMethod

TCustomComPort

Sets synchronization method for events.

type TSyncMethod = (smThreadSync, smWindowSync, smNone);

property SyncMethod: TSyncMethod;

Description

SyncMethod defines in context of which thread the events will be called. SyncMethod can be one of the following values:

Value	Meaning

smThreadSync	Events are called in context of main application thread.

smWindowSync	Events are called in context of thread that called Open method.

smNone	Events are called in context of special monitoring thread

Note

SyncMethod should usually be set to smThreadSync. Use smWindowSync in Windows NT service applications to define in which thread should events be called.


TCustomComPort.Port

TCustomComPort

Sets serial port number.

type TPort = String;

property Port: TPort;

Description

Use Port property to set serial port number. Port values have the following syntax: 'COMportnumber' or 'portnumber'. If Port is changed during a session, old port is closed and new one is opened. Application can call EnumComPorts procedure to enumerate serial ports on local computer.


TCustomComPort.TriggersOnRxChar

TCustomComPort

Indicates event which is called when data arrives in input buffer.

property TriggersOnRxChar: Boolean;

Description

Use TriggersOnRxChar property to check at runtime which event is called when data arrives in input buffer. If TriggersOnRxChar is True, OnRxChar event is called. If it returns False, OnRxBuf event is called.


TCustomComPort.StoredProps

TCustomComPort

Defines properties to be stored or loaded.

type TStoredProp = (spBasic, spFlowControl, spBuffer, spTimeouts, spParity, spOthers);

type TStoredProps = set of TStoredProp;

property StoredProps: TStoredProps;

Description

Use StoreProps property to define which properties are stored or loaded when calling StoreSettings or LoadSettings. StoredProps can have one or more of the following values:

TStoredProps	Meaning

spBasic	PortNum, BaudRate, DataBits, StopBits,

Parity and FlowControl

spFlowControl	Detailed flow control settings

spBuffer	Input and ouput buffer size

spTimeouts	Timeout values

spParity	Detailed parity settings

spOthers	EventChar and DiscardNull properties


TCustomComPort.AbortAllAsync

TCustomComPort

Aborts all pending asynchronous operations.

procedure AbortAllAsync;

Description

Call AbortAllAsync method to cancel all pending asynchronous operations. If WaitForAsync method is called after AbortAllAsync, it raises EComPort exception with WinCode ERROR_OPERATION_ABORTED.

Note

Application is still responsible to free Async pointer of all pending operations using DoneAsync method.


TCustomComPort.ApplyBuffer

TCustomComPort

Sends buffer sizes to serial driver.

procedure ApplyBuffer;

Description

ApplyBuffer method sends buffer sizes from Buffer property to serial driver.


TCustomComPort.ApplyDCB

TCustomComPort

Sets serial port settings.

procedure ApplyDCB;

Description

ApplyDCB method fills DCB record from TCustomComPort properties and sends it to serial driver.


TCustomComPort.ApplyTimeouts

TCustomComPort

Sets serial port timeouts.

procedure ApplyTimeouts;

Description

ApplyTimeouts method fills COMMTIMEOUTS record from TCustomComPort properties and sends it to serial driver.


TCustomComPort.BeginUpdate

TCustomComPort

Prevents port settings to be changed immidiatelly.

procedure BeginUpdate;

Description

Call BeginUpdate method to prevent port settings to be applied when any property is changed and Connected propertiy is set to True. After calling BeginUpdate, port settings are not applied until application calls EndUpdate method. This is useful when application has to change more settings at a time to gain performance.


TCustomComPort.EndUpdate

TCustomComPort

Applies port settings.

procedure EndUpdate;

Description

Call EndUpdate method to apply changes made to properties after BeginUpdate method.


TCustomComPort.ClearBuffer

TCustomComPort

Clears input and/or output buffer.

procedure ClearBuffer(Input, Output: Boolean);

Description

Call ClearBuffer method to empty input and/or output buffer. If Input parameter is True, input buffer is cleared. If Output parameter is True, output buffer is cleared.


TCustomComPort.Close

TCustomComPort

Closes current session.

procedure Close;

Description

Close method closes connection to serial port. If serial port is already closed, Close method does nothing. When port is closed, application can't read or write to it.

Note

Calling Close is the same as setting Connected property to False;


TCustomComPort.Create

TCustomComPort

Creates an instance of TCustomComPort class

constructor Create(AOwner: TComponent); override;

Description

Call Create to programatically create TCustomComPort object. ComPort components that are put on a form are automatically created.


TCustomComPort.CreateHandle

TCustomComPort

Creates handle of serial port.

procedure TCustomComPort.CreateHandle; virtual;

Description

CreateHandle is called by Open method. This is where connection is really established. After call to CreateHandle, Handle property becomes valid.


TCustomComPort.Destroy

TCustomComPort

Destroys TCustomComPort object.

destructor Destroy; override;

Description

Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TCustomComPort component is not already freed, and only then calls Destroy. If port is not closed, it is closed first.


TCustomComPort.DestroyHandle

TCustomComPort

Destroys serial port handle.

procedure DestroyHandle; virtual;

Description

DestroyHandle is called inside Close method. The connection to serial port is dropped and Handle property value becomes invalid.


TCustomComPort.DoBreak

TCustomComPort

Calls OnBreak event handler.

procedure DoBreak; dynamic;

Description

When serial port detects break event, DoBreak method is called. DoBreak method calls OnBreak event handler. Descendants can override this method to perform specific action.

Note

Do not call DoBreak method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoAfterClose

TCustomComPort

Calls OnAfterClose event handler.

procedure DoAfterClose; dynamic;

Description

After serial port is successfully closed, DoAfterClose method is called. DoAfterClose method calls OnAfterClose event handler. Descendants can override this method to perform specific action.

Note

Do not call DoAfterClose method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoAfterOpen

TCustomComPort

Calls OnAfterOpen event handler.

procedure DoAfterOpen; dynamic;

Description

After serial port is successfully opened, DoAfterOpen method is called. DoAfterOpen method calls OnAfterOpen event handler. Descendants can override this method to perform specific action.

Note

Do not call DoAfterOpen method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoBeforeClose

TCustomComPort

Calls OnBeforeClose event handler.

procedure DoBeforeClose; dynamic;

Description

Before serial port is closed, DoBeforeClose method is called. DoBeforeClose method calls OnBeforeClose event handler. Descendants can override this method to perform specific action.

Note

Do not call DoBeforeClose method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoBeforeOpen

TCustomComPort

Calls OnBeforeOpen event handler.

procedure DoBeforeOpen; dynamic;

Description

Before serial port is opened, DoBeforeOpen method is called. DoBeforeOpen method calls OnBeforeOpen event handler. Descendants can override this method to perform specific action.

Note

Do not call DoBeforeOpen method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoCTSChange

TCustomComPort

Calls OnCTSChange event handler.

procedure DoCTSChange(OnOff: Boolean); dynamic;

Description

When CTS signal changes, DoCTSChange method is called. DoCTSChange method calls OnCTSChange event handler. Descendants can override this method to perform specific action.

Note

Do not call DoCTSChange method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoDSRChange

TCustomComPort

Calls OnDSRChange event handler.

procedure DoDSRChange(OnOff: Boolean); dynamic;

Description

When DSR signal changes, DoDSRChange method is called. DoDSRChange method calls OnDSRChange event handler. Descendants can override this method to perform specific action.

Note

Do not call DoDSRChange method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoRLSDChange

TCustomComPort

Calls OnRLSDChange event handler.

procedure DoRLSDChange(OnOff: Boolean); dynamic;

Description

When RLSD signal changes, DoRLSDChange method is called. DoRLSDChange method calls OnRLSDChange event handler. Descendants can override this method to perform specific action.

Note

Do not call DoRLSDChange method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoRxChar

TCustomComPort

Calls OnRxChar event handler.

procedure DoRxChar(Count: Integer); dynamic;

Description

When charachter(s) arrive in input buffer, DoRxChar method is called. DoRxChar method calls OnRxChar event handler. Descendants can override this method to perform specific action.

Note

Do not call DoRxChar method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoRxFlag

TCustomComPort

Calls OnRxFlag event handler.

procedure DoRxFlag; dynamic;

Description

When event charachter arrives in input buffer, DoRxFlag method is called. DoRxFlag method calls OnRxFlag event handler. Descendants can override this method to perform specific action.

Note

Do not call DoRxFlag method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoTxEmpty

TCustomComPort

Calls OnTxEmpty event handler.

procedure DoTxEmpty; dynamic;

Description

When all charachter are transmitted from ouput buffer, DoTxEmpty method is called. DoTxEmpty method calls OnTxEmpty event handler. Descendants can override this method to perform specific action.

Note

Do not call DoTxEmpty method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoRing

TCustomComPort

Calls OnRing event handler.

procedure DoRing; dynamic;

Description

When ring indicator is detected, DoRing method is called. DoRing method calls OnRing event handler. Descendants can override this method to perform specific action.

Note

Do not call DoRing method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoError

TCustomComPort

Calls OnError event handler.

procedure DoError(Errors: TComErrors); dynamic;

Description

When all charachter are transmitted from ouput buffer, DoError method is called. DoError method calls OnError event handler. Descendants can override this method to perform specific action.

Note

Do not call DoError method directly, since it is called by TCustomComPort automatically.


TCustomComPort.DoRx80Full

TCustomComPort

Calls OnRx80Full event handler.

procedure DoRx80Full; dynamic;

Description

When all charachter are transmitted from ouput buffer, DoRx80Full method is called. DoRx80Full method calls OnRx80Full event handler. Descendants can override this method to perform specific action.

Note

Do not call DoRx80Full method directly, since it is called by TCustomComPort automatically.


TCustomComPort.InputCount

TCustomComPort

Returns the number of bytes in input buffer.

function InputCount: Integer;

Description

Call InputCount function to get the number of bytes in input buffer.


TCustomComPort.OuputCount
TCustomComPort.OutputCount

TCustomComPort

Returns the number of bytes in output buffer.

function OutputCount: Integer;

Description

Call OutputCount function to get the number of bytes in output buffer.


TCustomComPort.IsAsyncCompleted

TCustomComPort

Indicates whether asynchronous operation is completed.

function IsAsyncCompleted(AsyncPtr: PAsync): Boolean;

Description

Call IsAsyncCompleted to get asynchronous operation state. If the result is True, asynchronous operation is completed. If the result is False, operation is still in progress.

AsyncPtr parameter is variable initialized by InitAsync method.


TCustomComPort.LastErrors

TCustomComPort

Returns last occured errors on port.

type TComError = (ceFrame, ceRxParity, ceOverrun, ceBreak, ceIO, ceMode, ceRxOver, ceTxFull);

TComErrors = set of TComError;

function LastErrors: TComErrors;

Description

LastErrors function returns a set of errors that happened after last call to LastErrors. The following errors can occur on serial port:

Error	Meaning

ceFrame	The hardware detected a framing error.

ceRxParity	The hardware detected a parity error.

ceOverrun	A charachter buffer overrun has occured.

The next charachter is lost.

ceBreak	The hardware detected a break condition.

ceIO	An I/O error occured during communication

with the device.

ceMode	The requested mode is not supported.

ceRxOver	An input buffer overflow has occured.

ceTxFull	The output buffer is full


TCustomComPort.LoadSettings

TCustomComPort

Loads TCustomComPort settings from registry or file.

type TStoreType = (stRegistry, stIniFile);

procedure LoadSettings(StoreType: TStoreType; LoadFrom: String);

Description

LoadSettings method loads stored TCustomComPort property values either from a file or registry. Which properties are loaded depends on StoredProps property. StoreType parameter can have one of the following values:

StoreType	Meaning

stRegistry	LoadFrom parameter is a registry key.

stIniFile	LoadFrom parameter is a file name.


TCustomComPort.StoreSettings

TCustomComPort

Stores TCustomComPort settings to registry or file.

type TStoreType = (stRegistry, stIniFile);

procedure StoreSettings(StoreType: TStoreType; StoreTo: String);

Description

StoreSettings method stores TCustomComPort property values either in a file or registry. Which properties are stored depends on StoredProps property. StoreType parameter can have one of the following values:

StoreType	Meaning

stRegistry	StoreTo parameter is a registry key.

stIniFile	StoreTo parameter is a file name.


TCustomComPort.StoreRegistry

TCustomComPort

Stores TCustomComPort settings to registry.

procedure StoreRegistry(Reg: TRegistry); virtual;

Description

StoreRegistry method stores most of TCustomComPort properties that deal with serial port settings to registry. Descendands can override this method to store additional properties.

Note

Do not call StoreRegistry directly. The method is called inside StoreSettings method.


TCustomComPort.StoreIniFile

TCustomComPort

Stores TCustomComPort settings to configuration file.

procedure StoreIniFile(IniFile: TIniFile); virtual;

Description

StoreIniFile method stores most of TCustomComPort properties that deal with serial port settings to configuration file. Descendands can override this method to store additional properties.

Note

Do not call StoreIniFile directly. The method is called inside StoreSettings method.


TCustomComPort.LoadRegistry

TCustomComPort

Loads TCustomComPort settings from registry.

procedure LoadRegistry(Reg: TRegistry); virtual;

Description

LoadRegistry method loads most of TCustomComPort properties that deal with serial port settings from registry. Descendands can override this method to load additional properties.

Note

Do not call LoadRegistry method directly. The method is called inside LoadSettings method.


TCustomComPort.LoadIniFile
TCustomComPort.StoreIniFile

TCustomComPort

Loads TCustomComPort settings from configuration file.

procedure LoadIniFile(IniFile: TIniFile); virtual;

Description

LoadIniFile method loads most of TCustomComPort properties that deal with serial port settings from configuration file. Descendands can override this method to load additional properties.

Note

Do not call LoadIniFile directly. The method is called inside LoadSettings method.


TCustomComPort.Signals

TCustomComPort

Indicates which signals are in high state.

type TComSignal = (csCTS, csDSR, csRing, csRLSD);

TComSignals = set of TComSignal;

function Signals: TComSignals;

Description

Call Signals function to determine the state of signals. If a specific signal is included in the result, then the signal is in high state. To determine the change of signals use OnXChange events. Signals can determine the state of the following signals:

Signal	Meaning

csCTS	Clear-to-send

csDSR	Data-set-ready

csRing	Ring indicator

csRLSD	Receive-line-signal-detected


TCustomComPort.Open

TCustomComPort

Opens a connection to serial port

procedure Open;

Description

Open method connects to a serial port and sets all port settings defined in TCustomComPort properties. If a port is already opened, nothing happens.

Note

Serial port is opened in exclusive mode. That is, once it is opened by an application, it can not be opened once again in the same or another application until it is closed.


TCustomComPort.Read

TCustomComPort

Reads data from input buffer.

function Read(var Buffer; Count: Integer): Integer;

Description

Call Read function to read Count bytes into Buffer variable. The function does not return until Count bytes are read or timeout elapses.

The return value is the number of bytes that are actually read.

Note

Buffer variable must be large enough to hold Count bytes.


TCustomComPort.ReadAsync

TCustomComPort

Reads data from input buffer in asynchronous mode.

function ReadAsync(var Buffer; Count: Integer; var AsyncPtr: PAsync): Integer;

Description

Call ReadAsync function to read Count bytes into Buffer variable. The function returns immidiately and does not wait for the operation to be completed. Call WaitForAsync function to make sure that the operation is completed. AsyncPtr parameter is PAsync record initialized by InitAsync method. The application is responsible for freeing AsyncPtr pointer with DoneAsync method after the operation is completed

The return value is the number of bytes that are actually read.

Note

Buffer variable must be large enough to hold Count bytes.


TCustomComPort.ReadStr

TCustomComPort

Reads data from input buffer into string variable.

function ReadStr(var Str: String; Count: Integer): Integer;

Description

Call ReadStr function to read Count bytes into Str variable. The function does not return until Count bytes are read or timeout elapses.

The return value is the number of bytes that are actually read.

Note

Do not call ReadStr method with parameter Count set to 0.


TCustomComPort.ReadStrAsync

TCustomComPort

Reads data from input buffer into string variable in asynchronous mode.

function ReadStrAsync(var Str: String; Count: Integer; var AsyncPtr: PAsync): Integer;

Description

Call ReadStrAsync function to read Count bytes into Str variable. The function returns immidiately and does not wait for the operation to be completed. Call WaitForAsync function to make sure that the operation is completed. AsyncPtr parameter is PAsync record initialized by InitAsync method. The application is responsible for freeing AsyncPtr pointer with DoneAsync method after the operation is completed

The return value is the number of bytes that are actually read.

Note

If the result of WaitForAsync is different than Count parameter, application must manually adjust Str parameter length using SetLength function.

Do not call ReadStrAsync method with parameter Count set to 0.


TCustomComPort.Write

TCustomComPort

Writes data to output buffer.

function Write(const Buffer; Count: Integer): Integer;

Description

Call Write function to write Count bytes from Buffer variable to output buffer. The function does not return until Count bytes are written or timeout elapses.

The return value is the number of bytes that are actually written.


TCustomComPort.WriteAsync

TCustomComPort

Writes data to output buffer in asynchronous mode.

function WriteAsync(const Buffer; Count: Integer; var AsyncPtr: PAsync): Integer;

Description

Call WriteAsync function to write Count bytes of Buffer variable to output buffer. The function returns immidiately and does not wait for the operation to be completed. Call WaitForAsync function to make sure that the operation is completed. AsyncPtr parameter is PAsync record initialized by InitAsync method. The application is responsible for freeing AsyncPtr pointer with DoneAsync method after the operation is completed

The return value is the number of bytes that are actually written.


TCustomComPort.WriteStr

TCustomComPort

Writes string to output buffer.

function WriteStr(const Str: String): Integer;

Description

Call WriteStr function to write Str variable to output buffer. The function does not return until whole string is written or timeout elapses.

The return value is the number of bytes that are actually written.


TCustomComPort.WriteStrAsync

TCustomComPort

Writes string to output buffer in asynchronous mode.

function WriteStrAsync(const Str: String; var AsyncPtr: PAsync): Integer;

Description

Call WriteStrAsync function to write Str variable to output buffer. The function returns immidiately and does not wait for the operation to be completed. Call WaitForAsync function to make sure that the operation is completed. AsyncPtr parameter is PAsync record initialized by InitAsync method. The application is responsible for freeing AsyncPtr pointer with DoneAsync method after the operation is completed

The return value is the number of bytes that are actually written.


TCustomComPort.SetBreak

TCustomComPort

Places or transmission in break or non-break state.

procedure SetBreak(OnOff: Boolean);

Description

Use SetBreak function to set break or non-break transmission state. OnOff parameter can be one of the following values:

Value	Meaning

True	Suspends character transmission and places the

transmission line in a break state

False	Restores character transmission and places the

transmission line in a nonbreak state.


TCustomComPort.SetDTR

TCustomComPort

Enables or diables DTR signal.

procedure SetDTR(OnOff: Boolean);

Description

Use SetDTR function to enable or disable DTR (data-terminal-ready) signal. OnOff parameter can be one of the following values:

Value	Meaning

True	Sets DTR signal

False	Clears DTR signal

Note

If FlowControl.ControlDTR property is set to dtrHandshake, it is an error for the application to call SetDTR function and EComPort exception is raised.


TCustomComPort.SetRTS

TCustomComPort

Enables or diables RTS signal.

procedure SetRTS(OnOff: Boolean);

Description

Use SetRTS function to enable or disable RTS (request-to-send) signal. OnOff parameter can be one of the following values:

Value	Meaning

True	Sets RTS signal

False	Clears RTS signal

Note

If FlowControl.ControlRTS property is set to rtsHandshake, it is an error for the application to call SetRTS function and EComPort exception is raised.


TCustomComPort.SetXonXoff

TCustomComPort

Simulates Xon/Xoff charachter.

procedure SetXonXoff(OnOff: Boolean);

Description

Use SetXonXoff function to simulate Xon/Xoff charachter arrival. OnOff parameter can be one of the following values:

Value	Meaning

True	Causes transmission to act as if an Xon character

has been received.

False	Causes transmission to act as if an Xoff character

has been received.


TCustomComPort.SetupComPort

TCustomComPort

Sets serial port settings.

procedure SetupComPort; virtual;

Description

This method is called in Open method after CreateHandle method. SetupComPort calls ApplyDCB, ApplyTimeouts and ApplyBuffer methods to set serial port settings. Descendants can override this function to add additional settings.


TCustomComPort.ShowSetupDialog

TCustomComPort

Shows a serial port setup dialog box.

procedure ShowSetupDialog;

Description

Call ShowSetupDialog method to open a setup dialog for serial port. If port is already opened and user clicks OK button, changes are applied without reopening the port.


TCustomComPort.StateFlags

TCustomComPort

Returns serial port state flags.

TComStateFlag = (fCtlHold, fDsrHold, fRlsHold, fXoffHold, fXOffSent, fEof, fTxim);

TComStateFlags = set of TComStateFlag;

function StateFlags: TComStateFlags;

Description

Call StateFlags function to obtain information about serial communication device. Flags have the following meaning:

Flag	Meaning

fCtlHold	Specifies whether transmission is waiting for the

CTS (clear-to-send) signal to be sent. If this flag is

set, transmission is waiting.

fDsrHold	Specifies whether transmission is waiting for the

DSR (data-set-ready) signal to be sent. If this flag is

set, transmission is waiting.

fRlsHold	Specifies whether transmission is waiting for the

RLSD (receive-line-signal-detect) signal to be sent.

If this flag is set, transmission is waiting.

fXoffHold	Specifies whether transmission is waiting because

the Xoff character was received. If this flag is set,

transmission is waiting.

fXoffSent	Specifies whether transmission is waiting because

the Xoff character was transmitted. If this flag is set,

transmission is waiting. Transmission halts when the

Xoff character is transmitted to a system that takes the

next character as Xon, regardless of the actual character.

fEof	Specifies whether the end-of-file (EOF) character has

been received. If this flag is set, the EOF character has

been received.

fTxim	If this flag is set, there is a character queued for

transmission that has come to the communications

device by way of the TransmitChar function.

The communications device transmits such a character

ahead of other characters in the device's output buffer.


TCustomComPort.TransmitChar

TCustomComPort

Transmits a charachter.

procedure TransmitChar(Ch: Char);

Description

Use TransmitChar method to transmit a charachter ahead of any pending data in output buffer. The function is useful for sending an interrupt character (such as a CTRL+C) to a host system.

Character transmission is subject to normal flow control and handshaking.

Note

If the device is not transmitting, TransmitChar cannot be called repeatedly. Once TransmitChar places a character in the output buffer, the character must be transmitted before the function can be called again. If the previous character has not yet been sent, TransmitChar raises an error.


TCustomComPort.WaitForAsync

TCustomComPort

Waits until asynchronous operation is completed.

function WaitForAsync(var AsyncPtr: PAsync): Integer;

Description

Call WaitForAsync function to make sure that asynchronous operation is completed. WaitForAsync does not return until operation is finished or aborted. AsyncPtr parameter is a variable initialized by InitAsync method.

Note

Application is still responsible to free AsyncPtr variable using DoneAsync method.


TCustomComPort.WaitForEvent

TCustomComPort

Waits for event to occur on port.

procedure WaitForEvent(var Events: TComEvents; StopEvent: TEvent; Timeout: Integer);

Description

Call WaitForEvent method to wait for event to occur on serial port. Method returns when event occurs or timeout elapses. Events parameter defines which events should be monitored and returns events that have occured. StopEvent parameter is Win API event that cancels wait operation if application turns it on. Timeout parameter is number of milliseconds the application should wait. If you set Timeout parameter to WaitInfinite constant, the method does not return until at least one event occurs.

Note

WaitForEvent method is useful only when Events property is set to empty before Open method is called. If Events is not empty, a special thread is created which already calls wait function and all events are handled in OnX event handlers.


TCustomComPort.OnAfterClose

TCustomComPort

Occurs after serial port is closed.

property OnClose: TNotifyEvent;

Description

Write OnAfterClose event handler to take specific action after serial port is successfully closed using Close method or Connected property. If closing of serial port fails, OnAfterClose event is not triggered.


TCustomComPort.OnBeforeClose

TCustomComPort

Occurs before serial port is closed.

property OnBeforeClose: TNotifyEvent;

Description

Write OnBeforeClose event handler to take specific action before serial port is successfully closed using Close method or Connected property. If exception is raised inside OnBeforeClose event handler, port is not closed.


TCustomComPort.OnAfterOpen

TCustomComPort

Occurs after serial port is opened.

property OnAfterOpen: TNotifyEvent;

Description

Write OnAfterOpen event handler to take specific action after serial port is successfully opened using Open method or Connected property. If opening of serial port fails, OnAfterOpen event is not triggered.


TCustomComPort.OnBeforeOpen

TCustomComPort

Occurs before serial port is opened.

property OnBeforeOpen: TNotifyEvent;

Description

Write OnBeforeOpen event handler to take specific action after serial port is successfully opened using Open method or Connected property. If exception is raised inside OnBeforeOpen event handler, port is not opened.


TCustomComPort.OnTxEmpty

TCustomComPort

Occurs when output buffer becomes empty.

property OnTxEmpty: TNotifyEvent;

Description

Write OnTxEmpty event handler to take specific action when output buffer becomes empty, that is, all charachters in output buffer have been transmitted.


TCustomComPort.OnRx80Full

TCustomComPort

Occurs when input buffer is 80% full.

property OnRx80Full: TNotifyEvent;

Description

Write OnRx80Full event handler to take specific action when input buffer becomes 80 percent full. This is a warning to application that a input buffer overflow could occur unless there is some kind of flow control set.


TCustomComPort.OnRxFlag

TCustomComPort

Occurs when event charachter arrives.

property OnRxFlag: TNotifyEvent;

Description

Write OnRxFlag event handler to take specific action when event charachter arrives. Set EventChar property to set event charachter ASCII code.

Note

An event charachter is also placed in input buffer. The only difference between event and non-event charachter is that event charachter triggers OnRxChar and OnRxFlag events, while non-event charachter triggers only OnRxChar event.


TCustomComPort.OnBreak

TCustomComPort

Occurs when break is detected on input.

property OnBreak: TNotifyEvent;

Description

Write OnBreak event handler to take specific action when hardware detects a break on input.


TCustomComPort.OnRxChar

TCustomComPort

Occurs when charachter arrives in input buffer.

type TRxCharEvent = procedure(Sender: TObject; Count: Integer) of object;

property OnRxChar: TRxCharEvent;

Description

Write OnRxChar event handler to get information about recently arrived charachters in input buffer. Count parameter is the number of bytes in input buffer waiting to be read. OnRxChar event is usually used for reading charachters from input buffer.


TCustomComPort.OnRxBuf

TCustomComPort

Occurs when data has been read from input buffer.

type TRxBufEvent = procedure(Sender: TObject; const Buffer; Count: Integer) of object;

property OnRxBuf: TRxBufEvent;

Description

Write OnRxChar event handler to get data that had arrived in input buffer, but it has already been read from it by other linked component such as TComDataPacket or TCustomComTerminal. The application can not read the data from input buffer, because it has already been read from it and placed in Buffer parameter.

Note

Application can check whether OnRxBuf or OnRxChar event is called with TriggersOnRxChar property.


TCustomComPort.OnCTSChange

TCustomComPort

Occurs when CTS signal state has changed.

type TComSignalEvent = procedure(Sender: TObject; OnOff: Boolean) of object;

property OnCTSChange: TComSignalEvent;

Description

Write OnCTSChange event handler to take specific action when CTS (clear-to-send) signal has changed state. If OnOff parameter is True, CTS has changed from low to high state. If OnOff parameter is False, CTS has changed from high to low state.


TCustomComPort.OnDSRChange

TCustomComPort

Occurs when DSR signal state has changed.

type TComSignalEvent = procedure(Sender: TObject; OnOff: Boolean) of object;

property OnDSRChange: TComSignalEvent;

Description

Write OnDSRChange event handler to take specific action when DSR (data-set-ready) signal has changed state. If OnOff parameter is True, DSR has changed from low to high state. If OnOff parameter is False, DSR has changed from high to low state.


TCustomComPort.OnRLSDChange

TCustomComPort

Occurs when RLSD signal state has changed.

type TComSignalEvent = procedure(Sender: TObject; OnOff: Boolean) of object;

property OnRLSDChange: TComSignalEvent;

Description

Write OnRLSDChange event handler to take specific action when RLSD (receive-line-signal-detected) signal has changed state. If OnOff parameter is True, RLSD has changed from low to high state. If OnOff parameter is False, RLSD has changed from high to low state.


TCustomComPort.OnRing

TCustomComPort

Occurs when Ring indicator is detected.

property OnRing: TNotifyEvent;

Description

Write OnRing event handler to take specific action when Ring indicator is detected. This event is mainly used when programming modem application.


TCustomComPort.OnError

TCustomComPort

Occurs on line status error.

TComErrorEvent = procedure(Sender: TObject; Errors: TComErrors) of object;

property OnError: TComErrorEvent;

Description

Write OnError event handler to take specific action when a line status error occurs. Line status errors are ceFrame, ceOverrun, ceRxParity.

Note

If application calls LastErrors method inside OnError event, it returns empty result set. Use Errors paramater instead.


 TComDataPacket

Hierarchy       Properties       Methods       Events

TComData packet performs read operation in packets.

Unit

CPort

Description

Use TComDataPacket component to easily read data from input buffer in packets. The application can set stop and start condition for packet by setting TComDataPacket properties. One TCustomComPort component can have more than one TComDataPacket component linked.


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TComDataPacket


TComDataPacket properties

TComDataPacket     Legend

In TComDataPacket

  Buffer

  CaseInsensitive

  ComPort

  IncludeStrings

  MaxBufferSize

  Size

  StartString

  StopString


TComDataPacket methods

TComDataPacket     Legend

In TComDataPacket

  AddData

  Create

  Destroy

  DoDiscard

  DoPacket

  HandleBuffer

  Notification


TComDataPacket events

TComDataPacket     Legend

In TComDataPacket

  OnCustomStart

  OnCustomStop

  OnDiscard

  OnPacket


TComDataPacket.ComPort

TComDataPacket

Specifies the TCustomComPort component.

property ComPort: TCustomComPort;

Description

Set ComPort property to link TComDataPacket component with TCustomComPort component. The component gets all data from ComPort component. More than one TComDataPacket component can have the same ComPort component linked.


TComDataPacket.CaseInsensitive

TComDataPacket

Specifies case sensitivity for start and stop strings.

property CaseInsensitive: Boolean;

Description

Set CaseInsensitive property to specify case sensitivity of StartString and StopString properties. If CaseInsensitive is True, TComDataPacket ignores case. If CaseInsensitive is False, TComDataPacket does not ignore case.


TComDataPacket.MaxBufferSize

TComDataPacket

Specifies maximum buffer size.

property MaxBufferSize: Integer;

Description

Use MaxBufferSize to set maximum size of packet buffer. If buffer size reaches MaxBufferSize, buffer is discarded and current packet in buffer is removed.


TComDataPacket.IncludeStrings

TComDataPacket

Specifies whether start and stop strings are included.

property IncludeStrings: Boolean;

Description

Set IncludeStrings property to specify whether StartString and StopString strings are included in packet. If IncludeStrings is False, start and stop strings are not included inside OnPacket event.


TComDataPacket.StartString

TComDataPacket

Specifies start string.

property StartString: String;

Description

Use StartString property to set start condition for packet. If StartString is not empty, packet starts when StartString charachters arrive in input buffer. If StartString is empty, packet starts immidiately when any charachter arrives in input buffer.

Note

If TComDataPacket has OnCustomStart event assigned, StartString value is ignored and start condition is defined inside OnCustomStart event handler.


TComDataPacket.StopString

TComDataPacket

Specifies stop string.

property StopString: String;

Description

Use StopString property to set stop condition for packet. If StopString is not empty, packet ends when StopString charachters arrive in input buffer. After packet is finished, OnPacket event occurs.

Note

If Size is not 0 and greater than current packet length, packet is immidately ended regardless of StopString occurance in packet. If Size is 0 and StopString is empty, OnPacket event has the same function as OnRxBuf event of TCustomComPort component.

If TComDataPacket has OnCustomStop event assigned, both StopString and Size value are ignored and stop condition is defined inside OnCustomStop event handler.


TComDataPacket.Size

TComDataPacket

Specifies size stop condition.

property Size: Integer;

Description

Use Size property to set stop condition for packet. If current packet size is equal or greater than Size, packet is ended and OnPacket event is triggered. If Size is 0, size stop condition is not used.

Note

If StopString is not empty and StopString charachters are found in packet, packet is immidiately ended regardless of its size. If StopString is empty and Size is 0, OnPacket event has the same function as OnRxBuf event of TCustomComPort component.

If TComDataPacket has OnCustomStop event assigned, both StopString and Size value are ignored and stop condition is defined inside OnCustomStop event handler.


TComDataPacket.Buffer

TComDataPacket

Stores incoming data.

property Buffer: String;

Description

Use Buffer property to access raw data from ComPort component.


TComDataPacket.OnPacket

TComDataPacket

Occurs when packet ends.

type TComStrEvent = procedure(Sender: TObject; const Str: string) of object;

property OnPacket: TComStrEvent;

Description

Write OnPacket event to take action when packet is formed. Packet ends when one of stop conditions occurs. Parameter Str holds packet string.


TComDataPacket.OnDiscard

TComDataPacket

Occurs when data is discarded.

type TComStrEvent = procedure(Sender: TObject; const Str: string) of object;

property OnDiscard: TComStrEvent;

Description

Write OnDiscard event to specific take action when data is discarded. Any data that does not appear in OnPacket event goes through OnDiscard event.


TComDataPacket.OnCustomStart

TComDataPacket

Occurs when component needs start position of custom packet.

type TCustPacketEvent = procedure(Sender: TObject; const Str: string; var Pos: Integer) of object;

property OnCustomStart: TCustPacketEvent;

Description

Write OnCustomStart event to form custom packet. If TComDataPacket has OnCustomStart event handler assigned, start condition is defined inside OnCustomStart event handler. Str parameter is current buffer. Pos parameter is position where packet starts. Application has to set Pos parameter to define packet start position. If no data in Str parameter matches custom start condition, application should set Pos parameter to 0.


TComDataPacket.OnCustomStop

TComDataPacket

Occurs when component needs stop position of custom packet.

type TCustPacketEvent = procedure(Sender: TObject; const Str: string; var Pos: Integer) of object;

property OnCustomStop: TCustPacketEvent;

Description

Write OnCustomStop event to form custom packet. If TComDataPacket has OnCustomStop event handler assigned, stop condition is defined inside OnCustomStop event handler. Str parameter is current buffer. Pos parameter is position where packet stops. Application has to set Pos parameter to define packet stop position. If no data in Str parameter matches custom stop condition, application should set Pos parameter to 0.


TComDataPacket.Create

TComDataPacket

Creates an instance of TComDataPacket component.

constructor Create(AOwner: TComponent); override;

Description

Call Create to programatically create TComDataPacket object. TComDataPacket component that is put on a form is automatically created.


TComDataPacket.Destroy

TComDataPacket

Destroys an instance of TComDataPacket component.

destructor Destroy; override;

Description

Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TComDataPacket component is not already freed, and only then calls Destroy.


TComDataPacket.AddData

TComDataPacket

Creates an instance of TComDataPacket component.

procedure AddData(const Str: string);

Description

Use AddData method add non-comport related data to packet buffer. This method is useful when application needs to form packets from data which arrives from other sources, such as TCP/IP protocol.


TComDataPacket.Notification

TComDataPacket

Responds to notifications when objects are about to be created or destroyed.

procedure Notification(AComponent: TComponent; Operation: TOperation); override;

Description

Notification is called automatically when components are created or destroyed. After calling the inherited method, Notification checks whether the TCustomComPort component specified by the ComPort property is about to be destroyed. If the component is being destroyed, Notification sets the ComPort property to nil.


TComDataPacket.DoPacket

TCustomComPort

Calls OnPacket event handler.

procedure DoPacket(Str: String); dynamic;

Description

When packet is formed, DoPacket method is called. DoPacket method calls OnPacket event handler. Descendants can override this method to perform specific action.

Note

Do not call DoPacket method directly, since it is called by TComDataPacket automatically.


TComDataPacket.HandleBuffer

TCustomComPort

Splits data in packets.

procedure HandleBuffer; virtual;

Description

HandleBuffer method is called after data is read from input buffer and put into Buffer property. HandleBuffer splits incoming data into packets using start and stop conditions. Descandants can override this function to perform custom packet splitting.


TComDataPacket.DoDiscard

TCustomComPort

Calls OnDiscard event handler.

procedure DoDiscard(Str: String); dynamic;

Description

When data is discarded, DoDiscard method is called. DoDiscard method calls OnDiscard event handler. Descendants can override this method to perform specific action.

Note

Do not call DoDiscard method directly, since it is called by TComDataPacket automatically.


 TComComboBox

Hierarchy       Properties       Methods

TComComboBox is a windows combo box for selecting serial settings.

Unit

CPortCtl

Description

Drop TComComboBox control on the form to easily select common serial settings. TComComboBox can be linked to TCustomComPort descendand to to apply the desired settings to serial port.


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TControl

       |

TWinControl

       |

TCustomComboBox

       |

TComComboBox


TComComboBox properties

TComComboBox     Legend

In TComComboBox

  AutoApply

  ComPort

  ComProperty


TComComboBox methods

TComComboBox     Legend

In TComComboBox

  Change

  UpdateSettings

  ApplySettings

  Create

  Destroy

  Notification


TComComboBox.Create

TComComboBox

Creates an instance of TComComboBox control.

constructor Create(AOwner: TComponent); override;

Description

Call Create to programatically create TComComboBox object. TComComboBox control that is put on a form is automatically created.


TComComboBox.AutoApply

TComComboBox

Specifies whether changes are automaticaly applied.

property AutoApply: Boolean;

Description

If AutoApply is True and ComPort property is not nil, changes are automatically applied when selection in combo box is changed.

Note

If TCustomComPort component changes property that is shown in combo box, the selection in combo box is not automatically updated. The application must call UpdateSettings method.


TComComboBox.ComPort

TComComboBox

Specifies the TCustomComPort component.

property ComPort: TCustomComPort;

Description

Set ComPort property to link TComComboBox control with TCustomComPort component for applying and updating changes.


TComComboBox.ComProperty

TComComboBox

Selects serial setting.

type TComProperty = (cpNone, cpPortNum, cpBaudRate, cpDataBits, cpStopBits, cpParity, cpFlowControl);

property ComProperty: TComProperty;

Description

Set ComProperty property to select which TCustomComPort property is shown in combo box. ComProperty can be one of the following values:

Value	Meaning

cpNone	No property is shown in combo box

cpPortNum	PortNum property is shown in combo box

cpBaudRate	BaudRate property

cpDataBits	DataBits property

cpStopBits	StopBits property

cpParity	Parity.Bits property

cpFlowControl	FlowControl.FlowControl property


TComComboBox.Destroy

TComComboBox

Destroys an instance of TComComboBox control.

destructor Destroy; override;

Description

Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TComComboBox control is not already freed, and only then calls Destroy.


TComComboBox.UpdateSettings

TComComboBox

Updates selection in combo box.

procedure UpdateSettings;

Description

Call UpdateSettings method to update selection in combo box to show the correct state of TCustomComPort setting. If ComPort property is nil, the method has no effect.


TComComboBox.ApplySettings

TComComboBox

Applies settings to TCustomComPort component.

procedure ApplySettings;

Description

Call ApplySettings method to apply current selection in combo box to linked TCustomComPort component. If ComPort property is nil, the method has no effect.

Note

If AutoApply is True, selection is automatically applied when selection changes.


TComComboBox.Change

TComComboBox

Applies settings if allowed.

procedure Change; override;

Description

Change method is called automatically when user current selection is changed in combo box. If AutoApply is True and ComPort is not nil, changes are applied to linked TCustomComPort component. Change then calls OnChange event.


TComComboBox.Notification

TComComboBox

Responds to notifications when objects are about to be created or destroyed.

procedure Notification(AComponent: TComponent; Operation: TOperation); override;

Description

Notification is called automatically when components are created or destroyed. After calling the inherited method, Notification checks whether the TCustomComPort component specified by the ComPort property is about to be destroyed. If the component is being destroyed, Notification sets the ComPort property to nil.


 TComRadioGroup

Hierarchy       Properties       Methods

TComRadioGroup is a group of radio buttons for selecting serial settings.

Unit

CPortCtl

Description

Drop TComRadioGroup control on the form to easily select common serial settings. TComRadioGroup can be linked to TCustomComPort descendand to to apply the desired settings to serial port.


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TControl

       |

TWinControl

       |

TCustomControl

       |

TCustomGroupBox

       |

TCustomRadioGroup

       |

TComRadioGroup


TComRadioGroup properties

TComRadioGroup     Legend

In TComRadioGroup

  AutoApply

  ComPort

  ComProperty


TComRadioGroup methods

TComRadioGroup     Legend

In TComRadioGroup

  Click

  UpdateSettings

  ApplySettings

  Create

  Destroy

  Notification


TComRadioGroup.Create

TComRadioGroup

Creates an instance of TComRadioGroup control.

constructor Create(AOwner: TComponent); override;

Description

Call Create to programatically create TComRadioGroup object. TComRadioGroup control that is put on a form is automatically created.


TComRadioGroup.AutoApply

TComRadioGroup

Specifies whether changes are automaticaly applied.

property AutoApply: Boolean;

Description

If AutoApply is True and ComPort property is not nil, changes are automatically applied when selection in combo box is changed.

Note

If TCustomComPort component changes property that is shown in radio group, the selection in combo box is not automatically updated. The application must call UpdateSettings method.


TComRadioGroup.ComPort

TComRadioGroup

Specifies the TCustomComPort component.

property ComPort: TCustomComPort;

Description

Set ComPort property to link TComRadioGroup control with TCustomComPort component for applying and updating changes.


TComRadioGroup.ComProperty

TComRadioGroup

Selects serial setting.

type TComProperty = (cpNone, cpPortNum, cpBaudRate, cpDataBits, cpStopBits, cpParity, cpFlowControl);

property ComProperty: TComProperty;

Description

Set ComProperty property to select which TCustomComPort property is shown in radio group. ComProperty can be one of the following values:

Value	Meaning

cpNone	No property is shown in radio group

cpPortNum	PortNum property is shown in radio group

cpBaudRate	BaudRate property

cpDataBits	DataBits property

cpStopBits	StopBits property

cpParity	Parity.Bits property

cpFlowControl	FlowControl.FlowControl property


TComRadioGroup.Destroy

TComRadioGroup

Destroys an instance of TComRadioGroup control.

destructor Destroy; override;

Description

Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TComRadioGroup control is not already freed, and only then calls Destroy.


TComRadioGroup.UpdateSettings

TComRadioGroup

Updates selection in radio group.

procedure UpdateSettings;

Description

Call UpdateSettings method to update selection in radio group to show the correct state of TCustomComPort setting. If ComPort property is nil, the method has no effect.


TComRadioGroup.ApplySettings

TComRadioGroup

Applies settings to TCustomComPort component.

procedure ApplySettings;

Description

Call ApplySettings method to apply current selection in radio group to linked TCustomComPort component. If ComPort property is nil, the method has no effect.

Note

If AutoApply is True, selection is automatically applied when selection changes.


TComRadioGroup.Change
TComRadioGroup.Click

TComRadioGroup

Applies settings if allowed.

procedure Click; override;

Description

Change method is called automatically when user clicks in radio group control. If AutoApply is True and ComPort is not nil, changes are applied to linked TCustomComPort component. Click then calls OnClick event.


TComRadioGroup.Notification

TComRadioGroup

Responds to notifications when objects are about to be created or destroyed.

procedure Notification(AComponent: TComponent; Operation: TOperation); override;

Description

Notification is called automatically when components are created or destroyed. After calling the inherited method, Notification checks whether the TCustomComPort component specified by the ComPort property is about to be destroyed. If the component is being destroyed, Notification sets the ComPort property to nil.


 TComLed

Hierarchy       Properties       Methods       Events

TComLed is a led indicator for serial signals.

Unit

CPortCtl

Description

Use TComLed control to easily show the state of CTS, DSR, RLSD, Ring, Tx and Rx signals. Application can provide custom bitmaps to show the state of signals. TComLed can be linked to TCustomComPort component to automatically update the control when signal(s) change.


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TControl

       |

TGraphicControl

       |

TComLed


TComLed properties

TComLed     Legend

In TComLed

  ComPort

  GlyphOn

  GlyphOff

  Kind

  LedSignal

  State

  RingDuration


TComLed events

TComLed     Legend

In TComLed

  OnChange


TComLed methods

TComLed     Legend

In TComLed

  Create

  Destroy

  DoChange

  Notification

  Paint


TComLed.ComPort

TComLed

Specifies the TCustomComPort component.

property ComPort: TCustomComPort;

Description

Set ComPort property to link TComLed control with TCustomComPort component to show the status of LedSignal signal. If ComPort is not nil, the state of TComLed is automatically changed when signal on serial port changes.


TComLed.LedSignal

TComLed

Selects serial signal.

type TComLedSignal = (lsConn, lsCTS, lsDSR, lsRLSD, lsRing, lsRx, lsTx);

property LedSignal: TComLedSignal;

Description

Set LedSignal property to select serial signal to be monitored. If ComPort is not nil, state of TComLed automatically changes to show the state of the selected signal. LedSignal can have one of the following values:

Value	Meaning

lsConn	Serial port connected/disconnected

lsCTS	CTS signal changed state

lsDSR	DSR signal changed state

lsRLSD	RLSD signal changed state

lsRing	Ring signal detected

lsRx	Data recieve signal changed state

lsTx	Data send signal changed state


TComLed.GlyphOn

TComLed

Sets custom bitmap for “on” state.

property GlyphOn: TLedBitmap;

Description

Set GlyphOn bitmap to select the bitmap for “on” state. This bitmap is shown when State has a value of lsOn.

Note

Kind property must have a value of lkCustom.


TComLed.GlyphOff

TComLed

Sets custom bitmap for “off” state.

property GlyphOn: TLedBitmap;

Description

Set GlyphOn bitmap to select the bitmap for “off” state. This bitmap is shown when State has a value of lsOff.

Note

Kind property must have a value of lkCustom.


TComLed.Kind

TComLed

Sets kind of TComLed bitmaps

type TLedKind = (lkRedLight, lkGreenLight, lkBlueLight, lkYellowLight, lkPurpleLight, lkBulb, lkCustom);

property Kind: TLedKind;

Description

Set Kind property to select bitmaps to show the state of serial port signals. There are six predefined pairs of bitmaps. Kind property can have one of the following value.

Value	Meaning

lsRedLight	A red light is shown

lsBlueLight	A blue light.

lsGreenLight	A green light.

lsYellowLight	A yellow light.

lsPurpleLight	A purple light

lsBulb	A bulb is shown.

lsCustom	Bitmaps are provided through GlyphOn, GlyphOff properties.


TComLed.State

TComLed

Sets TComLed state.

type TLedState = (lsOff, lsOn);

property State: TLedState;

Description

Set State property to change the state of TComLed.

Note

It is invalid to change State property manually when ComPort is not nil.


TComLed.RingDuration

TComLed

Sets duration of ring signal.

property RingDuration: Integer;

Description

Ring signal is treated slightly different than other signals. TCustomComPort does not report “on” and “off” state. It only reports the detection of Ring signal. At this point, State is set to lsOn and after RingDuration miliseconds it is set to lsOff.


TComLed.OnChange

TComLed

Occurs on state change.

type TLedStateEvent = procedure(Sender: TObject; AState: TLedState) of object;

property OnChange: TLedStateEvent;

Description

OnChange event is triggered when State property changes its value either manually or automatically AState parameter is a new value of State property..


TComLed.Create

TComLed

Creates an instance of TComLed class.

constructor Create(AOwner: TComponent); override;

Description

Call Create to programatically create TComLed object. ComLed components that are put on a form are automatically created.


TComLed.Destroy

TComLed

Destroys TComLed object.

destructor Destroy; override;

Description

Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TComLed component is not already freed, and only then calls Destroy.


TComLed.DoChange

TComLed

Calls OnChange event.

procedure DoChange(AState: TLedState); dynamic;

Description

DoChange procedure is called when State property changes its value. Descendands can override this method to perform specific action on state change.

Note

Do not call DoChange method directly, since it is called by TComLed automatically.


TComLed.Notification

TComRadioGroup

Responds to notifications when objects are about to be created or destroyed.

procedure Notification(AComponent: TComponent; Operation: TOperation); override;

Description

Notification is called automatically when components are created or destroyed. After calling the inherited method, Notification checks whether the TCustomComPort component specified by the ComPort property is about to be destroyed. If the component is being destroyed, Notification sets the ComPort property to nil.


TComLed.Paint

TComRadioGroup

Paints TComLed control.

procedure Paint; override;

Description

Paint method is called as a response to WM_PAINT message. It paints TComLed control. Descendands can override this method to add custom painting to the control.


 TComTerminal

Hierarchy       Properties       Methods       Events

TComTerminal is a VT52/VT100/ANSI terminal control.

Unit

CPortCtl

Description

TComTerminal control recieves data from TCustomComPort component and puts it on the screen. The control supports connection to VT52, VT100 and ANSI terminal servers. Application can also provide custom escape code parsing in OnGetEscapeCodes event.


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TControl

       |

TWinControl

       |

TCustomControl

       |

TCustomComTerminal

       |

TComTerminal


TComTerminal properties

TComTerminal     Legend

Derived from TCustomComTerminal

  AltColor

  AppendLF

  ArrowKeys

  AutoSize

  Caret

  Color

  Connected

  ComPort

  Columns

  Emulation

  Font

  Force7Bit

  LocalEcho

  SendLF

  Rows

  WantTab

  WrapLines


TComTerminal events

TComTerminal     Legend

Derived from TCustomComTerminal

  OnChar

  OnGetEscapeCodes

  OnStrRecieved

  OnUnhandledCode


TComTerminal methods

TComTerminal     Legend

Derived from TCustomComTerminal

  Create

  Destroy

  LoadFromStream

  MoveCaret

  WriteStr

  WriteEscCode

  SaveToStream

  SelectFont

  ShowSetupDialog


TCustomComTerminal

Hierarchy       Properties       Methods       Events

TCustomComTerminal is a base class for client terminals.

Unit

CPortCtl

Description

TCustomComTerminal is a base class that provides interface for terminals. Do not create an instance of TCustomComTerminal. Use controls derived from TCustomComTerminal such as TComTerminal.


Hierarchy

TObject

       |

TPersistent

       |

TComponent

       |

TControl

       |

TWinControl

       |

TCustomControl

       |

TCustomComTerminal


TCustomComTerminal properties

TCustomComTerminal     Legend

In TCustomComTerminal

  AltColor

  AppendLF

  ArrowKeys

  AutoSize

  Caret

  Color

  Connected

  ComPort

  Columns

  Emulation

  Font

  Force7Bit

  LocalEcho

  SendLF

  Rows

  WantTab

  WrapLines


TCustomComTerminal events

TCustomComTerminal     Legend

In TCustomComTerminal

  OnChar

  OnGetEscapeCodes

  OnStrRecieved

  OnUnhandledCode


TCustomComTerminal methods

TCustomComTerminal     Legend

In TCustomComTerminal

  Create

  Destroy

  DoChar

  DoGetEscapeCodes

  DoStrRecieved

  DoUnhandledCode

  LoadFromStream

  MoveCaret

  WriteStr

  WriteEscCode

  SaveToStream

  SelectFont

  ShowSetupDialog


TCustomComTerminal.Connected

TCustomComTerminal

Indicates whether a connection is active.

property Connected: Boolean;

Description

Set Connected to True to open connection to terminal server. Set Connected to False close connection. An application can check Connected to determine whether or not a connection is active. If Connected is True, terminal is connected to server, otherwise it is disconnected.

Note

If ComPort property is nil, Connected is always false.


TCustomComTerminal.AutoSize
TCustomComTerminal.AutoApply

TCustomComTerminal

Determines whether the size of control automatically changes to accomodate its context.

property AutoSize: Boolean;

Description

Use AutoSize to make the terminal control adjust its size automatically so the client area accommodates the screen. When AutoSize is False, the terminal control has a fixed height and width. When AutoSize is True, the size of the control is readjusted whenever a change occurs that could affect the size of the control, such as a change to the font or border style.


TCustomComTerminal.Color

TCustomComTerminal

Specifies background color.

property Color: TColor;

Description

Use Color property to set background color of terminal screen. Default background color for terminals is black, but application can change the value to set custom background color.


TCustomComTerminal.AltColor

TCustomComTerminal

Specifies alternativ font color.

property AltColor: TColor;

Description

Use AltColor property to set alternative font color of terminal screen. Alternative font color is set automatically when terminal recieves escape code which requests alternativ color for current font.


TCustomComTerminal.Caret

TCustomComTerminal

Sets caret type.

type TTermCaret = (tcBlock, tcUnderline, tcNone);

property Caret: TTermCaret;

Description

Set Caret property to specify kind of caret terminal control uses. Caret or terminal cursor is visible only when terminal control has focus. Caret can have one of the following values:

Value	Meaning

tcBlock	Block style caret

tcUnderline	Underline style caret

tcNone	No caret visible


TCustomComTerminal.ComPort

TCustomComTerminal

Specifies the TCustomComPort component.

property ComPort: TCustomComPort;

Description

Set ComPort property to link TCustomComTerminal component with TCustomComPort component. The component gets all data from ComPort component. More than one TComTerminal control can have the same ComPort component linked.


TCustomComTerminal.Font

TCustomComTerminal

Specifies terminal font.

property Font: TFont;

Description

Use Font property to set terminal font. TCustomComTerminal can use only fonts which have fixed pitch size. If selected font does not match terminal requirements, default terminal font is selected instead.


TCustomComTerminal.Emulation

TCustomComTerminal

Specifies emulation type.

type TTermEmulation = (teVT100orANSI, teVT52, teNone);

property Emulation: TTermEmulation;

Description

Set Emulation property to define how escape codes are interpreted. Most of terminal servers are VT100/ANSI compatible. If Emulation has a value of teNone, application can provide custom escape code handling in OnGetEscapeCodes event handler. Emulation property can have one of the following values:

Value	Meaning

teVT100orANSI	VT100/ANSI compatible escape codes

teVT52	VT52 compatible escape codes

teNone	Do not interpret escape codes


TCustomComTerminal.Columns

TCustomComTerminal

Specifies the number of columns.

property Columns: Integer;

Description

Use Columns property to set the number of columns of terminal screen. The default value for terminals is 80.


TCustomComTerminal.Rows

TCustomComTerminal

Specifies the number of rows.

property Rows: Integer;

Description

Use Rows property to set the number of rows of terminal screen. The default value for terminals is 24.


TCustomComTerminal.ArrowKeys

TCustomComTerminal

Defines cursor keys role.

type TArrowKeys = (akTerminal, akWindows);

property ArrowKeys: TArrowKeys;

Description

Set ArrowKeys property to define how control reacts to cursor key when pressed. ArrowKeys can have a value of:

Value	Meaning

akTerminal	Cursor keys act as terminal keys. Escape code is

sent to server when cursor key is pressed.

akWindows	Cursor keys act as windows keys.


TCustomComTerminal.LocalEcho

TCustomComTerminal

Enables or disables local echo.

property LocalEcho: Boolean;

Description

Use LocalEcho property to enable or disable local echo. If LocalEcho is True, all ascii charachters that are sent to server via terminal client are put on a screen. If LocalEcho is False local charachters are not echoed on screen.

Note

It is recommended to set LocalEcho to True if terminal server does not return data to the client which had sent data.


TCustomComTerminal.SendLF

TCustomComTerminal

Enables or disables line feed sending.

property SendLF: Boolean;

Description

Use SendLF property to determine whether line feed charachter (ASCII code 10) is sent after each carriage return charachter (ASCII code 13). If SendLF is True, line feed is sent after carriage return. If SendLF is False, line feed is not sent after carriage return.


TCustomComTerminal.AppendLF

TCustomComTerminal

Enables or disables line feed appending.

property AppendLF: Boolean;

Description

Use AppendLF property to specify whether line feed charachter (ASCII code 10) is put after each recieved carriage return charachter (ASCII code 13). If AppendLF is True, line feed is appended to carriage return.


TCustomComTerminal.WrapLines

TCustomComTerminal

Enables or disables line wrapping.

property WrapLines: Boolean;

Description

Use WrapLines property to specify whether line wrapping is used. If WrapLines is True, cursor is moved to the beging of the next line when it reaches end of current line. If WrapLines is False, charachters at the end of the line are overlapped.


TCustomComTerminal.WantTab

TCustomComTerminal

Enables or disables tab key processing.

property WantTab: Boolean;

Description

Use WantTab property to define Tab key behaviour. If WantTab is True, pressing Tab key sends Tab charachter to serial port using linked TCustomComPort component. If WantTab is False, pressing Tab key changes focus from terminal to next control on the form.


TCustomComTerminal.Force7Bit

TCustomComTerminal

Determines whether 7 bit charachters are processed.

property Force7Bit: Boolean;

Description

Use Force7Bit property to enable or disable 7 bit charachter processing. If Force7Bit  is True, all incoming charachters are processed as 7 bit charachters.


TCustomComTerminal.OnChar

TCustomComTerminal

Occurs when charachter is put on a screen.

type TChScreenEvent = procedure(Sender: TObject; Ch: Char) of object;

property OnChar: TChScreenEvent;

Description

Write OnChar event to take specific action a non-escape code charachters is put on a screen. This is especially useful when application needs to log all incoming data to file or printer.


TCustomComTerminal.OnGetEscapeCodes

TCustomComTerminal

Occurs when terminal needs escape codes definition.

type TEscapeEvent = procedure(Sender: TObject; var EscapeCodes: TEscapeCodes) of object;

property OnGetEscapeCodes: TEscapeEvent;

Description

Write OnGetEscapeCodes event handler to provide custom escape code handling. If Emulation is not teNone, OnGetEscapeCodes event handler is ignored. If Emulation is teNone and EscapeCodes parameter is nil, control does not process escape codes.


TCustomComTerminal.OnStrRecieved

TCustomComTerminal

Occurs string is recieved from serial port.

type TStrRecvEvent = procedure(Sender: TObject; var Str: string) of object;

property OnStrRecieved: TStrRecvEvent;

Description

Write OnStrRecieved event handler to take specific action when after string is read from input buffer of serial port. OnStrRecieved event is called before any escape code processing is done. OnStrRecieved event is a good place to modify recieved string before its processed.


TCustomComTerminal.OnUnhandledCode

TCustomComTerminal

Occurs when escape code is not handled.

type TUnhandledEvent = procedure(Sender: TObject; Code: TEscapeCode; Data: string) of object;

property OnUnhandledCode: TUnhandledEvent;

Description

Write OnUnhandledCode event handler to take specific action when escape code has no default action or it is not recognized by selected emulation. Code parameter is the escape code value that has no default action or ecUnknown when it is not recognized. Data parameter is escape code as string type.


TCustomComTerminal.Create

TCustomComTerminal

Creates an instance of TCustomComTerminal control.

constructor Create(AOwner: TComponent); override;

Description

Call Create to programatically create TCustomComTerminal object. TCustomComTerminal component that is put on a form is automatically created.


TCustomComTerminal.Destroy

TCustomComTerminal

Destroys an instance of TCustomComTerminal control.

destructor Destroy; override;

Description

Do not call Destroy directly in an application. Instead, call Free. Free verifies that the TCustomComTerminal component is not already freed, and only then calls Destroy.


TCustomComTerminal.MoveCaret

TCustomComTerminal

Moves caret to new position.

procedure MoveCaret(AColumn, ARow: Integer);

Description

Call MoveCaret method to move caret to new position. AColumn is new column position and ARow is new row position. If AColumn or ARow parameter is out of bounds of terminal screen, caret is positioned at the edge of the screen.


TCustomComTerminal.ShowSetupDialog

TCustomComTerminal

Shows terminal setup dialog.

procedure ShowSetupDialog;

Description

Call ShowSetupDialog method to open a setup dialog for terminal. If users clicks OK button, changes are immidiately applied to terminal.


TCustomComTerminal.SelectFont

TCustomComTerminal

Opens terminal font dialog box.

procedure SelectFont;

Description

Call SelectMethod method to open a setup dialog for terminal font. Dialog allows only selection of fixed pitch size fonts.


TCustomComTerminal.WriteStr

TCustomComTerminal

Puts string on screen.

procedure WriteStr(Str: string);

Description

Call WriteStr method to put a string on screen. Method does not send data to serial port. Str parameter must not include escape codes, because terminal does not interrpret it when calling WriteStr method. If application needs to send escape code to terminal it should call WriteEscCode.


TCustomComTerminal.WriteEscCode

TCustomComTerminal

Sends escape code to terminal window.

procedure WriteEscCode(ACode: TEscapeCode; AParams: TParams);

Description

Call WriteEscCode method to send to escape code to terminal screen, but not to terminal server through serial port. ACode is escape code application needs to send and AParams are parameters specific to escape code sequence.


TCustomComTerminal.LoadFromStream

TCustomComTerminal

Loads buffer from stream.

procedure LoadFromStream(Stream: TStream);

Description

Call LoadFromStream method to load screen buffer from a stream.


TCustomComTerminal.SaveToStream

TCustomComTerminal

Saves screen buffer to stream.

procedure SaveToStream(Stream: TStream);

Description

Call SaveToStream method to save screen buffer to a stream.

Note

SaveToStream method does not save charachter atrributes, such as color, intensity, etc.


TCustomComTerminal.DoChar

TCustomComTerminal

Calls OnChar event handler.

procedure DoChar(Ch: Char); dynamic;

Description

When non-escape charachter is put on terminal screen DoChar method is called. DoChar method calls OnChar event handler. Application can override this method to take specific action when charachter is put on screen.

Note

Do not call DoChar method directly since it is called by TCustomComTerminal automatically.


TCustomComTerminal.DoGetEscapeCodes

TCustomComTerminal

Calls OnGetEscapeCodes.

procedure DoGetEscapeCodes(var EscapeCodes: TEscapeCodes); dynamic;

Description

When TCustomComTerminal needs escape code processing class DoGetEscapeCodes method is called. DoGetEscapeCodes method calls OnGetEscapeCodes event handler. Application can override this method to take specific action when terminal needs custom escape code processing class.

Note

Do not call DoGetEscapeCodes method directly since it is called by TCustomComTerminal automatically.


TCustomComTerminal.DoStrRecieved

TCustomComTerminal

Calls OnStrRecieved event handler.

procedure DoStrRecieved(var Str: string); dynamic;

Description

When string is read out of input buffer DoStrRecieved method is called. DoStrRecieved method calls OnStrRecieved event handler. Application can override this method to take specific action when string is read out of input buffer.

Note

Do not call DoStrRecieved method directly since it is called by TCustomComTerminal automatically.


TCustomComTerminal.DoUnhandledCode

TCustomComTerminal

Calls OnUnhandledCode event handler.

procedure DoUnhandledCode(Code: TEscapeCode; Data: string); dynamic;

Description

When terminal cannot interpret escape code DoUnhandledCode method is called. DoUnhandledCode method calls OnUnhandledCode event handler. Application can override this method to take specific action when escape code is unknown.

Note

Do not call DoUnhandledCode method directly since it is called by TCustomComTerminal automatically.


TComTimeouts

Hierarchy       Properties       Methods

Defines timeouts for read and write operations.

Unit

CPort

Description

Timeout property defines detailed timeout settings for read and write operations. When timeout for specific operation elapses, operation is aborted, however, no errors are reported.

Two types of time-outs are enabled by the time-out parameters. An interval time-out occurs when the time between the receipt of any two characters exceeds a specified number of milliseconds. Timing starts when the first character is received and is restarted when each new character is received. A total time-out occurs when the total amount of time consumed by a read operation exceeds a calculated number of milliseconds. Timing starts immediately when the I/O operation begins. Write operations support only total time-outs. Read operations support both interval and total time-outs, which can be used separately or combined.

The time, in milliseconds, of the total time-out period for a read or write operation is calculated by using the multiplier and constant:

Timeout = (MULTIPLIER * number_of_bytes) + CONSTANT


Hierarchy

TObject

       |

TPersistent

       |

TComTimeouts


TComTimeouts properties

TComTimeouts     Legend

In TComTimeouts

  ComPort

  ReadInterval

  ReadTotalConstant

  ReadTotalMultiplier

  WriteTotalConstant

  WriteTotalMultiplier


TComTimeouts methods

TComTimeouts     Legend

In TComTimeouts

  AssignTo

  Create


TComTimeouts.ComPort

TComTimeouts

Determines TCustomComPort component.

property ComPort: TCustomComPort;

Description

Use ComPort property to determine TCustomComPort component which this class belongs to.


TComTimeouts.ReadInterval

TComTimeouts

Specifies read interval timeout.

property ReadInterval: Integer;

Description

Specifies the maximum time, in milliseconds, allowed to elapse between the arrival of two characters on the communications line. During a read operation, the time period begins when the first character is received. If the interval between the arrival of any two characters exceeds this amount, the read operation is completed and any buffered data is returned. A value of zero indicates that interval time-outs are not used.

Note

A value of -1, combined with zero values for both the ReadTotalConstant and ReadTotalMultiplier properties, specifies that the read operation is to return immediately with the characters that have already been received, even if no characters have been received.


TComTimeouts.ReadTotalConstant

TComTimeouts

Specifies constant for read total timeout.

property ReadTotalConstant: Integer;

Description

Specifies the constant, in milliseconds, used to calculate the total time-out period for read operations. For each read operation, this value is added to the product of the ReadTotalMultiplier property and the requested number of bytes.

Note

A value of zero for both the ReadTotalMultiplier and ReadTotalConstant properties indicates that total time-outs are not used for read operations.

If an application sets ReadInterval and ReadTotalMultiplier to -1 and sets ReadTotalConstant to a value greater than zero, one of the following occurs when the read function is called:

•	If there are any characters in the input buffer, read function returns immediately with the characters in the buffer.

•	If there are no characters in the input buffer, read function waits until a character arrives and then returns immediately.

•	If no character arrives within the time specified by ReadTotalConstant, read function times out.


TComTimeouts.ReadTotalMultiplier

TComTimeouts

Specifies multiplier for read total timeout.

property ReadTotalMultiplier: Integer;

Description

Specifies the multiplier, in milliseconds, used to calculate the total time-out period for read operations. For each read operation, this value is multiplied by the requested number of bytes to be read.

Note

A value of zero for both ReadTotalTimeout the and ReadTotalConstant properties indicates that total time-outs are not used for read operations.


TComTimeouts.WriteTotalConstant

TComTimeouts

Specifies constant for write total timeout.

property WriteTotalConstant: Integer;

Description

Specifies the constant, in milliseconds, used to calculate the total time-out period for write operations. For each write operation, this value is added to the product of the WriteTotalMultiplier properties and the number of bytes to be written.

Note

A value of zero for both the WriteTotalMultiplier and WriteTotalConstant properties indicates that total time-outs are not used for write operations.


TComTimeouts.WriteTotalMultiplier

TComTimeouts

Specifies multiplier for write total timeout.

property WriteTotalMultiplier: Integer;

Description

Specifies the multiplier, in milliseconds, used to calculate the total time-out period for write operations. For each write operation, this value is multiplied by the number of bytes to be written.

Note

A value of zero for both the WriteTotalMultiplier and WriteTotalConstant properties indicates that total time-outs are not used for write operations.


TComTimeouts.Create

TComTimeouts

Creates an instance of TComTimeouts class.

constructor TComTimeouts.Create;

Description

Use Create constructor to programmatically create an instance of TComTimeouts class. Create sets following properties to default values:

Property	Value

ReadInterval	-1

ReadTotalMultiplier	0

ReadTotalConstant	0

WriteTotalMultiplier	100

WriteTotalConstant	1000


TComTimeouts.AssignTo

TComTimeouts

Handles assignments for TComTimeouts objects.

procedure AssignTo(Dest: TPersistent); override;

Description

Call AssignTo to copy the values of one TComTimeouts object to another.

AssignTo overrides the inherited method in order to handle assignments specific to TComTimeouts objects.


TComFlowControl

Hierarchy       Properties       Methods

Defines flow control settings.

Unit

CPort

Description

Flow control, sometimes called “handshaking”, is a concept that prevents buffer overflowing when the bytes are received faster than they are processed. There are basically two types of flow control, hardware and software.

The most common settings for flow control are:

Flow control	Values

RTS/CTS (Hardware)	ControlRTS := rtsHandshake;

OutCTSFlow := True;

Xon/Xoff (Software)	XonXoffOut := True;

XonXoffIn := True;


Hierarchy

TObject

       |

TPersistent

       |

TComFlowControl


TComFlowControl properties

TComFlowControl     Legend

In TComFlowControl

  ComPort

  ControlDTR

  ControlRTS

  DSRSensitivity

  FlowControl

  OutCTSFlow

  OutDSRFlow

  TxContinueOnXoff

  XoffChar

  XonChar

  XonXoffIn

  XonXoffOut


TComFlowControl methods

TComFlowControl     Legend

In TComFlowControl

  AssignTo

  Create


TComFlowControl.ComPort

TComFlowControl

Determines TCustomComPort component.

property ComPort: TCustomComPort;

Description

Use ComPort property to determine TCustomComPort component which this class belongs to.


TComFlowControl.ControlDTR

TComFlowControl

Specifies DTR flow control.

type TDTRFlowControl = (dtrDisable, dtrEnable, dtrHandshake);

property ControlDTR: TDTRFlowControl;

Description

ControlDTR sets DTR (data-terminal-ready) flow control type.

Value	Meaning

dtrDisable	Disables the DTR line when the device is

 	opened and leaves it disabled.

dtrEnable	Enables the DTR line when the device is

 	opened and leaves it on.

dtrHandshake	Enables DTR handshaking. If handshaking is enabled,

 	it is an error for the application to adjust the line

 	by using the SetDTR function


TComFlowControl.ControlRTS

TComFlowControl

Specifies RTS flow control.

type TRTSFlowControl = (dtrDisable, dtrEnable, dtrHandshake, dtrToggle);

property ControlRTS: TRTSFlowControl;

Description

ControlRTS sets RTS (request-to-send) flow control type.

Value	Meaning

rrsDisable	Disables the RTS line when the device is

 	opened and leaves it disabled.

rtsEnable	Enables the RTS line when the device is

 	opened and leaves it on.

rtsHandshake	Enables RTS handshaking. The driver raises

 	the RTS line when the "type-ahead" (input) buffer

 	is less than one-half full and lowers the RTS line

 	when the buffer is more than three-quarters full.

 	If handshaking is enabled, it is an error for the application

 	to adjust the line by using the SetRTS function.

rtsToggle	Specifies that the RTS line will be high if bytes are

 	available for transmission. After all buffered bytes

 	have been sent, the RTS line will be low.


TComFlowControl.DSRSensitivity

TComFlowControl

Enables or disables DSR sensitivity.

property DSRSensitivity: Boolean;

Description

Specifies whether the communications driver is sensitive to the state of the DSR signal. If this property is True, the driver ignores any bytes received, unless the DSR input line is high.


TComFlowControl.FlowControl

TComFlowControl

Sets common flow control type.

type TFlowControl = (fcHardware, fcSoftware, fcNone, fcCustom);

property FlowControl: TFlowControl;

Description

Set FlowControl property to set one of common flow control types (e.g. hardware, software). FlowControl property is virtual property, so its value depends on the following properties: ControlRTS, OutCTSFlow, XonXoffIn and XonXoffOut.

Note

Setting FlowControl property usually changes other properties of TComFlowControl class. Also setting other properties of TComFlowControl class changes FlowControl property.


TComFlowControl.OutCTSFlow

TComFlowControl

Enables or disables CTS signal monitoring.

property OutCTSFlow: Boolean;

Description

Specifies whether the CTS (clear-to-send) signal is monitored for output flow control. If this property is True and CTS is turned off, output is suspended until CTS is sent again.


TComFlowControl.OutDSRFlow

TComFlowControl

Enables or disables DSR signal monitoring.

property OutDSRFlow: Boolean;

Description

Specifies whether the DSR (data-set-ready) signal is monitored for output flow control. If this property is True and DSR is turned off, output is suspended until DSR is sent again.


TComFlowControl.TxContinueOnXoff

TComFlowControl

Enables or disables transmission after Xoff charachter has been received.

property TxContinueOnXoff: Boolean;

Description

Specifies whether transmission stops when the input buffer is full and the driver has transmitted the XoffChar character. If this property is True, transmission continues after the driver has transmitted the XoffChar character to stop receiving bytes. If this property is False, transmission does not continue until the driver has transmitted the XonChar character to resume reception.


TComFlowControl.XoffChar

TComFlowControl

Specifies the value of the Xoff charachter.

property XoffChar: Char;

Description

Specifies the value of the Xoff character for both transmission and reception. This is usally charachter of ASCII code 19.


TComFlowControl.XonChar

TComFlowControl

Specifies the value of the Xon charachter.

property XonChar: Char;

Description

Specifies the value of the Xon character for both transmission and reception. This is usally charachter of ASCII code 17.


TComFlowControl.XonXoffIn

TComFlowControl

Enables or disables software input flow control.

property XonXoffIn: Boolean;

Description

Specifies whether Xon/Xoff flow control is used during reception. If this property is True, the XoffChar character is sent when the input buffer comes within maximum byte limit of being full, and the XonChar character is sent when the input buffer comes within minimum byte limit of being empty.


TComFlowControl.XonXoffOut

TComFlowControl

Enables or disables software output flow control.

property XonXoffOut: Boolean;

Description

Specifies whether Xon/Xoff flow control is used during transmission. If this property is True, transmission stops when the XoffChar character is received and starts again when the XonChar character is received.


TComFlowControl.Create

TComFlowControl

Creates an instance of TComFlowControl class.

constructor TComFlowControl.Create;

Description

Use Create constructor to programmatically create an instance of TComFlowControl class.When object is instantiated, all flow control settings are disabled.


TComFlowControl.AssignTo

TComFlowControl

Handles assignments for TComFlowControl objects.

procedure AssignTo(Dest: TPersistent); override;

Description

Call AssignTo to copy the values of one TComFlowControl object to another.

AssignTo overrides the inherited method in order to handle assignments specific to TComFlowControl objects.


TComBuffer

Hierarchy       Properties       Methods

Defines input and ouput buffer sizes.

Unit

CPort

Description

Use TComBuffer to specify input and ouput buffer size.However, these are only recommended buffer sizes. Serial driver accepts this values, but it is free to use any other input and ouput buffer scheme.


Hierarchy

TObject

       |

TPersistent

       |

TComBuffer


TComBuffer properties

TComBuffer     Legend

In TComBuffer

  ComPort

  InputSize

  OutputSize


TComBufferMethods

TComBuffer     Legend

In TComBuffer

  AssignTo

  Create


TComBuffer.ComPort

TComBuffer

Determines TCustomComPort component.

property ComPort: TCustomComPort;

Description

Use ComPort property to determine TCustomComPort component which this class belongs to.


TComBuffer.InputSize

TComBuffer

Specifies input buffer size.

property InputSize: Integer;

Description

Use InputSize to specify the recommended size, in bytes, of the device's internal input buffer.


TComBuffer.OutputSize

TComBuffer

Specifies output buffer size.

property OutputSize: Integer;

Description

Use OutputSize to specify the recommended size, in bytes, of the device's internal output buffer.


TComBuffer.Create

TComBuffer

Creates an instance of TComBuffer class.

constructor TComBuffer.Create;

Description

Use Create constructor to programmatically create an instance of TComBuffer class. Create sets the following default values.

Property	Value

InputSize	1024

OutputSize	1024


TComBuffer.AssignTo

TComBuffer

Handles assignments for TComBuffer objects.

procedure AssignTo(Dest: TPersistent); override;

Description

Call AssignTo to copy the values of one TComBuffer object to another.

AssignTo overrides the inherited method in order to handle assignments specific to TComBuffer objects.


TComParity

Hierarchy       Properties       Methods

Defines parity checking and charachter replacing.

Unit

CPort

Description

TComParity object specifies parity bits, parity checking, error reporting and charachter replacement.


Hierarchy

TObject

       |

TPersistent

       |

TComParity


TComParity properties

TComParity     Legend

In TComParity

  Bits

  Check

  ComPort

  Replace

  ReplaceChar


TComParity methods

TComParity     Legend

In TComParity

  AssignTo

  Create


TComParity.ComPort

TComParity

Determines TCustomComPort component.

property ComPort: TCustomComPort;

Description

Use ComPort property to determine TCustomComPort component which this class belongs to.


TComParity.Bits

TComParity

Specifies the parity scheme.

type TParityBits = (prNone, prOdd, prEven, prMark, prSpace);

property Bits: TParityBits;

Description

Specifies the parity scheme to be used. This property can be one of the following values.

Value	Meaning

prNone	No parity

prOdd	Odd

prEven	Even

prMark	Mark

prSpace	Space


TComParity.Check

TComParity

Enables or disables parity check.

property Check: Boolean;

Description

Specifies whether parity checking is enabled. If this property is True, parity checking is performed and errors are reported in OnError event as ceRxParity error.


TComParity.Replace

TComParity

Enables or disables charachter replacement.

property Replace: Boolean;

Description

Specifies whether bytes received with parity errors are replaced with the character specified by the ReplaceChar property. If this property is True and the Check property is True, replacement occurs.


TComParity.ReplaceChar

TComParity

Specifies error replacing charachter.

property ReplaceChar: Char;

Description

Specifies the ASCII value of the character used to replace bytes received with a parity error.


TComParity.Create

TComParity

Creates an instance of TComParity class.

constructor TComParity.Create;

Description

Use Create constructor to programmatically create an instance of TComBuffer class. Create constructor disables parity checking and charachter replacement and sets no parity.


TComParity.AssignTo

TComParity

Handles assignments for TComParity objects.

procedure AssignTo(Dest: TPersistent); override;

Description

Call AssignTo to copy the values of one TComParity object to another.

AssignTo overrides the inherited method in order to handle assignments specific to TComParity objects.


EComPort

Hierarchy       Properties       Methods

EComPort is the exception class for failures on serial port.

Unit

CPort

Description

EComPort exception is raised on error that occurs inside TCustomComPort component. Check EComPort properties for additional information about exception.


Hierarchy

Exception

       |

EComPort


EComPort properties

EComPort     Legend

In EComPort

  Code

  WinCode


EComPort methods

EComPort     Legend

In EComPort

  Create

  CreateNoCode


EComPort.Code

EComPort

Specifies detailed error type.

property Code: Integer;

Description

Use Code property to obtain information about error type. See Error codes for detailed description of error codes.


EComPort.WinCode

EComPort

Specifies windows error code.

property WinCode: Integer;

Description

Use WinCode property to get information about windows error code.

Note

WinCode is 0 only when EComPort was created with CreateNoCode constructor.


EComPort.Create

EComPort

Creates an instance of EComPort exception.

constructor Create(ACode: Integer; AWinCode: Integer);

Description

Constructor Create instantiates EComPort exception. ACode parameter is a ComPort exception type. See Error codes for detailed description of error types. AWinCode parameter is a windows error code.


EComPort.CreateNoCode

EComPort

Creates an instance of EComPort exception.

constructor CreateNoCode(ACode: Integer);

Description

Constructor CreateNoCode instantiates EComPort exception. ACode parameter is a TCustomComPort exception code. See Error codes for detailed description of error codes.

Note

CreateNoCode sets WinCode property to 0.


Other procedures, types and constants

Unit

CPort

Procedures

InitAsync

DoneAsync

EnumComPorts

Conversion functions

Unit

CPortCtl

ComTerminalFont


InitAsync procedure

Inits PAsync variable.

procedure InitAsync(var AsyncPtr: PAsync);

Description

Call InitAsync procedure init PAsync type variable. PAsync type is used to identify operation in all methods that deal with asynchronous operations. After the operation is completed, application is responsible for freeing PAsync type variable with DoneAsync procedure.


DoneAsync procedure

Frees PAsync variable.

procedure DoneAsync(var AsyncPtr: PAsync);

Description

Call DoneAsync procedure to free PAsync type variable after asynchronous operation is completed.


EnumComPorts procedure
EnumComPorts

Enumerates serial ports on local computer.

procedure EnumComPorts(Ports: TStrings);

Description

Call EnumComPorts to fill Ports paramater with installed com ports on local computer. Ports parameter is a TString descendant created and maintained by the application. Application can assign Ports member to Port property to set port number.


Conversion functions

Use these functions to easily convert one type to other.

procedure BaudRateToStr(BaudRate: TBaudRate): String;

procedure DataBitsToStr(DataBits: TDataBits): String;

procedure StopBitsToStr(StopBits: TStopBits): String;

procedure ParityToStr(Parity: TParityBits): String;

procedure FlowControlToStr(FlowControl: TFlowControl): String;

procedure StrToBaudRate(Str: String): TBaudRate;

procedure StrToDataBits(Str: String): TDataBits;

procedure StrToStopBits(Str: String): TStopBits;

procedure StrToParity(Str: String): TParityBits;

procedure StrToFlowControl(Str: String): TFlowControl;


ComTerminalFont variable

Default terminal font.

var ComTerminalFont: TFont;

Description

ComTerminalFont is default font fot TCustomComTerminal component and its descendants.


Error codes

List of error codes

Code	Constant	Meaning

1	CError_OpenFailed	Failed to open serial port.

2	CError_WriteFailed	Error occured while writing to port.

3	CError_ReadFailed	Error occured while reading from port.

4	CError_InvalidAsync	PAsync type parameter is invalid.

5	CError_PurgeFailed	PurgeComm API function failed.

6	CError_AsyncCheck	Unable to check asynchronous operation.

7	CError_SetStateFailed	SetCommState API function failed.

8	CError_TimeoutsFailed	SetCommTimeouts API func. failed.

9	CError_SetupComFailed	SetupComm API function failed.

10	CError_ClearComFailed	ClearCommError API func. failed.

11	CError_ModemStatFailed	GetCommModemStatus failed.

12	CError_EscapeComFailed	EscapeCommFunction failed.

13	CError_TransmitFailed	TransmitChar method failed.

14	CError_SyncMeth	SyncMethod cannot be changed

while connected.

15	CError_EnumPortsFailed	EnumPorts function failed

16	CError_StoreFailed	Failed to store settings

17	CError_LoadFailed	Failed to load settings

18	CError_RegFailed	Link (un)registration failed

19	CError_LedStateFailed	Cannot change led state if ComPort is

selected

20	CError_ThreadCreated	Cannot wait for event if event thread

is created

21	CError_WaitFailed	WaitForEvent method failed