System.IO.Ports.SerialPort.Write Method

Writes the specified string to the serial port.

Syntax

public void Write (string str)

Parameters

str
Documentation for this section has not yet been entered.

Remarks

Use this method when you want to write a string as output to a serial port.

If there are too many bytes in the output buffer and SerialPort.Handshake is set to Handshake.XOnXOff then the System.IO.Ports.SerialPort object may raise a System.ServiceProcess.TimeoutException while it waits for the device to be ready to accept more data.

By default, System.IO.Ports.SerialPort uses System.Text.ASCIIEncoding to encode the characters. System.Text.ASCIIEncoding encodes all characters greater than 127 as (char)63 or '?'. To support additional characters in that range, set SerialPort.Encoding to System.Text.UTF8Encoding, System.Text.UTF32Encoding, or System.Text.UnicodeEncoding.

Requirements

Namespace: System.IO.Ports
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0