home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / d / d020_1_4 / 6.ddi / TTY / TTY.TXT < prev    next >
Encoding:
Text File  |  1990-06-01  |  3.4 KB  |  74 lines

  1. /*  TTY.c
  2.     a very simple sample terminal application. It demonstrates
  3.     the basics in the use of the Windows Comm functions. It also
  4.     shows the basic structure for a terminal program.
  5.  
  6. */
  7.  
  8. The TTY program is designed to demonstrate the basics of using the
  9. Windows Communications functions. This demonstration is in the form
  10. of a simple tty terminal program.
  11.  
  12. The general procedure used for performing communications with these
  13. functions is:
  14. 1. Call OpenComm to open the communications port.
  15. 2. Call SetCommState to set the baud rate, parity, and other
  16.    communications parameters.
  17. 3. Call WriteComm to transmit characters to another computer or device.
  18. 4. Call ReadComm to read characters that have been received from
  19.    another computer or device.
  20. 5. Call CloseComm to close the communications port.
  21.  
  22. Before you start working with the communications functions, it is
  23. recommended that you read a reference on this subject, so that you
  24. understand the terms and hardware issues involved. The MS-DOS Encyclopedia,
  25. published by Microsoft Press, contains a good discussion of the hardware
  26. and general communications ideas, and describes the creation of a device
  27. driver for serial communications.  Another source is "Communications and
  28. Networking for the IBM PC & Compatibles" by Larry Jordan and Brucde 
  29. Churchill, published by Brady.
  30.  
  31. Below are descriptions of the communications functions:
  32.  
  33. BuildCommDCB        Fills a device control block (DCB) with control codes.
  34.             The DCB is passed to the SetCommState function to set
  35.             the various parameters of the port. BuildCommDCB
  36.             provides a convenient way to set the fields of the DCB,
  37.             using a parameter string, similar to the one used for
  38.             the DOS Mode command. This function isn't required, and
  39.             doesn't replace the SetCommState function. The fields of
  40.             the DCB can be set with normal C commands. Some fields,
  41.             such as the flow control flags and Xon/Xoff characters,
  42.             default to zero, and are not set by BuildCommDCB. They
  43.             must be set directly using C.
  44.  
  45. ClearCommBreak        Clears the communication break state from a communcation
  46.             device. This function is used with the SetCommBreak
  47.             function. To issue a break to a device, you call
  48.             SetCommBreak, wait for a certain period of time, and
  49.             call ClearCommBreak.
  50.  
  51. CloseComm        Closes a communication device after transmitting the
  52.             current buffer. You must close the port when you are
  53.             finished using it. No other application will be able to
  54.             access the port while it is opened. The port isn't closed
  55.             automatically, when the application quits.
  56.  
  57. FlushComm        Flushes characters from a communication device. If you call
  58.             this function while characters are still in the queue,
  59.             those characters will be lost.
  60.  
  61. GetCommError        Fills a ComStat buffer with the communication status. If
  62.             one of the communication I/O function returns an error,
  63.             this function should be called to determine the cause of
  64.             the error and clear the error state. I/O will not continue
  65.             until the error state is cleared.
  66.  
  67. GetCommEventMask    Retrieves, and then clears an event mask.
  68.  
  69. GetCommState        Fills a DCB buffer with the current device control block.
  70.             This is used to return the values of the parameters
  71.             currently being used.
  72.  
  73. OpenComm        Opens a communication device.
  74.