type TZylSerialPort = class(TComponent)
Implements serial port communication. General usage: You can use it in asynchronous (AutoReceive = true) and synchronous mode (AutoReceive = false). In asynchronous mode the component will check the serial port periodically for new data (Interval property), it will read automatically all the available data, if exist and will fire the OnReceive event. Here you will be able to get the data from the Buffer parameter. If you set the PacketSize property higher than 0, then maximum PacketSize amount of bytes will be read periodically (it can be fewer, if not enough data is available). If you set PacketTerminator to true, then data will be read automatically until it reach the NewLine property string. This will ensure that you receive the packet in one piece. If it will not receive NewLine in 60 seconds, then it will return the available data without NewLine. In this case PacketSize will be ignored. In synchronous mode OnReceive event will fire every time, when new data is available and you can read the data using the various Read methods programmatically.
Events are raised on a secondary thread.
![]() |
constructor Create(AOwner: TComponent); override; |
![]() |
destructor Destroy(); override; |
![]() |
function Open(): Boolean; |
![]() |
procedure Close(); |
![]() |
function IsConnected: TCommPort; |
![]() |
function StringToCommPort(Port: AnsiString): TCommPort; |
![]() |
function IntToCommPort(portNumber: Integer): TCommPort; |
![]() |
function CommPortToString(const Port: TCommPort): AnsiString; |
![]() |
function BaudRateToInt(const pBaudRate: TBaudRate): Integer; |
![]() |
function IntToBaudRate(const Value: Integer): TBaudRate; |
![]() |
function SendString(const str: AnsiString): Cardinal; |
![]() |
function SendStringLine(const str: AnsiString): Cardinal; |
![]() |
procedure SendStringOnNewThread(const str: AnsiString); |
![]() |
function SendData(Data: Pointer; dataSize: Cardinal): Cardinal; |
![]() |
function SendWord(const number: Word): Cardinal; |
![]() |
function SendByte(const number: Byte): Cardinal; |
![]() |
function SendChar(const character: AnsiChar): Cardinal; |
![]() |
function SendChars(const str: AnsiString): Cardinal; |
![]() |
function SendCharsLine(const str: AnsiString): Cardinal; |
![]() |
procedure SendCharsOnNewThread(const str: AnsiString); |
![]() |
function GetExistingCommPorts: TCommPortSet; |
![]() |
procedure GetExistingCommPortNames(Strings: TStrings); |
![]() |
function GetCommPortPath(port: TCommPort): Ansistring; overload; |
![]() |
function GetCommPortPath(port: AnsiString): Ansistring; overload; |
![]() |
function IsExistingCommPort(port: AnsiString): Boolean; |
![]() |
function GetCommPortType(port: AnsiString): TSerialCommPortType; overload; |
![]() |
function GetCommPortType(port: TCommPort): TSerialCommPortType; overload; |
![]() |
function IsCommPortBusy(port: AnsiString): Boolean; overload; |
![]() |
function IsCommPortBusy(port: TCommPort): Boolean; overload; |
![]() |
function IsCommPortAvailable(port: AnsiString): Boolean; overload; |
![]() |
function IsCommPortAvailable(port: TCommPort): Boolean; overload; |
![]() |
function SetBreak(const OnOff: Boolean): Boolean; |
![]() |
function SetDTR(const OnOff: Boolean): Boolean; |
![]() |
function SetRTS(const OnOff: Boolean): Boolean; |
![]() |
function SetXonXoff(const OnOff: Boolean): Boolean; |
![]() |
function ClearInputBuffer(): Boolean; |
![]() |
function ClearOutputBuffer(): Boolean; |
![]() |
function GetCTS(): Boolean; |
![]() |
function GetDSR(): Boolean; |
![]() |
function GetRING(): Boolean; |
![]() |
function GetDCD(): Boolean; |
![]() |
function GetLastReadBuffer(): AnsiString; |
![]() |
function GetEntireBuffer(): AnsiString; |
![]() |
function GetAvailableInputBufferSize(): Cardinal; |
![]() |
function GetAvailableOutputBufferSize: Cardinal; |
![]() |
function ReplaceControlChars(strInput: AnsiString): AnsiString; |
![]() |
function InsertControlChars(strInput: AnsiString): AnsiString; |
![]() |
function ReadBuffer(): AnsiString; |
![]() |
function ReadChar(): AnsiString; |
![]() |
function ReadChars(noChars: Integer; timeout: Integer = 60000): AnsiString; |
![]() |
function ReadByte(): Byte; |
![]() |
function ReadStringUpToEndChars(endChars: AnsiString; timeout: Integer = 60000): AnsiString; overload; |
![]() |
function ReadStringUpToEndChars(endChars: AnsiString; timeout: Integer; var partialResult: string; var timedOut: Boolean; var endCharsFound: string): AnsiString; overload; |
![]() |
function ReadStringUpToEndChars(endCharsList: TStrings; timeout: Integer = 60000): AnsiString; overload; |
![]() |
function ReadStringUpToEndChars(endCharsList: TStrings; timeout: Integer; var partialResult: AnsiString): AnsiString; overload; |
![]() |
function ReadStringUpToEndChars(endCharsList: TStrings; timeout: Integer; var partialResult: AnsiString; var timedOut: Boolean; var endCharsFound: AnsiString): AnsiString; overload; |
![]() |
function ReadStringLine(timeout: Integer = 60000): AnsiString; |
![]() |
function Echo(): AnsiString; |
![]() |
function RandomDataGenerator(length: Integer): AnsiString; |
![]() |
function DetectDevice(const sentToken, receivedToken: AnsiString; const startBaudRate, endBaudRate: TBaudRate; var pPort: AnsiString; var pBaudRate: TBaudRate): Boolean; overload; |
![]() |
function DetectDevice(const sentToken, receivedToken: AnsiString; var pPort: TCommPort; var pBaudRate: TBaudRate): Boolean; overload; |
![]() |
function FastDetectDevice(const sentToken, receivedToken: AnsiString; var strPort: AnsiString; var pBaudRate: TBaudRate): Boolean; |
![]() |
function TestDevice(sentToken, receivedToken: AnsiString; timeout: Integer = 60000): Boolean; |
![]() |
procedure ResetIdleState; |
![]() |
procedure SetFault; |
![]() |
function GetLastError: TSerialErrorSet; |
![]() |
function GetError(errorCode: cardinal): TSerialErrorSet; |
![]() |
property ExceptionLogger: TExceptionLogger read FExceptionLogger write FExceptionLogger; |
![]() |
property IsSending: Boolean read FIsSending default False; |
![]() |
property IsReceiving: Boolean read FIsReceiving default False; |
![]() |
property IsFaulted: Boolean read FIsFaulted default False; |
![]() |
property NeedSynchronization: Boolean read FNeedSynchronization write FNeedSynchronization; |
![]() |
property MinCheckDisconnectedInterval: Cardinal read FMinCheckDisconnectedInterval write FMinCheckDisconnectedInterval default 50; |
![]() |
property MaxLineLength: Integer read FMaxLineLength write FMaxLineLength default 0; |
![]() |
property IsIdle: Boolean read FIdleWasFired; |
![]() |
property LastTimeReceived: TDateTime read FLastTimeReceived; |
![]() |
property ConnectionTime: TDateTime read FConnectionTime; |
![]() |
property Version: double read FVersion; |
![]() |
property UnlockKey: AnsiString read FUnlockKey write FUnlockKey; |
![]() |
property Port: TCommPort read GetCommPort write SetCommPort default spNone; |
![]() |
property BaudRate: TBaudRate read GetBaudRate write SetBaudRate default br004800; |
![]() |
property DataWidth: TDataWidth read GetDataWidth write SetDataWidth default dw8Bits; |
![]() |
property StopBits: TStopBits read GetStopBits write SetStopBits default sb1Bit; |
![]() |
property Parity: TParityBits read GetParity write SetParity default pbNone; |
![]() |
property EnableDTROnOpen: Boolean read FEnableDTROnOpen write SetEnableDTROnOpen default True; |
![]() |
property EnableRTSOnOpen: Boolean read FEnableRTSOnOpen write SetEnableRTSOnOpen default True; |
![]() |
property HwFlowControl: THwFlowControl read FHwFlowControl write SetHwFlowControl default hfNONE; |
![]() |
property SwFlowControl: TSwFlowControl read FSwFlowControl write SetSwFlowControl default sfNONE; |
![]() |
property XonChar: AnsiChar read FXonChar write SetXonChar default #17; |
![]() |
property XoffChar: AnsiChar read FXoffChar write SetXoffChar default #19; |
![]() |
property XonLim: Word read FXonLim write SetXonLim default 0; |
![]() |
property XoffLim: Word read FXoffLim write SetXoffLim default 1; |
![]() |
property ParityCheck: Boolean read FParityCheck write SetParityCheck default False; |
![]() |
property ReplaceParityErrors: Boolean read FReplaceParityErrors write SetReplaceParityErrors default False; |
![]() |
property DiscardNulls: Boolean read FDiscardNulls write SetDiscardNulls default False; |
![]() |
property DsrSensitivity: Boolean read FDsrSensitivity write SetDsrSensitivity default False; |
![]() |
property TXContinueOnXoff: Boolean read FTXContinueOnXoff write SetTXContinueOnXoff default False; |
![]() |
property ErrorChar: AnsiChar read FErrorChar write SetErrorChar default #0; |
![]() |
property EofChar: AnsiChar read FEofChar write SetEofChar default #26; |
![]() |
property EvtChar: AnsiChar read FEvtChar write SetEvtChar default #26; |
![]() |
property ReadIntervalTimeout: LongWord read FReadIntervalTimeout write FReadIntervalTimeout default MAXDWORD; |
![]() |
property ReadTotalTimeoutMultiplier: LongWord read FReadTotalTimeoutMultiplier write FReadTotalTimeoutMultiplier default 0; |
![]() |
property ReadTotalTimeoutConstant: LongWord read FReadTotalTimeoutConstant write FReadTotalTimeoutConstant default 0; |
![]() |
property WriteTotalTimeoutMultiplier: LongWord read FWriteTotalTimeoutMultiplier write FWriteTotalTimeoutMultiplier default 100; |
![]() |
property WriteTotalTimeoutConstant: LongWord read FWriteTotalTimeoutConstant write FWriteTotalTimeoutConstant default 1000; |
![]() |
property InputBuffer: Cardinal read FInputBuffer write SetInputBuffer default 4096; |
![]() |
property OutputBuffer: Cardinal read FOutputBuffer write SetOutputBuffer default 4096; |
![]() |
property Priority: TThreadPriority read FPriority write SetPriority default tpNormal; |
![]() |
property Delay: Cardinal read FDelay write FDelay default 100; |
![]() |
property Interval: Cardinal read FDelay write FDelay default 100; |
![]() |
property IdleInterval: Cardinal read FIdleInterval write FIdleInterval default 0; |
![]() |
property IdleTimeoutInterval: Cardinal read FIdleTimeoutInterval write FIdleTimeoutInterval default 0; |
![]() |
property CustomPortName: AnsiString read FCustomPortName write SetCustomPortName; |
![]() |
property CustomBaudRate: Integer read FCustomBaudRate write SetCustomBaudRate default 0; |
![]() |
property LogInput: Boolean read FLogInput write FLogInput default False; |
![]() |
property LogDateTime: Boolean read FLogDateTime write FLogDateTime default False; |
![]() |
property LogFile: String read FLogFile write FLogFile; |
![]() |
property AutoReceive: Boolean read FAutoReceive write SetAutoReceive default true; |
![]() |
property AutoReconnect: Boolean read FAutoReconnect write FAutoReconnect default false; |
![]() |
property AutoReconnectCheckInterval: Integer read FAutoReconnectCheckInterval write FAutoReconnectCheckInterval default 4000; |
![]() |
property KeepEntireBuffer: Boolean read FKeepEntireBuffer write FKeepEntireBuffer default False; |
![]() |
property NewLine: AnsiString read FNewLine write FNewLine; |
![]() |
property CloseWhenLineStatusIsZero: Boolean read FCloseWhenLineStatusIsZero write FCloseWhenLineStatusIsZero default false; |
![]() |
property SkipSetupFailed: Boolean read FSkipSetupFailed write FSkipSetupFailed default false; |
![]() |
property PacketSize: LongWord read FPacketSize write FPacketSize; |
![]() |
property PacketTerminator: boolean read FPacketTerminator write FPacketTerminator; |
![]() |
property OnReceive: TSendReceiveEvent read FOnReceive write FOnReceive; |
![]() |
property OnSend: TSendReceiveEvent read FOnSend write FOnSend; |
![]() |
property OnLineStatusChange: TLineStatusEvent read FOnLineStatusChange write FOnLineStatusChange; |
![]() |
property OnConnect: TConnectEvent read FOnConnect write FOnConnect; |
![]() |
property OnDisconnect: TConnectEvent read FOnDisconnect write FOnDisconnect; |
![]() |
property OnFault: TConnectEvent read FOnFault write FOnFault; |
![]() |
property OnIdle: TNotifyEvent read FOnIdle write FOnIdle; |
![]() |
property OnIdleTimeout: TNotifyEvent read FOnIdleTimeout write FOnIdleTimeout; |
![]() |
property OnResume: TNotifyEvent read FOnResume write FOnResume; |
![]() |
property OnDetect: TDetectEvent read FOnDetect write FOnDetect; |
![]() |
property OnReconnect: TReconnectEvent read FOnReconnect write FOnReconnect; |
![]() |
property OnError: TErrorEvent read FOnError write FOnError; |
![]() |
constructor Create(AOwner: TComponent); override; |
|
Constructor of the component. | |
![]() |
destructor Destroy(); override; |
|
Destructor of the component. | |
![]() |
function Open(): Boolean; |
|
Opens the serial port.
Returnstrue if succeeded. | |
![]() |
procedure Close(); |
|
Closes the serial port. | |
![]() |
function IsConnected: TCommPort; |
|
Returns true if the serial port is connected (open).
ReturnsConnected (open) = true; not connected = false; | |
![]() |
function StringToCommPort(Port: AnsiString): TCommPort; |
|
Converts string to TCommPort.
Parameters
ReturnsThe equivalent TCommPort value. | |
![]() |
function IntToCommPort(portNumber: Integer): TCommPort; |
|
Converts integer to TCommPort.
Parameters
ReturnsThe equivalent TCommPort value. | |
![]() |
function CommPortToString(const Port: TCommPort): AnsiString; |
|
Converts TCommPort to string.
Parameters
ReturnsString representation of the port. | |
![]() |
function BaudRateToInt(const pBaudRate: TBaudRate): Integer; |
|
Converts TBaudRate to integer.
Parameters
ReturnsInteger value of baud rate. | |
![]() |
function IntToBaudRate(const Value: Integer): TBaudRate; |
|
Converts integer to TBaudRate.
Parameters
ReturnsThe equivalent TBaudRate value. | |
![]() |
function SendString(const str: AnsiString): Cardinal; |
|
Sends an ANSI string to the serial port (NULL terminated if $H+ (default)).
Parameters
ReturnsThe count of sent bytes. | |
![]() |
procedure SendStringOnNewThread(const str: AnsiString); |
|
Sends an ANSI string to the serial port on a separate thread.
Parameters
| |
![]() |
function SendData(Data: Pointer; dataSize: Cardinal): Cardinal; |
|
Sends a buffer to the serial port.
Parameters
ReturnsThe count of sent bytes. | |
![]() |
function SendWord(const number: Word): Cardinal; |
|
Sends a word number to the serial port.
Parameters
ReturnsThe count of sent bytes. | |
![]() |
function SendByte(const number: Byte): Cardinal; |
|
Sends a byte to the serial port.
sends a byte number Parameters
ReturnsThe count of sent bytes. | |
![]() |
function SendChar(const character: AnsiChar): Cardinal; |
|
Sends a char to the serial port.
sends a character Parameters
ReturnsThe count of sent bytes. | |
![]() |
function SendChars(const str: AnsiString): Cardinal; |
|
Sends an ANSI string to the serial port, including null characters.
Parameters
ReturnsThe count of sent bytes. | |
![]() |
function GetExistingCommPorts: TCommPortSet; |
|
Returns the existing serial ports of the system.
ReturnsExisting serial ports of the system in an array of SerialCommPort objects. | |
![]() |
procedure GetExistingCommPortNames(Strings: TStrings); |
|
Returns the existing serial port names of the system.
ReturnsExisting serial ports of the system in an array of strings. | |
![]() |
function GetCommPortPath(port: TCommPort): Ansistring; overload; |
|
Returns the OS level name of the port. E.g.: \Device\PCISerial1 If the port does not exists, returns empty string.
Parameters
ReturnsOS level name of the port. | |
![]() |
function IsExistingCommPort(port: AnsiString): Boolean; |
|
Checks if a serial port exists.
Parameters
Returnstrue, if the port exists. | |
![]() |
function GetCommPortType(port: AnsiString): TSerialCommPortType; overload; |
|
Returns the type of the serial port.
Parameters
ReturnsType of the serial port. | |
![]() |
function GetCommPortType(port: TCommPort): TSerialCommPortType; overload; |
|
Returns the type of the serial port.
Parameters
ReturnsType of the serial port. | |
![]() |
function IsCommPortBusy(port: TCommPort): Boolean; overload; |
|
Checks if a serial port is already opened by another or the same process (busy). If the port does not exists, SerialPortException is thrown.
Parameters
Returnstrue, if busy. | |
![]() |
function IsCommPortAvailable(port: TCommPort): Boolean; overload; |
|
Checks if the serial port is available (It exists and is not busy, opened by another or the same process).
Parameters
Returnstrue, if available. | |
![]() |
function SetDTR(const OnOff: Boolean): Boolean; |
|
Sets DTR (data-terminal-ready) line.
Parameters
ReturnsTrue, if succeeded. | |
![]() |
function SetRTS(const OnOff: Boolean): Boolean; |
|
Sets RTS (request-to-send) line.
Parameters
ReturnsTrue, if succeeded. | |
![]() |
function ClearInputBuffer(): Boolean; |
|
Clears input buffer.
Returnstrue, if succeeded. | |
![]() |
function ClearOutputBuffer(): Boolean; |
|
Clears output buffer.
Returnstrue, if succeeded. | |
![]() |
function GetCTS(): Boolean; |
|
Returns the state of CTS (clear-to-send) line.
ReturnsReturns the state of CTS line. | |
![]() |
function GetDSR(): Boolean; |
|
Returns the state of DSR (data-set-ready) line.
ReturnsReturns the state of DSR line. | |
![]() |
function GetRING(): Boolean; |
|
Returns the state of RING line.
ReturnsReturns the state of RING line. | |
![]() |
function GetLastReadBuffer(): AnsiString; |
|
Returns the last received buffer. It is used when AutoReceive = false.
ReturnsReturns the last received buffer. | |
![]() |
function Echo(): AnsiString; |
|
Sends the last received buffer back.
ReturnsReturns the last received buffer, which was sent back to the port. | |
![]() |
function RandomDataGenerator(length: Integer): AnsiString; |
|
Generates random data in string format (chars between 0 - 255).
Parameters
ReturnsRandom data. | |
![]() |
function DetectDevice(const sentToken, receivedToken: AnsiString; const startBaudRate, endBaudRate: TBaudRate; var pPort: AnsiString; var pBaudRate: TBaudRate): Boolean; overload; |
|
Detects the serial port where the device is connected to and returns as output parameters the communication port and baud rate. In the detection process senToken will be sent and receivedToken is expected to receive. Only baud rate values between startBaudRate and endBaudRate are checked.
Parameters
ReturnsReturns true, if a device was detected, otherwise false. | |
![]() |
function DetectDevice(const sentToken, receivedToken: AnsiString; var pPort: TCommPort; var pBaudRate: TBaudRate): Boolean; overload; |
|
Detects the serial port where the device is connected to and returns as output parameters the communication port and baud rate. In the detection process senToken will be sent and receivedToken is expected to receive.
Parameters
ReturnsReturns true, if a device was detected, otherwise false. | |
![]() |
function FastDetectDevice(const sentToken, receivedToken: AnsiString; var strPort: AnsiString; var pBaudRate: TBaudRate): Boolean; |
|
Detects the serial port where the device is connected to and returns as output parameters the communication port and baud rate. In the detection process senToken will be sent and receivedToken is expected to receive. Only baud rates between 4800 and 921600 will be checked.
Parameters
ReturnsReturns true, if a device was detected, otherwise false. | |
![]() |
procedure ResetIdleState; |
|
Resets the idle state of the port. | |
![]() |
procedure SetFault; |
|
Emulates faulted state, raises the OnFault event and close the port. If AutoReconnect is true, it will try to reconnect. | |
![]() |
function GetLastError: TSerialErrorSet; |
|
Returns the last error occured.
ReturnsLast error occured. | |
![]() |
function GetError(errorCode: cardinal): TSerialErrorSet; |
|
Converts errorCode to TSerialErrorSet.
Parameters
ReturnsTSerialErrorSet value. | |
![]() |
property ExceptionLogger: TExceptionLogger read FExceptionLogger write FExceptionLogger; |
|
Exception logger object. | |
![]() |
property IsFaulted: Boolean read FIsFaulted default False; |
|
Indicates that the last connection was faulted. Example: When you unplug an USB device which communicates on a virtual serial port. | |
![]() |
property IsIdle: Boolean read FIdleWasFired; |
|
True if Idle occurred, until Resumed. It works only for AutoReceive = true. | |
![]() |
property LastTimeReceived: TDateTime read FLastTimeReceived; |
|
Last date-time when data received from the serial port. | |
![]() |
property ConnectionTime: TDateTime read FConnectionTime; |
|
Indicates when the last connection was established. | |
![]() |
property Version: double read FVersion; |
|
Version number of the component. | |
![]() |
property UnlockKey: AnsiString read FUnlockKey write FUnlockKey; |
|
Unlock key of the component.
Set the unlock key after the component is created. E.g.: componentName.UnlockKey = 'your unlock key'; | |
![]() |
property Port: TCommPort read GetCommPort write SetCommPort default spNone; |
|
Physical name of the serial port. | |
![]() |
property BaudRate: TBaudRate read GetBaudRate write SetBaudRate default br004800; |
|
Baud rate at which the communications device operates. | |
![]() |
property DataWidth: TDataWidth read GetDataWidth write SetDataWidth default dw8Bits; |
|
Number of bits in the bytes transmitted and received. | |
![]() |
property StopBits: TStopBits read GetStopBits write SetStopBits default sb1Bit; |
|
Number of stop bits to be used. | |
![]() |
property Parity: TParityBits read GetParity write SetParity default pbNone; |
|
Parity scheme to be used. | |
![]() |
property EnableDTROnOpen: Boolean read FEnableDTROnOpen write SetEnableDTROnOpen default True; |
|
Enable DTR when the port is opening. The default value is true. | |
![]() |
property EnableRTSOnOpen: Boolean read FEnableRTSOnOpen write SetEnableRTSOnOpen default True; |
|
Enable RTS when the port is opening. The default value is true. | |
![]() |
property HwFlowControl: THwFlowControl read FHwFlowControl write SetHwFlowControl default hfNONE; |
|
Hardware flow control of the serial port. | |
![]() |
property SwFlowControl: TSwFlowControl read FSwFlowControl write SetSwFlowControl default sfNONE; |
|
Software flow control of the serial port. | |
![]() |
property XonChar: AnsiChar read FXonChar write SetXonChar default #17; |
|
Value of the XON character for both transmission and reception (ANSI: 0 - 255). The default value is #17. | |
![]() |
property XoffChar: AnsiChar read FXoffChar write SetXoffChar default #19; |
|
Value of the XOFF character for both transmission and reception (ANSI: 0 - 255). The default value is #19. | |
![]() |
property ErrorChar: AnsiChar read FErrorChar write SetErrorChar default #0; |
|
Value of the character used to replace bytes received with a parity error (ANSI: 0 - 255). The default value is #0. | |
![]() |
property EofChar: AnsiChar read FEofChar write SetEofChar default #26; |
|
Value of the character used to signal the end of data (ANSI: 0 - 255). The default value is #26. | |
![]() |
property EvtChar: AnsiChar read FEvtChar write SetEvtChar default #26; |
|
Value of the character used to signal an event (ANSI: 0 - 255). The default value is #26. | |
![]() |
property Priority: TThreadPriority read FPriority write SetPriority default tpNormal; |
|
Priority of the receiver thread. The default value is tpNormal. | |
![]() |
property Interval: Cardinal read FDelay write FDelay default 100; |
|
Time interval between two receivings in milliseconds (frequency). It must be a positive value. The default value is 100. | |
![]() |
property CustomPortName: AnsiString read FCustomPortName write SetCustomPortName; |
|
Custom port name can be used when Port is set to Custom. You can use any name, different from COMMxx. | |
![]() |
property LogFile: String read FLogFile write FLogFile; |
|
Name and full path of the received data log file. | |
![]() |
property NewLine: AnsiString read FNewLine write FNewLine; |
|
Gets or sets the value used to interpret the end of line in the ReadLine or SendAsciiStringLine methods. Default value is #13#10. | |
![]() |
property OnReceive: TSendReceiveEvent read FOnReceive write FOnReceive; |
|
Occurs when data was received. You will get the received data in Buffer, when AutoReceive is true. When AutoReceive is false, Buffer property is empty and you have to read the data with one of the Read methods. | |
![]() |
property OnSend: TSendReceiveEvent read FOnSend write FOnSend; |
|
Occurs when data was sent. | |
![]() |
property OnLineStatusChange: TLineStatusEvent read FOnLineStatusChange write FOnLineStatusChange; |
|
Occurs when the line status of the serial port is changed. | |
![]() |
property OnConnect: TConnectEvent read FOnConnect write FOnConnect; |
|
Occurs after the serial port is connected. | |
![]() |
property OnDisconnect: TConnectEvent read FOnDisconnect write FOnDisconnect; |
|
Occurs when the serial port is disconnected. | |
![]() |
property OnFault: TConnectEvent read FOnFault write FOnFault; |
|
Occurs when the serial port communication is faulted. After an OnFault event, the port will be closed automatically. Example: When you unplug an USB device which communicates on a virtual serial port. Do not try to reconnect from the OnFault or OnDisconnect event. Set AutoReconnect property to true, to automatically reconnect after an OnFault event, or use the property IsFaulted, which is automatically set to true after an OnFault event and use a timer which checks periodically this property and reconnect from the OnTimer event when IsFaulted is true. In order to work, set CloseWhenLineStatusIsZero property to true and Interval to a higher value than MinCheckDisconnectedInterval. If it does not work, try to set EnableDtrOnOpen or EnableRtsOnOpen to true, before opening the port. | |
![]() |
property OnResume: TNotifyEvent read FOnResume write FOnResume; |
|
Occurs when the receiver is idle and data is received. It works only for AutoReceive = true. | |
![]() |
property OnDetect: TDetectEvent read FOnDetect write FOnDetect; |
|
Occurs when the serial port detection process is in progress. and there are new values of port or baud rate to be checked. | |
![]() |
property OnReconnect: TReconnectEvent read FOnReconnect write FOnReconnect; |
|
Occurs when the serial port connection was lost (faulted) and it tries to reconnect. AutoReconnect must be true. | |
![]() |
property OnError: TErrorEvent read FOnError write FOnError; |
|
Fires when an error occurs. The error will be cleared automatically.
You can sometimes get errors at the beginning of the communication. The problem is probably that you are opening the port while the remote device is in the middle of transmitting. This can cause your serial port to miss-detect the start bit of the data byte, causing corrupted data (framing errors) until there is a gap in the communication and the UART can resynchronize with the next start bit in the data stream. | |