About PortController
Introduction
Purchasing PortController
Redistributing PortController
License Agreement
Support
Getting Started
How to Use PortController
PortController Sample Projects
Handling PortController Errors
Reference
Properties
AvailableSystemPorts
BaudRate Property
Break Property
BytesUsedRQ Property
BytesUsedTQ Property
Cd Property
Cts Property
DataBits Property
Dsr Property
Dtr Property
DtrDsr Property
EnableReadOnEventChar Property
EventChar Property
ForceBeginInvokeEventFiring Property
IsOpen Property
IsFileTransferInProgress Property
Parity Property
PortHandle Property
PortName Property
ReceiveBufferSize Property
Ring Property
Rts Property
RtsCts Property
StopBits Property
SystemPorts Property
TraceOutput Property
TransmitBufferSize
XoffByte Property
XonByte Property
XonXoff Property
Methods
CancelFileTransfer Method
ClearRQ Method
ClearTQ Method
Close Method
GetErrorStatus Method
Open Method
Read Method
ReadBinary Method
ReceiveFileXModem Method
ReceiveFileXModemCRC Method
ReceiveFileYModem Method
ReceiveFileZModem Method
SendFileXModem Method
SendFileXModem1k Method
SendFileYModem Method
SendFileZModem Method
SimulateReceivedXoff Method
SimulateReceivedXon Method
Write Method
WriteBinary Method
Events
OnBreakSignal Event
OnCdToggle Event
OnCtsToggle Event
OnDataReceived Event
OnDsrToggle Event
OnError Event
OnEventCharReceived Event
OnFileTransferComplete Event
OnFileTransferStatusUpdate Event
OnRing Event
OnTQEmpty Event

Open Method

Opens a communications port.

Syntax

[Visual Basic]
object.Open( PortName [, BaudRate, DataBits, Parity, StopBits])

[C#]
object.Open(PortName [, BaudRate, DataBits, Parity, StopBits])

[C++]
object->Open(PortName [, BaudRate, DataBits, Parity, StopBits])

Parameters

object

An object expression that evaluates to a PortController object.

PortName

A string containing the name of the communications port.

[optional] BaudRate

An Int32 indicating the baud rate of the port. See BaudRate property for valid values.

[optional] DataBits

An Int16 indicating the data bits setting. See DataBits property for valid values.

[optional] Parity

A value of type ParityValue indicating the parity setting. See Parity property for valid values.

[optional] StopBits

A value of type StopBitsValue indicating the stop bits setting. See StopBits property for valid values.

Return Value

None

Remarks

  • The BaudRate, DataBits, Parity, and StopBits paramters are optional. If not supplied, the current respective property values will be used.
  • BaudRate, DataBits, Parity, and StopBits parameters are subject to the constraints documented in their property documentation.

Errors

  • After opening a port using Open(), any subsequent call to Open() will cause 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 PortController to throw a "Could not open port. This may be because the port does not exist or it is already in use." exception.

Example

[Visual Basic]
myPortController.Open("COM1", 9600, 8, SciCom.PortController.ParityValue.Parity_None, SciCom.PortController.StopBitsValue.StopBits_1)

' Or to use current values:
' myPortController.Open("COM1")


[C#]
myPortController.Open("COM1", 9600, 8, SciCom.PortController.ParityValue.Parity_None, SciCom.PortController.StopBitsValue.StopBits_1);

// Or to use current values:
// myPortController.Open("COM1");


[C++]
myPortController->Open("COM1", 9600, 8, SciCom::PortController::ParityValue::Parity_None, SciCom::PortController::StopBitsValue::StopBits_1);

// Or to use current values:
// myPortController->Open("COM1");

See Also

IsOpen property | DataBits property | BaudRate property | Parity property | StopBits property | PortName property | Close method