Effective Serial Port Use

by Sanjay Mishra

Serial ports have disappeared from modern day PCs. However as product designers we still use them to debug and control products because of their simplicity. Here are serial port usage ideas that I have found useful.

Choice, Multiport, Chips, COM Number Assignments, Terminal Utilities, Programming, Virtual Loopback Adapters, Virtual TCP/IP Redirectors, Virtual Serial Port Sharing, Legacy Application Support, Long Distance, Outdoor Installations,

Choose the Right USB adapter

Modern laptops and PCs do not have a built in serial port. The common solution to this is to get a USB to serial port adapter. However not all USB to serial port adapters are created equial. I had timing issues with some that I used before. For the past few years I have used the Radio Shack single port USB to serial port adapter. While there are other cheaper and maybe betters ones out there, the Radio Shack adapter works for me so I have not had occasion to change.

Multiport Adapters

There are multiport adapters available as PCI, PCMCIA cards or USB add-ons. I have used USB adapters from Quatech and have been happy with them. Their newest USB adapters gives both RS-232 and RS-485 on the same device which is a big help.

Chips for USB to UART for your product

The chip manufacturers provide USB drivers for the host operating system. There are lots of these chips out on the market. I have used chips from FTDI and Silicon Labs. They are pretty much the same in use.

Another option is to bit bang the USB or use controller with built in USB handling capability.

Wrangling with Windows COM number assignments

When you install serial ports, Windows assigns them numbers. Sometimes the numbers that Windows assigns are not to your liking. For example your application can only access serial ports from 1 to 10 and Windows assigned your new serial port a number of 11. Well there is a way around it. Go to Control Panel -> System -> Hardware->Device Manager -> Port -> Properties->Advanced and fill in the COM number that you would like to have.

While you are there you might want to take a look at other settings. Your adapter manufacturer may have other controls that you might find useful.

Free But Effective Serial Port Terminal Utilities

While there are many software utilities and terminal emulators out there, I have found the following to be particularly useful.


This is a free software utility . It has two features that I find particularly useful. Ability to send arbitrary data at the push of different buttons. This enable me to construct different packets for testing the product.. I also like the way it has implemented Hex data display.


This is available for both Windows and Linux. It has a more polished look and feel. I use this sometimes. One of its good features is automatic detection of serial ports installed on the machine. I sometimes fire it up just to see which port number Windows has assigned to my device.

Serial Port Programming

Sometimes your needs go beyond using a simple terminal program. Maybe you want to respond quickly to data received from the test device or do calculations and display the data visually. For this you will need to write a program in a language of choice.

All Operating Systems offer some kind of serial port programming interface. These interfaces allow you to control the serial port in great detail. The easiest way to get started is to get some sample code from the Internet and modify it. Google code search is great for this. C/C++ is a good option for writing programs that deal with low level programming.and I have written tons of working, deployed code in C/C++. Other langauges that work at near native speed are probably good too. I tried writing programs for serial port data in Interpreted languages (Perl specifically) in 2003 or thereabout and found that they had problems responding to high data rate serial data. That might have changed since then. Lua especially JitLua may be good for this but I have not played with that.

For quick test programs I find Purebasic to be the best option. I can hear snickers from different programmers over my choice of a Basic variant Purebasic. Yes you can hear them over the Internet. In my defence I have written tons of code in almost every programming language out there. The test utilities that I write for testing products over the serial port are for internal use. For these my only consideration what will perform the job the fastest with least amount of my time. For this ,after much hunting about, I settled on Purebasic. It is

  • fast, fun and easy to write code in
  • costs about $100 for a lifetime license,
  • is cross platform (Windows, Linux, Mac),
  • generates small compiled exes (50 kB or so for a small test program),
  • has a great friendly support community,

Virtual Serial Ports - Looped back

A virtual serial port has no hardware interface. Loopback are created in pairs. Everything you write to one serial port appears as the output of the other serial port. I find them very useful for testing the software that interfaces to the product. Using the virtual serial port I can send test data and develop software that interfaces to the product without actually having the product available. Even if the product is available, it is much easier to simulate conditions using the loopback serial port.

Loopback serial ports can also be used while debugging microcontroller code running inside a software emulator. You can assign one serial port to the microcontroller through the emulator. The other serial port can be used by the test program to interact with the microcontroller code running inside the emulator.

I have used commercial Virtual Serial Port adapter utilities from Eltima . Of late I have been using the open source com0com null modem emulator utility . Eltima is easier to install but the licensing fees and hassles get to you, especially when you are installing on multiple PCs.

Virtual Serial Ports - Mapped to TCP/IP port numbers

This allows you to use the serial port to perform remote networking. For example, with the com2tcp (COM port to TCP redirector,part of the com0com project) you can communicate via serial interface with the TCP/IP servers.

Eltima provides similar capability in another application (for which you pay another licensing fee).

Virtual Serial Ports - Share serial port data between different applications

You can create virtual serial ports mapped to a single real serial port. Different applications can open the virtual serial port and share data. ith the hub4com (HUB for COM ports, part of the com0com project) it is possible to handle data from a single serial device by a number of differentapplications. For example, several applications can share data from one GPS device.

Legacy Serial Port Application Support

You can use virtual serial ports to keep legacy applications that work off a serial port going. With virtual serial ports running over TCP/IP these legacy applications will work over a network too!

Long distance, outdoors installations

We have found transmitting signals over fiber to be best for long distance, out doors installations. There are a variety of fiber to serial converters available. You can also easily build a fiber interface in your product. Not only do you get much longer distances with fiber but you also get built in lightning and surge protection. Installation is a bit more problematic. You need a trained fiber optic termination expert or pre terminated fibers to make it work.

RS-485 will go longer distances as compared to RS-232 but you need to make sure that you have proper protection against surges and lightning. If you are going to install your product outdoors make sure the data lines are isolated and protected by gas discharge tubes.

Need More Help? Have An Opinion?

Do you need more help to solve your problem? Would you like to ask the author a question about your specific problem? Do you have a great idea about this?

We will post an answer within 2 business days. If you need more immediate assistance or you would like to discuss your issue privately, please use our contact us form or call us at 1-888-215-8557. We love solving technical issues and there is no charge if we solve your problem over email or over a short phone call.

[ ? ]

Author Information (optional)

To receive credit as the author, enter your information below.

(first or full name)

(e.g., City, State, Country)

Submit Your Contribution

  •  submission guidelines.

(You can preview and edit on the next page)