|
PortController.NET
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
|