ZylSerialPort.NET is a thread based, event driven, asynchronous / synchronous serial port .NET component (class library). Use ZylSerialPort.NET component to easily communicate with external devices on serial port connection, such as modems, bar code readers, GSM modules and others.
You can use it asynchronously or synchronously (AutoReceive = true / false).
If you use it asynchronously, all the incoming data is automatically read and discharged in the Received event into e.Buffer.
If you use it synchronously, then you have to read the incoming data with one of the Read methods.
Classes | Class | Description |
---|
 | ConnectionEventArgs |
Provides data for the Connected and Disconnected events.
|
 | DataEventArgs |
Provides data for the Sent and Received events.
|
 | DetectEventArgs |
Provides data for the Detecting and Reconnecting event.
|
 | ErrorEventArgs |
Provides data for the Error events.
|
 | ExtensionMethods |
Extension class for SerialCommPort.
|
 | LineStatusEventArgs |
Provides data for the LineStatusChanged events.
|
 | Logger |
Logger class.
Used for exception logging.
|
 | SerialCommPortExtensions |
Extension methods for SerialCommPort.
|
 | SerialException |
Implements serial exception class.
|
 | SerialPort |
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 Received 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 Received event will fire every time, when new data is available and you can read the data using the various Read methods programmatically.
|
Enumerations | Enumeration | Description |
---|
 | SerialBaudRate |
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.
|
 | SerialCommPort |
Physical serial port enumeration type.
|
 | SerialCommPortType |
Serial port type enumeration.
|
 | SerialDataWidth |
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.
|
 | SerialErrors |
Serial communication errors enumeration type. It can be one or more of the following values.
|
 | SerialHardwareFlowControl |
Hardware flow control enumeration type.
|
 | SerialParityBits |
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.
|
 | SerialSoftwareFlowControl |
Software flow control enumeration type.
|
 | SerialStopBits |
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.
|