About PortController
Introduction
Purchasing PortController
Redistributing PortController
License Agreement
Support
Getting Started
How to Use PortController
Using PortController with Visual Basic
Using PortController with Visual C++
Using PortController with Delphi
How to Use Events
Handling Events in Visual Basic
Handling Events in Visual C++
Handling Events in Delphi
PortController Sample Projects
Reading and Writing Binary Data
Handling PortController Errors
Reference
Properties
BaudRate Property
Break Property
BytesUsedRQ Property
BytesUsedTQ Property
Cd Property
Cts Property
DataBits Property
Dsr Property
Dtr Property
DtrDsr Property
EnableReadOnEventChar Property
EventChar Property
Parity Property
PortHandle Property
PortName Property
Ring Property
Rts Property
RtsCts Property
StopBits Property
XonXoff Property
Methods
ClearRQ Method
ClearTQ Method
Close Method
GetErrorStatus Method
Open Method
Read Method
ReadBinary Method
Write Method
WriteBinary Method
SendXoff Method
SendXon Method
Events
BreakSignal Event
CdToggle Event
CtsToggle Event
DataReceived Event
DsrToggle Event
Error Event
EvtCharReceived Event
Ring Event
TQEmpty Event

StopBits Property

Sets and returns the stop bits communications parameter.

Syntax

Visual Basic

object.StopBits [ = value ]

Visual C++

object.GetStopBits()

object.SetStopBits(value)

Delphi

object.StopBits [ := value ]

Part Description
object An object expression that evaluates to a PortController object.
value An integer representing the number of stop bits.

Example

Visual Basic

'Set stop bits
myPortController.StopBits = 1

'Get stop bits
Dim stopBits As Integer
stopBits = myPortController.StopBits

Visual C++

// Set stop bits
m_myPortController.SetStopBits(1);

// Get stop bits
int stopBits = m_myPortController.GetStopBits();

Delphi

// Set stop bits
myPortController.StopBits := 1;

// Get stop bits
var stopBits: Integer;           // declare variable in the proper place.
stopBits := myPortController.StopBits;

Remarks

Note that the conventions for setting the stop bits value from the StopBits property and setting the stop bits value from the Open() method are slightly different.

Valid stop bits values are as follows:
Setting Description
1 1 Stop Bit (Default)
15 1.5 Stop Bits
2 2 Stop Bits

Default

1

Returns

An integer representing the stop bits parameter of the port.

Errors

  • Attempting to set StopBits to an invalid value will cause the PortController to throw an "Invalid argument" exception.

  • Attempting to set StopBits to 1.5 when DataBits is 6, 7, or 8 is illegal and will cause the PortController to throw a "Invalid stop bits / data bits combination" exception if the port is open. If the port is closed, no exception will be thrown.

  • Attempting to set StopBits to 2 when DataBits is 5 is illegal and will cause the PortController to throw a "Invalid stop bits / data bits combination" exception.

See Also

DataBits, BaudRate, Parity, Open()