

It returns an array of available serial ports( COMxx in Windows and ttyUSBx in Linux). It is a part of the System.IO.Ports namespace,so you have to include it. SerialPort.GetPortNames() is a static method which can be used to get all the available Serial ports in your System. String PortNames = SerialPort.GetPortNames() If you double click on COM46,you can see the details of the corresponding port.ĭisplaying the available serial ports using C# I am using a FTDI based USB to Serial Converter ( USB2SERIAL) which is recognized as COM46. If your PC has any hardware ports, it will be shown either as COM1 or COM2 under the Ports Section.

All the C soure files used in this tutorial can be downloaded from our GitHub Page.Winforms GUI based serial port program written in C# here.If you are looking for a GUI based serial programming tutorial check the link below. Net Core(3.1)/.Net 5 / Dotnet Framework 4.5+.Īll the codes listed here are designed to run on command line and is intended to highlight the core serial programming concepts. How to control the RTS and DTR pins of Serial Port using C# and.Develop a serial communication App using C# and Dotnet Framework 4.5+ to communicate with a USB device over Virtual COM port.NET Core(3.1)/.Net 5 to communicate with a USB device over Virtual COM port. Develop a cross platform serial communication App using C# and.In this tutorial we are going to learn How to program the serial port on a Windows/Linux PC using C# .
