Share via


SerialPort Members

The following tables list the members exposed by the SerialPort type.

Public Constructors

Name Description
Public Method SerialPort Overloaded. Initializes a new instance of the SerialPort class.

Public Destructors

Name Description
Public Method ~SerialPort Deletes an instance of the SerialPort class.

Public Properties

Name Description
Public Property BaseStream Gets the current instance as a stream.
Public Property BaudRate Gets or sets the serial baud rate.
Public Property BytesToRead Gets the number of bytes of data in the receive buffer.
Public Property BytesToWrite Gets the number of bytes of data in the send buffer.
Public Property CanRead Gets a value indicating whether the current stream supports reading.
Public Property CanSeek Gets a value indicating whether the current stream supports seeking.
Public Property CanTimeout Gets a value that indicates whether the current stream can time out.
Public Property CanWrite Gets a value that indicates whether the current stream supports writing.
Public Property DataBits Gets or sets the standard length of data bits per byte.
Public Property Handshake Gets or sets the handshaking protocol for serial port transmission of data.
Public Property IsOpen Gets a value indicating the open or closed status of the SerialPort object.
Public Property Length Gets the length in bytes of the stream.
Public Property Parity Gets or sets the parity-checking protocol.
Public Property PortName Gets or sets the port for communications, including but not limited to all available COM ports.
Public Property Position Gets or sets the position in the current stream.
Public Property ReadTimeout Gets or sets the number of milliseconds before a time-out occurs when a read operation does not finish.
Public Property StopBits Gets or sets the standard number of stopbits per byte.
Public Property WriteTimeout Gets or sets the number of milliseconds before a time-out occurs when a write operation does not finish.

Public Methods

Name Description
Public Method Close Closes the port connection, sets the IsOpen property to false, and disposes of the internal Stream object.
Public Method DiscardInBuffer Discards data from the serial driver's receive buffer.
Public Method DiscardOutBuffer Discards data from the serial driver's transmit buffer.
Public Method Dispose Releases the unmanaged resources used by the SerialPort object.
Public Method Flush Sends any data waiting in the send buffer of this SerialPort and clears the buffer.
Public Method Open Opens a new serial port connection.
Public Method Read Reads a number of bytes from the SerialPort input buffer and writes those bytes into a byte array at the specified offset.
Public Method Seek Sets the position within the current stream.
Public Method SetLength Sets the length of the current stream.
Public Method Write Writes a specified number of bytes to the serial port using data from a buffer.

Public Events

Name Description
Public Event DataReceived Represents the method that will handle the data received event of a SerialPort object.
Public Event ErrorReceived Represents the method that handles the error event of a SerialPort object.

See Also

Reference

SerialPort Class
System.IO.Ports Namespace