StopBits 열거형

정의

SerialPort 개체에 사용되는 정지 비트의 수를 지정합니다.

public enum class StopBits
public enum StopBits
type StopBits = 
Public Enum StopBits
상속
StopBits

필드

None 0

정지 비트를 사용하지 않습니다. 이 값은 StopBits 속성에서 지원하지 않습니다.

One 1

1비트의 정지 비트를 사용합니다.

OnePointFive 3

1.5비트의 정지 비트를 사용합니다.

Two 2

2비트의 정지 비트를 사용합니다.

예제

다음 예제에서는 설정 하는 방법을 보여 줍니다 합니다 StopBits 속성을 One입니다.

SerialPort^ mySerialPort = gcnew SerialPort("COM1");

mySerialPort->BaudRate = 9600;
mySerialPort->Parity = Parity::None;
mySerialPort->StopBits = StopBits::One;
mySerialPort->DataBits = 8;
mySerialPort->Handshake = Handshake::None;
mySerialPort->RtsEnable = true;
SerialPort mySerialPort = new SerialPort("COM1");

mySerialPort.BaudRate = 9600;
mySerialPort.Parity = Parity.None;
mySerialPort.StopBits = StopBits.One;
mySerialPort.DataBits = 8;
mySerialPort.Handshake = Handshake.None;
mySerialPort.RtsEnable = true;
Dim mySerialPort As New SerialPort("COM1")

mySerialPort.BaudRate = 9600
mySerialPort.Parity = Parity.None
mySerialPort.StopBits = StopBits.One
mySerialPort.DataBits = 8
mySerialPort.Handshake = Handshake.None
mySerialPort.RtsEnable = True

가능한 값을 표시 하는 다음 코드 예제는 StopBits 콘솔에 열거 한 다음 하나를 선택 하 라는 합니다. 이 코드 예제는 일부에 대해 제공 된 더 큰 코드 예제는 SerialPort 클래스입니다.

static StopBits SetPortStopBits(StopBits defaultPortStopBits)
{
    String^ stopBits;

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

    Console::Write("Enter StopBits value (None is not supported and \n" +
        "raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString());
    stopBits = Console::ReadLine();

    if (stopBits == "")
    {
        stopBits = defaultPortStopBits.ToString();
    }

    return (StopBits)Enum::Parse(StopBits::typeid, stopBits);
}
public static StopBits SetPortStopBits(StopBits defaultPortStopBits)
{
    string stopBits;

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

    Console.Write("Enter StopBits value (None is not supported and \n" +
     "raises an ArgumentOutOfRangeException. \n (Default: {0}):", defaultPortStopBits.ToString());
    stopBits = Console.ReadLine();

    if (stopBits == "" )
    {
        stopBits = defaultPortStopBits.ToString();
    }

    return (StopBits)Enum.Parse(typeof(StopBits), stopBits, true);
}
' Display StopBits values and prompt user to enter a value.

Public Shared Function SetPortStopBits(defaultPortStopBits As StopBits) As StopBits
    Dim stopBits As String

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

    Console.Write("Enter StopBits value (None is not supported and " &
                  vbLf & "raises an ArgumentOutOfRangeException. " &
                  vbLf & " (Default: {0}):", defaultPortStopBits.ToString())
    stopBits = Console.ReadLine()

    If stopBits = "" Then
        stopBits = defaultPortStopBits.ToString()
    End If

    Return CType([Enum].Parse(GetType(StopBits), stopBits, True), StopBits)
End Function

설명

값을 설정할 때이 열거형을 사용 합니다 StopBits 속성에는 SerialPort 클래스입니다. 정지 비트 비동기 직렬 연결에서 데이터의 각 단위를 구분합니다. 또한 데이터 전송에 사용 가능한 경우에 지속적으로 전송 됩니다.

합니다 SerialPort throw 클래스는 ArgumentOutOfRangeException 설정 하는 경우 예외를 StopBits 속성을 None입니다.

적용 대상