Solved

Null Modem Source Code

Posted on 1998-09-10
8
303 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
Comment Utility
Adjusted points to 100
0
 
LVL 23

Expert Comment

by:chensu
Comment Utility
MS-DOS? Windows 3.x? Windows 9x? Windows NT? ...
0
 

Author Comment

by:Joemiglino
Comment Utility
Edited text of question
0
 

Author Comment

by:Joemiglino
Comment Utility
Edited text of question
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

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

Author Comment

by:Joemiglino
Comment Utility
Edited text of question
0
 

Author Comment

by:Joemiglino
Comment Utility
Edited text of question
0
 

Accepted Solution

by:
TangCheng earned 100 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
  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 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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now