Solved

Null Modem Source Code

Posted on 1998-09-10
8
344 Views
Last Modified: 2009-07-29
I am need of source code that will enable me to connect two computers, within close proximity, together via a serial port null modem (RS-232, DB-25), in such a way so as to allow me to tranfer small files of text between to two machines. The OS is Windows NT Ver 4.0. and/or Windows 95 OSR2  
0
Comment
Question by:Joemiglino
  • 6
8 Comments
 

Author Comment

by:Joemiglino
ID: 1172515
Adjusted points to 100
0
 
LVL 23

Expert Comment

by:chensu
ID: 1172516
MS-DOS? Windows 3.x? Windows 9x? Windows NT? ...
0
 

Author Comment

by:Joemiglino
ID: 1172517
Edited text of question
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Joemiglino
ID: 1172518
Edited text of question
0
 

Author Comment

by:Joemiglino
ID: 1172519
OS is Windows NT Ver 4.0 and/or Windows 95 OSR2.
0
 

Author Comment

by:Joemiglino
ID: 1172520
Edited text of question
0
 

Author Comment

by:Joemiglino
ID: 1172521
Edited text of question
0
 

Accepted Solution

by:
TangCheng earned 100 total points
ID: 1172522
This function is told you about open, close,read, write Comm Port

BOOL CommFunction()
{
      ///////////////////////////////////
      //Open COM Port
      //////////////////////////////////
      HANDLE CommHandle = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
      if(CommHandle == INVALID_HANDLE_VALUE)
      {
            return FALSE;
      }

      //Set Speed
      char cc[500];
      COMMCONFIG* pCC = (COMMCONFIG*)cc;
      pCC->dwSize = 500;
      pCC->wVersion = 0x100;
      
      //Set TimeOut
      COMMTIMEOUTS timeout;
      timeout.ReadIntervalTimeout      = MAXDWORD;
      timeout.ReadTotalTimeoutMultiplier = 0;
      timeout.ReadTotalTimeoutConstant = 0;
      timeout.WriteTotalTimeoutMultiplier = 0;
      timeout.WriteTotalTimeoutConstant = 0;
      if(!SetCommTimeouts(CommHandle, &timeout) ||
           !CommConfigDialog("COM1", NULL, pCC))
      {
            CloseHandle(TivhCommHandle);
            return FALSE;
      }

      //Set DCB
      DCB dcb;      
      GetCommState(CommHandle, &dcb);
      dcb.BaudRate = pCC->dcb.BaudRate;
      dcb.ByteSize = pCC->dcb.ByteSize;
      dcb.StopBits = pCC->dcb.StopBits;
      dcb.Parity   = pCC->dcb.Parity;
      SetCommState(CommHandle, &dcb);

      ///////////////////////////////////
      //Read Data
      //////////////////////////////////
      char sBuf[MAX_BUF];
      int  lLen;
      while(<When Read Data Stop>)
      {
            if(ReadFile(CommHandle, sBuf, 1, &lLen, NULL) && lLen > 0)
            {
                  //All Data in sBuf,Read Length in lLen
                  ..........
            }
      }

      ///////////////////////////////////
      //Write Data
      //////////////////////////////////
      WriteFile(CommHandle, sBuf, lLen, NULL, NULL);

      ///////////////////////////////////
      //Close Port
      //////////////////////////////////
      CloseHandle(CommHandle);
}
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question