Solved

Null Modem Source Code

Posted on 1998-09-10
8
352 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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 82
simple way to manipulate chinese characters in non unicode mfc c++ application. 9 253
Precision Problem in C++ 7 67
using interface in TLB 3 29
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

738 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