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

Open Method

Opens the communications port.

Syntax

Visual Basic

object.Open port [, settings]

Visual C++

object.Open(port, settings)

Delphi

object.Open(port, settings)

Part Description
object An object expression that evaluates to a PortController object.
port A string containing the name of the communications port.
settings A string containing comma delimited settings for the port in the format BaudRate, DataBits, Parity, StopBits.

Example

Visual Basic

myPortController.Open "COM1", "9600,8,N,1"

Visual C++

m_myPortController.Open("COM1","9600,8,N,1");

Delphi

myPortController.Open('COM1', '9600,8,N,1');

Remarks

  • The settings parameter is optional. If is not supplied (or specified as an empty string in VC++) the current values for these properties are used.

  • To use current values for a particular setting, simply leave the setting blank. For example, "9600, , E, 1.5" sets BaudRate to 9600, Parity to Even, and StopBits to 1.5 while using the current value for DataBits.

  • Valid baud rates are as follows:

    • 110
    • 300
    • 600
    • 1200
    • 2400
    • 4800
    • 9600 (Default)
    • 14400
    • 19200
    • 28800
    • 38400
    • 56000
    • 57600
    • 115200
    • 128000
    • 256000
  • Valid data bits values are as follows:

    • 8 (Default)
    • 7
    • 6
    • 5
  • Valid parity values are as follows:
    Setting Description
    N None
    O Odd
    E Even
    M Mark
    S Space
    Note that these conventions are different than the conventions for the Parity property conventions.

  • Valid stop bits values are as follows:
    Setting Description
    1 1 Stop Bit
    1.5 1.5 Stop Bits
    2 2 Stop Bits
    Note that these conventions are different than the conventions for the StopBits property conventions.

  • BaudRate, DataBits, Parity, and StopBits parameters are subject to the constraints documented in their property documentation.

Returns

Nothing

Errors

  • Violating any of the settings constraints will cause the PortController to use the current or default values for the offending setting.

  • After opening a port using Open(), any subsequent call to Open() will cause the PortController to throw a "Port is already open" exception.

  • An attempt to open a port that has already been opened by another application or that does not exist will cause the PortController to throw a "Could not open port. This may be because the port does not exist or it is already in use." exception.

See Also

DataBits, BaudRate, Parity, StopBits, PortName, Close()