Code Examples
  Home arrow Code Examples arrow Writing a Serial Communication Library for...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Writing a Serial Communication Library for Windows
By: Digvijay Chauhan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 81
    2004-09-28

    Table of Contents:
  • Writing a Serial Communication Library for Windows
  • Opening the Selected Serial Port
  • CSerialComm Class
  • DWORD BaudRate, Parity
  • Write and Read Timeouts
  • How To Use 'CSerialComm' Class

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Writing a Serial Communication Library for Windows
    (Page 1 of 6 )

    Serial Data transmission can be diffucult for newcomers to the world of Serial Communication and especially for developers trying it on the Windows platform using C++/VC++. This article illustrates how to develop a simple class for implementing serial data communication.

    Introduction

    Serial Data transmission seems a bit difficult for those who are new to the world of Serial Communication and especially for the developers who try to achieve it on the Windows platform using C++/VC++. When I was an Electronics graduate doing my Final year project that was developing a Add-on Data Acquisition Card that works on Windows 98/2000/XP, I faced a lot of problems on Windows 2000/XP and I searched a lot for some help on accessing ports in Windows 2000/XP. I got some valuable information on Direct Port Access under Windows NT on DDJ.com in an article by Dale Roberts. Here in this article I combine that experience with Serial communication and show you how to develop a simple class for implementing serial data communication.

    This simple Class will ease development of Data Communication or Embedded Interface applications. It implements the functionality using the Win32 API functions, so I’d expect basic familiarity with Win32 on the reader’s part. So we shall first understand the basics of Serial data communication before we get to the class.

    Serial Data Transmission Basics

    In serial data communication the data is transmitted in serial format with the LSB (Least Significant Bit) of the byte to be transmitted as the first among the data bits. The general format for serial transmission is as in the figure below.

    Serial Data Communication Library

    The Parity bit (as in the third box) is optional. It is to be included only if you want to put a check on the validity of the transmitted data on the receiving end i.e. to perform error checking in communication. Parity settings can be altered by software modifications and hence it is easy to enable or disable it as per the design of the application and hardware you’re designing. You might be aware that the parity can be odd or even so you might like to configure it appropriately.

    The following steps are used for sending and receiving data through the serial port of a PC:

    • Open the Communication Port that you decide to use.

    • Configure the selected Communication Port by setting the Baud rate, parity, no. of data bits, etc.

    • Set time-out value for Communication.

    • Read/Write Data to the Port.

    • Close the Port.

    Now we shall discuss these steps in detail so as to get a closer look at the process.

    More Code Examples Articles
    More By Digvijay Chauhan


       · This article plus its associated download/source code are one of the few a pages on...
     

    CODE EXAMPLES ARTICLES

    - Handling Animations and Bitmaps Using GDI+ f...
    - Download a Web Page using the WebClient
    - Creating a Chart using Data from a Database ...
    - The Basics of Charting with the MS Chart Con...
    - Searching Body Text with textRange: Enter th...
    - Searching Body Text with textRange: Building...
    - Searching Body Text with textRange, part 1: ...
    - First Steps in Programming
    - Programming in C
    - Quick Introduction to ASF,ASX, and Networkin...
    - SatView: Pointer Perfect, Part 2: Constructi...
    - SatView: Pointer Perfect, Part 1
    - Style Case Studies: Construction Unions
    - Creating an Engine for Games for Windows
    - Style Case Studies: Generic Callbacks

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway