Handshake 枚举


指定在为 SerialPort 对象建立串行端口通信时使用的控制协议。Specifies the control protocol used in establishing a serial port communication for a SerialPort object.

public enum class Handshake
public enum Handshake
type Handshake = 
Public Enum Handshake


None 0

没有用于握手的控件。No control is used for the handshake.

RequestToSend 2

使用请求发送 (RTS) 硬件流控制。Request-to-Send (RTS) hardware flow control is used. RTS 发出信号,指出数据可用于传输。RTS signals that data is available for transmission. 如果输入缓冲区已满,RTS 行将被设置为 falseIf the input buffer becomes full, the RTS line will be set to false. 当输入缓冲区中有更多可用空间时,RTS 行将被设置为 trueThe RTS line will be set to true when more room becomes available in the input buffer.

RequestToSendXOnXOff 3

同时使用请求发送 (RTS) 硬件控制和 XON/XOFF 软件控制。Both the Request-to-Send (RTS) hardware control and the XON/XOFF software controls are used.

XOnXOff 1

使用 XON/XOFF 软件控制协议。The XON/XOFF software control protocol is used. 发送 XOFF 控制以停止数据传输。The XOFF control is sent to stop the transmission of data. 发送 XON 控制以继续传输。The XON control is sent to resume the transmission. 使用这些软件控制,而不是使用请求发送 (RTS) 和清除发送 (CTS) 硬件控制。These software controls are used instead of Request to Send (RTS) and Clear to Send (CTS) hardware controls.


下面的代码示例向控制台显示Handshake枚举的可能值, 然后提示用户选择一个值。The following code example displays the possible values of the Handshake enumeration to the console, then prompts the user to choose one. 此代码示例是为SerialPort类提供的更大代码示例的一部分。This code example is part of a larger code example provided for the SerialPort class.

static Handshake SetPortHandshake(Handshake defaultPortHandshake)
    String^ handshake;

    Console::WriteLine("Available Handshake options:");
    for each (String^ s in Enum::GetNames(Handshake::typeid))
        Console::WriteLine("   {0}", s);

    Console::Write("Enter Handshake value (Default: {0}):", defaultPortHandshake.ToString());
    handshake = Console::ReadLine();

    if (handshake == "")
        handshake = defaultPortHandshake.ToString();

    return (Handshake)Enum::Parse(Handshake::typeid, handshake);
public static Handshake SetPortHandshake(Handshake defaultPortHandshake)
    string handshake;

    Console.WriteLine("Available Handshake options:");
    foreach (string s in Enum.GetNames(typeof(Handshake)))
        Console.WriteLine("   {0}", s);

    Console.Write("Enter Handshake value (Default: {0}):", defaultPortHandshake.ToString());
    handshake = Console.ReadLine();

    if (handshake == "")
        handshake = defaultPortHandshake.ToString();

    return (Handshake)Enum.Parse(typeof(Handshake), handshake, true);
Public Shared Function SetPortHandshake(defaultPortHandshake As Handshake) As Handshake
    Dim handshake As String

    Console.WriteLine("Available Handshake options:")
    For Each s As String In [Enum].GetNames(GetType(Handshake))
        Console.WriteLine("   {0}", s)

    Console.Write("Enter Handshake value (Default: {0}):", defaultPortHandshake.ToString())
    handshake = Console.ReadLine()

    If handshake = "" Then
        handshake = defaultPortHandshake.ToString()
    End If

    Return CType([Enum].Parse(GetType(Handshake), handshake, True), Handshake)
End Function


此枚举与 Handshake 属性一起使用。This enumeration is used with the Handshake property.