.NET v2.0: Serial Port Communications Finally Arrives

System.IO.Ports.SerialPort (derives from System.ComponentModel.Component) -- Whidbey's MSDN:

Use this class to control a serial port file resource. It provides synchronous and event-driven IO, access to pin and break states, and access to serial driver properties. In addition, its functionality can be wrapped in an internal Stream object, accessible through the BaseStream property, and passed to classes that wrap or utilize streams.

Public Constructors
      SerialPort Initializes a new instance of the SerialPort class.

Public Events
      Disposed (inherited from Component)Adds an event handler to listen to the Disposed event on the component.
      ErrorEvent Represents the method that handles the error event of a SerialPort object.
      PinChangedEvent Represents the method that will handle the serial pin changed event of a SerialPort object.
      ReceivedEvent Represents the method that will handle the serial received event of a SerialPort object.

Public Fields
      InfiniteTimeout Value indicates that no timeout should occur.

Public Methods
      Close Closes the port connection, sets System.IO.Ports.IsOpen to false and disposes of the internal Stream object.
      CreateObjRef (inherited from MarshalByRefObject)Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
      DiscardInBuffer Discards data from the serial driver's receive buffer.
      DiscardOutBuffer Discards data from the serial driver's transmit buffer.
      Dispose (inherited from Component)Releases the resources used by the Component.
      Equals (inherited from Object)Determines whether the specified Object is equal to the current Object.
      GetHashCode (inherited from Object)Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
      GetLifetimeService (inherited from MarshalByRefObject)Retrieves the current lifetime service object that controls the lifetime policy for this instance.
      GetType (inherited from Object)Gets the Type of the current instance.
      InitializeLifetimeService (inherited from MarshalByRefObject)Obtains a lifetime service object to control the lifetime policy for this instance.
      Open Opens a new serial port connection.
      Read Reads from the SerialPort input buffer.
      ReadByte Synchronously reads one byte from the SerialPort input buffer.
      ReadChar Synchronously reads one character from the SerialPort input buffer.
      ReadExisting Reads all immediately available characters (based on the Encoding) in the stream and internal buffer of the SerialPort object.
      ReadLine Reads up to the NewLine value in the input buffer.
      ReadTo Reads up to the specified value in the input buffer.
      ToString (inherited from Component)Returns a String containing the name of the Component , if any. This method should not be overridden. For internal use only.
      Write Writes data to serial port output.
      WriteLine Writes the specified string and the NewLine value to the output buffer.

Public Properties
      BaseStream Gets the internal Stream object, if it exists, for a SerialPort object .
      BaudRate Gets or sets the serial baud rate.
      BreakState Gets or sets the break signal state.
      BytesToRead Gets the number of bytes of data in the receive buffer.
      BytesToWrite
      CDHolding Gets the state of the carrier detect line for the port.
      Container (inherited from Component)Gets the IContainer that contains the Component.
      CtsHolding Gets the state of the clear-to-send line.
      DataBits Gets or sets the standard length of databits per byte.
      DiscardNull Gets or sets whether null characters are ignored when transmitted between the port and the receive buffer.
      DsrHolding Gets the state of the data set ready (DSR) signal.
      DtrEnable Gets or sets the enabling of DTR during serial communication.
      Encoding Gets or sets the character encoding for pre- and post-transmission conversion of text.
      Handshake Gets or sets the handshaking protocol for serial port transmission of data.
      IsOpen Gets the open or closed status of the SerialPort object.
      NewLine Gets or sets the value used to interpret the end of a call to the ReadLine and WriteLine methods.
      Parity Gets or sets the parity checking protocol.
      ParityReplace Gets or sets the 8-bit character that is used to replace invalid characters in a data stream when a parity error occurs.
      PortName Gets or sets the port for communications, including but not limited to all available com ports.
      ReadBufferSize
      ReadTimeout Gets or sets the number of milliseconds before a timeout occurs when a read operation does not finish.
      ReceivedBytes Threshold Gets or sets the number of bytes in the internal input buffer before a ReceivedEvent is fired.
      RtsEnable Gets or sets the enabling of RTS during serial communication.
      Site (inherited from Component)Gets or sets the ISite of the Component.
      StopBits Gets or sets the standard number of stopbits per byte.
      WriteBufferSize
      WriteTimeout Gets or sets the number of milliseconds before a timeout occurs when a write operation does not finish.

14 Comments

Comments have been disabled for this content.