  Platform eXtended Library (PXL)Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Class TCustomPortUART
Unit
PXL.Boards.Types
Declaration
type TCustomPortUART = class abstract(TCustomDataPort)
Description
Abstract UART (Universal Asynchronous Receiver / Transmitter) communication manager.
Hierarchy
Overview
Fields
Methods
Properties
Description
Fields
 |
internal const InterimSleepTime = 10000 ; |
|
Default sleep time while waiting during transmission between multiple attempts.
|
 |
internal const StringBufferSize = 32 ; |
|
Default buffer size used when reading and writing strings.
|
Methods
 |
constructor Create(const ASystemCore: TCustomSystemCore); |
|
Creates UART (serial) port instance associated with a specific instace of TCustomSystemCore. Note that ASystemCore parameter is required as it is used for timeout calculations.
|
 |
function ReadBuffer(const Buffer: Pointer; const BufferSize, Timeout: Cardinal): Cardinal; virtual; |
|
Reads data buffer from UART (serial) port.
Parameters
- Buffer
- Pointer to data buffer where the data will be written to.
- BufferSize
- Number of bytes to read.
- Timeout
- Maximum time (in milliseconds) to wait while attempting to read the buffer. If this parameter is set to zero, then the function will block indefinitely, attempting to read until the specified number of bytes have been read.
Returns
Number of bytes that were actually read. |
 |
function ReadByte(out Value: Byte; const Timeout: Cardinal = 0): Boolean; inline; |
|
Attempts to read a byte from UART (serial) port. Timeout defines maximum time (in milliseconds) to wait while attempting to do so; if this parameter is set to zero, then the function will block indefinitely until the byte has been read. True is returned when the operation was successful and False when the byte could not be read.
|
 |
function ReadString(out Text: StdString; const MaxCharacters: Cardinal = 0; const Timeout: Cardinal = 0): Boolean; |
|
Reads string from UART (serial) port.
Parameters
- Text
- String that will hold the incoming data.
- MaxCharacters
- Maximum number of characters to read. Once this number of characters has been read, the function immediately returns, even if there is more data to read. When this parameter is set to zero, then the function will continue to read the data, depending on value of
Timeout.
- Timeout
- Maximum time (in milliseconds) to wait while attempting to read the buffer. If this parameter is set to zero, then the function will read only as much data as fits in readable FIFO buffers (or fail when such buffers are not supported).
Returns
Number of bytes that were actually read. |
 |
function WriteBuffer(const Buffer: Pointer; const BufferSize, Timeout: Cardinal): Cardinal; virtual; |
|
Writes data buffer to UART (serial) port.
Parameters
- Buffer
- Pointer to data buffer where the data will be read from.
- BufferSize
- Number of bytes to write.
- Timeout
- Maximum time (in milliseconds) to wait while attempting to write the buffer. If this parameter is set to zero, then the function will block indefinitely, attempting to write until the specified number of bytes have been written.
Returns
Number of bytes that were actually written. |
 |
function WriteByte(const Value: Byte; const Timeout: Cardinal = 0): Boolean; inline; |
|
Attempts to write a byte to UART (serial) port. Timeout defines maximum time (in milliseconds) to wait while attempting to do so; if this parameter is set to zero, then the function will block indefinitely until the byte has been written. True is returned when the operation was successful and False when the byte could not be written.
|
 |
function WriteBytes(const Values: array of Byte; const Timeout: Cardinal = 0): Boolean; |
|
Attempts to write multiple bytes to UART (serial) port. Timeout defines maximum time (in milliseconds) to wait while attempting to do so; if this parameter is set to zero, then the function will block indefinitely, attempting to write until the specified bytes have been written. True is returned when the operation was successful and False when not all bytes could be written.
|
 |
function WriteString(const Text: StdString; const Timeout: Cardinal = 0): Boolean; |
|
Writes string to UART (serial) port.
Parameters
- Text
- String that should be sent.
- Timeout
- Maximum time (in milliseconds) to wait while attempting to write the buffer. If this parameter is set to zero, then the function will write only what fits in writable FIFO buffers (or fail when such buffers are not supported).
Returns
Number of bytes that were actually read. |
 |
function GetBaudRate: Cardinal; virtual; abstract; |
|
Returns currently set baud rate.
|
 |
function GetBitsPerWord: TBitsPerWord; virtual; abstract; |
|
Returns current number of bits per word.
|
 |
function GetParity: TParity; virtual; abstract; |
|
Returns current parity check type.
|
 |
function GetStopBits: TStopBits; virtual; abstract; |
|
Returns current number of stop bits.
|
 |
procedure Flush; virtual; abstract; |
|
Flushes UART (serial) port read and write FIFO buffers.
|
 |
procedure SetBaudRate(const Value: Cardinal); virtual; abstract; |
|
Sets new baud rate.
|
 |
procedure SetBitsPerWord(const Value: TBitsPerWord); virtual; abstract; |
|
Sets new number of bits per word.
|
 |
procedure SetParity(const Value: TParity); virtual; abstract; |
|
Sets new parity check type.
|
 |
procedure SetStopBits(const Value: TStopBits); virtual; abstract; |
|
Sets new number of stop bits.
|
Properties
 |
property BaudRate: Cardinal read GetBaudRate write SetBaudRate; |
|
Currently used baud rate in terms of bits per second. Note that to calculate the actual speed of transmission, it is necessary to take into account start and stop bits among other things; for typical situations, the actual transmission speed may be something like BaudRate / 10 bytes per second or less.
|
 |
property BitsPerWord: TBitsPerWord read GetBitsPerWord write SetBitsPerWord; |
|
Number of bits per message (or "word") used in the transmission. Typically this equals to 8 bits, which means one byte is sent at a time. Accepted values usually range between 5 and 8 bits. Lower values, especially when combined with parity checks may result in less and/or easier to detect errors.
|
 |
property Parity: TParity read GetParity write SetParity; |
|
Number of parity (error detection) bits used in the transmission. This means that additional bits will be added to the tail of transmission that indicate whether the number of ones in the message is odd or even; if the received number of bits does not match this hint, the message will be discarded.
|
 |
property StopBits: TStopBits read GetStopBits write SetStopBits; |
|
Number of stop bits used in the transmission. Although normally only one stop bit is necessary, it may be difficult to detect in hardware when transmission channel is noisy; therefore, additional stop bits may help alleviate the problem.
|
Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.
|