Code Examples
  Home arrow Code Examples arrow Writing a Serial Communication Library for...
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 86
    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
     
     
    ADVERTISEMENT


    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

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek