Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

Null Modem Source Code

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
Joemiglino
Asked:
Joemiglino
  • 6
1 Solution
 
JoemiglinoAuthor Commented:
Adjusted points to 100
0
 
chensuCommented:
MS-DOS? Windows 3.x? Windows 9x? Windows NT? ...
0
 
JoemiglinoAuthor Commented:
Edited text of question
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
JoemiglinoAuthor Commented:
Edited text of question
0
 
JoemiglinoAuthor Commented:
OS is Windows NT Ver 4.0 and/or Windows 95 OSR2.
0
 
JoemiglinoAuthor Commented:
Edited text of question
0
 
JoemiglinoAuthor Commented:
Edited text of question
0
 
TangChengCommented:
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now