Port Operations in the .NET Framework with Visual Basic
You can access your computer's serial ports through the .NET Framework classes in the System.IO.Ports namespace. The most important class, SerialPort, provides a framework for synchronous and event-driven I/O, access to pin and break states, and access to serial driver properties. It can be wrapped in a Stream object, accessible through the BaseStream property. Wrapping SerialPort in a Stream object allows the serial port to be accessed by classes that use streams. The namespace includes enumerations that simplify the control of serial ports.
The simplest way to create a SerialPort object is through the OpenSerialPort method.
Note
You cannot use .NET Framework classes to directly access other types of ports, such as parallel ports, USB ports, and so on. To access your computer's network, see Classes Used in .NET Framework Network Operations (Visual Basic).
Enumerations
This table lists and describes the main enumerations used for accessing a serial port:
Enumeration |
Description |
Specifies the control protocol used in establishing a serial port communication for a SerialPort object. |
|
Specifies the parity bit for a SerialPort object. |
|
Specifies the type of character that was received on the serial port of the SerialPort object. |
|
Specifies errors that occur on the SerialPort object |
|
Specifies the type of change that occurred on the SerialPort object. |
|
Specifies the number of stop bits used on the SerialPort object. |
Tasks
This table lists and describes the main tasks for accessing a serial port:
To |
See |
Show available serial ports |
|
Dial a modem attached to the serial port of a computer |
How to: Dial Modems Attached to Serial Ports in Visual Basic |
Send a string to a computer's serial port |
|
Receive a string from a computer's serial port |