SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 184 | Next

Jan Axelson

"Serial Port Complete: COM Ports, USB Virtual COM Ports, and Ports for Embedded Systems"


index += 1;
}
while ( !((nameArray[index] == myComPortName) |
(index == nameArray.GetUpperBound(0))));
// If the desired port isn't found, select the first port in the array.
if ( index == nameArray.GetUpperBound( 0 ) )
{
myComPort Name= nameArray[ 0 ];
}
To change a parameter, set the property??™s value:
 myComPort.PortName = "COM6"
myComPort.BaudRate = 115200
myComPort.Parity = Parity.Even
myComPort.DataBits = 7
myComPort.StopBits = StopBits.Two
myComPort.Handshake = RequestToSend
 myComPort.PortName = "COM6";
myComPort.BaudRate = 115200;
myComPort.Parity = Parity.Even;
myComPort.DataBits = 7;
myComPort.StopBits = StopBits.Two;
myComPort.Handshake = RequestToSend;
Using .NET??™s SerialPort Class
159
You can also set some of the parameters when initializing a SerialPort object:
 myComPort = new SerialPort("COM6", 115200, Parity.None, 8, StopBits.One)
 myComPort = new SerialPort("COM6", 115200, Parity.None, 8, StopBits.One);
Before communicating with a port, the application must open a connection to
the SerialPort object. The Open method uses the specified parameters or
default parameters if values haven??™t been specified:
 myComPort.Open()
 myComPort.Open();
 In Visual Basic, an alternate way to open a connection uses the My.Computer.
Ports object. Note that the object uses the OpenSerialPort (not Open)
method:
myComPort = My.


Pages:
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196