A Few Bits of Code

Windows Serial Port Application

Sometime you just want an easy way to communicate with a Serial COM port asynchronously. This is a simple Windows project that does just that.



Sometimes things like COM ports become so obsolete it becomes hard to program for them. The less something is used, the harder it is to find example source code. This project's aim is to change that. I needed a way to asynchronously talk with my serial device and couldn't find a simple example to reference. This project shows how to send AND receive asynchronously under Windows. It also has built in configuration options for connecting to COM ports and displays the status of the connection.

Source Code

The project below was written as an MFC Windows application. MFC is my favorite, but the Serial routines could easily be stripped out and used in another framework. Look for files SerialPort.h/cpp for the serial routines. The rest of the files are MFC related and are used to build a simple application showcasing what the code can do. The screenshot below shows a USB-to- Serial adapter with the Tx and Rx lines tied together to loopback the data.


The entire Visual Studio project is here: SerialComm.zip (52.17 Kb).