CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

jobs.internet.com

internet.commerce
Partners & Affiliates
Compare Prices
Televisions
Baby Photo Contest
Logo Design
Dental Insurance
Disney World Tickets
Home Improvement
Desktop Computers
Laptops
Online Education
Corporate Gifts
Promotional Golf
PDA Phones & Cases
Imprinted Promotions


RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

Home >> Visual C++ / C++ >> Internet & Networking >> Network Protocols

Becoming a Better Project Manager: Best Practices, Tips, Strategies & More. Download Exclusive eBook Now.

COMMSPY: A serial port monitor
Rating: none

Dan Pilat (view profile)
February 19, 1999

Attempting to monitor the serial port can be a frustrating experience. Without buying expensive shrink wrapped software, there's really nothing available. That was my motivation for creating an MFC program called COMMSPY. COMMSPY is a dialog based, serial port monitor for Windows.  It is a Windows GUI built around the ever popular Visual C++ SDK sample "tty.c", and built under Visual C++ 4.2+. It provides a user friendly interface, with full customization of the port and display settings only a few clicks away. COMMSPY will remember every one of the settings, including the position of the dialog, and restore them the next time you run it.

To use COMMSPY, you'll need a "break-out" cable. Connect two of its ends between the two devices communicating, and the third end to either COMM1 or COMM2 of the PC on which COMMSPY is running. Then update the communication settings, setting the port to either COMM1 or COMM2, whichever you hooked the third end of the cable to. This is the COMMSPY main window:


(continued)



Download these IBM resources today!


Webcast: Hacking 101--The Top 10 Attacks in Web Applications
Learn about the three most common web application attacks, including how they occur and what can be done to prevent them.

eKit: Web Application Security
Discover how IBM Rational AppScan Standard Edition can help you detect vulnerabilities in your Web applications. The new Web Application Security eKit provides you with valuable resources, including whitepapers, demos, and additional information on the benefits of testing your Web applications.

Tutorial: Create Secure Java Applications Productively
This is the first in a two-part tutorial series creating secure Java-based Web applications using Rational Application Developer, Data Studio and Rational AppScan.

eKit: Web 2.0 Developer
Take advantage of open, flexible Web 2.0 technologies, like social software and mash-ups. The IBM Web 2.0 Developer eKit has been updated with the latest best practices & technologies from IBM.

Figure 1: COMMSPY main window

It is intentionally laid out to look like an oscilloscope. The window on the left is the serial port output, in the middle the serial port settings, on the right the display settings, and on the bottom the command buttons. To start monitoring the serial port, simply select "Start!":

Figure 2: COMMSPY main window while monitoring

The serial port output window changes to full dialog mode, hiding unused controls.  To stop monitoring, select "Stop!".

I ran into some problems while developing COMMSPY. First, I had problems getting the thread to terminate. Since its sitting inside WaitForCommEvent(), the only way to communicate with the thread is through a comm event. It turns out that WaitForCommEvent() will instantly return if the comm mask is changed with
SetCommMask(). I was doing that, but it wasn't working. Then I noticed that an OVERLAPPED structure must be passed to WaitForCommEvent() in order for that to work correctly. Second, the controls on the dialog were slow to repaint when monitoring started. This was because I was originally connecting to the COM port AND starting the thread, then rearranging controls. When the second threads starts, it and the main thread start competing for CPU cycles, which slows down the repaint of the controls. When I split the monitoring functionality (GCommMonitor) up (into Connect() and Monitor()), and rearranged the controls in-between calling those two functions, everything worked smoothly.

Below is a few diagrams which will demonstrate a few possible configurations of the "break-out" cable. The below samples assume you have one or more PCs, and some external device with which it is (the are) communicating:

Figure 3: PC#1 communicating to external device via COMM2, COMMSPY monitoring COMM1

Figure 4: PC#1 communicating to external device via COMM1, COMMSPY, on PC#2, is monitoring COMM1

These are the features I really wanted to add to this version, but never had the time:

Download source (includes compiled EXE) - 147 KB

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

Intel Go Parallel Portal: Translating Multicore Power into Application Performance. Learn more.
Becoming a Better Project Manager. Checklists, Tips & Strategies. Download Exclusive eBook Now.
Is it time to make your move to the multi-threaded and parallel processing world? Find out!
Best Practices for Developing a Web Site. Checklists, Tips & Strategies. Download Exclusive eBook Now.
Improve How You Manage Information: Becoming a Better Project Manager. Exclusive eBook - Download Now.


RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
Read/write to remote COM1 - Legacy CodeGuru (10/15/2003)
virtual com port without hardware - Legacy CodeGuru (09/27/2003)
Communicating with a serial port in C# - Legacy CodeGuru (09/21/2003)
Communicating with a serial port in Java - Legacy CodeGuru (07/10/2003)
Printer Cotrol - Legacy CodeGuru (04/18/2003)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)
Access FREE Mainsoft Tools:
Demo: Integrate Microsoft SharePoint into IBM Lotus Notes
Mainsoft's SharePoint Integrator for Lotus Notes is an easy-to-deploy, client side plug-in that gives Notes users easy access to Microsoft SharePoint document libraries. SharePoint Integrator makes collaboration easy for enterprises that use Lotus Notes and have workgroups that rely on SharePoint for basic document management and team collaboration.


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers