Solved

Null Modem Source Code

Posted on 1998-09-10
8
356 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  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 …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

617 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