ZylSerialPort is a Delphi & C++Builder thread based serial port component. Use ZylSerialPort component to easily communicate with external devices on serial port connection, such as modems, bar code readers, GSM modules and others. It works in synchronous and asynchronous mode. You can use it also with USB, IrDA and Bluetooth devices, because these devices have a driver that redirects the input from the USB, IrDA or Bluetooth port to a virtual serial port (you can check it in System/Device Manager/Ports). If your USB device is not provided with such a driver, then use a USB controller whose vendor provides a virtual serial port driver, such as FTDI or use a USB/RS-232 adapter. If the connection is interrupted, you can set to auto-reconnect when the device is available again.
| Name | Description |
|---|---|
Class TExceptionLogger |
Exception logger class. |
Class TZylSerialPort |
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. |
Class EZylSerialPortException |
Serial Port exception class. |
TCommPort = (...); |
TCommPortSet = set of TCommPort; |
TBaudRate = (...); |
TStopBits = (...); |
TDataWidth = (...); |
TParityBits = (...); |
THwFlowControl = (...); |
TSwFlowControl = (...); |
TLineStatus = (...); |
TLineStatusSet = set of TLineStatus; |
TSerialCommPortType = (...); |
TSerialError = (...); |
TSerialErrorSet = set of TSerialError; |
TConnectEvent = procedure(Sender: TObject; Port: TCommPort) of object; |
TSendReceiveEvent = procedure(Sender: TObject; Buffer: AnsiString) of object; |
TLineStatusEvent = procedure(Sender: TObject; LineStatus: TLineStatusSet) of object; |
TDetectEvent = procedure(Sender: TObject; const Port: TCommPort; const BaudRate: TBaudRate; var Cancel: Boolean) of object; |
TReconnectEvent = procedure(Sender: TObject; const Port: TCommPort; const BaudRate: TBaudRate; var Cancel: Boolean) of object; |
TErrorEvent = procedure(Sender: TObject; const errorCode: Cardinal) of object; |
dcb_Binary = $00000001; |
dcb_ParityCheck = $00000002; |
dcb_OutxCtsFlow = $00000004; |
dcb_OutxDsrFlow = $00000008; |
dcb_DtrControlMask = $00000030; |
dcb_DtrControlDisable = $00000000; |
dcb_DtrControlEnable = $00000010; |
dcb_DtrControlHandshake = $00000020; |
dcb_DsrSensivity = $00000040; |
dcb_TXContinueOnXoff = $00000080; |
dcb_OutX = $00000100; |
dcb_InX = $00000200; |
dcb_ErrorChar = $00000400; |
dcb_NullStrip = $00000800; |
dcb_RtsControlMask = $00003000; |
dcb_RtsControlDisable = $00000000; |
dcb_RtsControlEnable = $00001000; |
dcb_RtsControlHandshake = $00002000; |
dcb_RtsControlToggle = $00003000; |
dcb_AbortOnError = $00004000; |
dcb_Reserveds = $FFFF8000; |
se_Break = $0010; |
se_Frame = $0008; |
se_Overrun = $0002; |
se_RxOver = $0001; |
se_RxParity = $0004; |
TCommPort = (...); |
|
Physical serial port enumeration type. Values
|
TCommPortSet = set of TCommPort; |
|
Physical serial port set type. |
TBaudRate = (...); |
|
Baud rate enumeration type. It's the measure of how fast data is moving between instruments that use serial communication. Unit of measurement: bps (bits per second). RS-232 uses only two voltage states, called MARK and SPACE. In such a two-state coding scheme, the baud rate is identical to the maximum number of bits of information, including "control" bits, that are transmitted per second. Values
|
TStopBits = (...); |
|
Stop bits enumeration type. The last part of a character frame consists of 1, 1.5, or 2 stop bits. These bits are always represented by a negative voltage. If no further characters are transmitted, the line stays in the negative (MARK) condition. The transmission of the next character frame, if any, is heralded by a start bit of positive (SPACE) voltage. Values
|
TDataWidth = (...); |
|
Data bits enumeration type (ByteSize). Data bits are transmitted "upside down and backwards." Inverted logic is used and the order of transmission is from least significant bit (LSB) to most significant bit (MSB). To interpret the data bits in a character frame, you must read from right to left, and read 1 for negative voltage and 0 for positive voltage. Values
|
TParityBits = (...); |
|
Parity bits enumeration type. An optional parity bit follows the data bits in the character frame. The parity bit, if present, also follows inverted logic: read 1 for negative voltage and 0 for positive voltage. This bit is included as a simple means of error checking. The idea is this: you specify ahead of time whether the parity of the transmission is to be even or odd. Suppose the parity is chosen to be odd. The transmitter will then set the parity bit in such a way as to make an odd number of 1's among the data bits and the parity bit. Values
|
THwFlowControl = (...); |
|
Hardware flow control enumeration type.
Possible values: None, None + RTS always on, RTS/CTS. Values
|
TSwFlowControl = (...); |
|
Software flow control enumeration type.
Possible values: None, XON/XOFF. Values
|
TLineStatus = (...); |
|
Line status enumeration type.
Possible values: Clear To Send, Data Set Ready, Ring, Carrier Detect = Received Line Signal Detected (RLSD). Values
|
TLineStatusSet = set of TLineStatus; |
|
Line status set type. |
TSerialCommPortType = (...); |
|
Serial port type enumeration.
Possible values: Serial, USB, Bluetooth, Virtual, Unknown. Values
|
TSerialError = (...); |
|
Serial communication errors enumeration type. It can be one or more of the following values.
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. Values
|
TSerialErrorSet = set of TSerialError; |
|
Serial error set type. |
TConnectEvent = procedure(Sender: TObject; Port: TCommPort) of object; |
|
Type of OnConnect and OnDisconnect events.
Parameters
|
TSendReceiveEvent = procedure(Sender: TObject; Buffer: AnsiString) of object; |
|
Type of OnReceive and OnSend events.
Parameters
|
TLineStatusEvent = procedure(Sender: TObject; LineStatus: TLineStatusSet) of object; |
|
Type of OnLineStatusChange event.
Parameters
|
TDetectEvent = procedure(Sender: TObject; const Port: TCommPort; const BaudRate: TBaudRate; var Cancel: Boolean) of object; |
|
Type of OnDetect event.
Parameters
|
TReconnectEvent = procedure(Sender: TObject; const Port: TCommPort; const BaudRate: TBaudRate; var Cancel: Boolean) of object; |
|
Type of OnReconnect event.
Parameters
|
TErrorEvent = procedure(Sender: TObject; const errorCode: Cardinal) of object; |
|
Type of OnError event.
Parameters
|
dcb_Binary = $00000001; |
dcb_ParityCheck = $00000002; |
dcb_OutxCtsFlow = $00000004; |
dcb_OutxDsrFlow = $00000008; |
dcb_DtrControlMask = $00000030; |
dcb_DtrControlDisable = $00000000; |
dcb_DtrControlEnable = $00000010; |
dcb_DtrControlHandshake = $00000020; |
dcb_DsrSensivity = $00000040; |
dcb_TXContinueOnXoff = $00000080; |
dcb_OutX = $00000100; |
dcb_InX = $00000200; |
dcb_ErrorChar = $00000400; |
dcb_NullStrip = $00000800; |
dcb_RtsControlMask = $00003000; |
dcb_RtsControlDisable = $00000000; |
dcb_RtsControlEnable = $00001000; |
dcb_RtsControlHandshake = $00002000; |
dcb_RtsControlToggle = $00003000; |
dcb_AbortOnError = $00004000; |
dcb_Reserveds = $FFFF8000; |
se_Break = $0010; |
se_Frame = $0008; |
se_Overrun = $0002; |
se_RxOver = $0001; |
se_RxParity = $0004; |