home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / commail / os2com15.doc < prev    next >
Text File  |  1992-06-19  |  3KB  |  76 lines

  1. os2comm.c - a simple os/2 comm program - version 1.5beta
  2.  
  3. To use this program, type OS2COMM at the OS/2 prompt,
  4. followed by the port, baud rate, parity, databits, and stopbits,
  5. and an optional capture file name:
  6.  
  7.     OS2COMM  COMx:baud,parity,databits,stopbits  capture-filespec
  8.  
  9. To end this program, press Alt-X.
  10.  
  11. While a communications session is in progress, data can be transmitted
  12. from a file by pressing Alt-F or Alt-A.  The program will prompt for the
  13. filename, the data in the file will be transmitted, then control will be
  14. returned to the keyboard.  Using Alt-A performs an ASCII upload - replacing
  15. CRLF pairs with CRs.  Alt-F sends the file without any translation.
  16.  
  17. This version of OS2Comm has added logic to receive a file using the
  18. XModem file transfer protocol.  To receive a file using XModem, first
  19. tell the remote system to begin sending it, then press Alt-R.  OS2Comm
  20. will prompt you for the receive filespec.  You may optionally specify a
  21. drive letter and path.
  22.  
  23. This program will run only in the protected mode of OS/2.
  24. It will not run under DOS.
  25.  
  26. The program contains 3 threads:
  27.  
  28.   1. main() - This thread calls a COM initialization routine, then
  29.      opens the COM port and creates the next two threads.  After they
  30.      have been created, it waits for the keytocom() thread to complete,
  31.      then exits back to OS/2.
  32.  
  33.   2. keytocom() - This thread reads characters from the keyboard and
  34.      sends them to the COM device driver.  When a Alt-Z is received
  35.      from the keyboard, it signals main() to exit.  When Alt-F or Alt-A is
  36.      received from the keyboard, it prompts for a filename, then sends
  37.      the data from the file to the COM port.  It also handles the Alt-R
  38.      XModem protocol for receiving files.
  39.  
  40.   3. comtodsp() - This thread reads characters from the COM device
  41.      driver and displays them on the screen.  It also writes data to
  42.      the optional capture file.
  43.  
  44. Three semaphores are used in this version of OS2Comm.  The first,
  45. main_sem, is used to release the main thread when the keytocom thread
  46. has received an Alt-X from the keyboard.  This allows the program to end
  47. gracefully.
  48.  
  49. The second, buf_sem, is used by the ascii upload routine, filetocom,
  50. which uses the OS/2 DosWriteAsync function to send data to the COM
  51. device driver.  A semaphore is required by this function to allow the
  52. program to know when the buffer has been freed.  Using DosWriteAsync for
  53. this routine allows the file transfer to proceed as fast as possible.
  54.  
  55. The third semaphore, ctd_sem, is used to control the comtodisp thread.
  56. Requesting this semaphore causes the comtodisp thread to block waiting
  57. for it.  Clearing it allows comtodisp to run again.  This method of
  58. controlling comtodisp is used instead of the OS/2 DosSuspendThread and
  59. DosResumeThread functions because it allows control over where the
  60. thread is when it is blocked.  DosSuspendThread will block the thread no
  61. matter what it is doing at the time.
  62.  
  63.  To compile and link this program, at the OS2 prompt, type:
  64.  
  65.      set PATH=C:\C\BIN;C:\;C:\OS2
  66.      set INCLUDE=C:\C\INCLUDE
  67.      set LIB=C:\C\LIB;C:\OS2
  68.      set TMP=C:\
  69.      cl os2comm.c /AS
  70.  
  71. These settings are dependent on the compiler and version.
  72. This program requires the use of the COM0x.SYS device driver
  73. in CONFIG.SYS.  Use COM01.SYS for AT class machines.  Use
  74. COM02.SYS for PS/2 machines.
  75. 
  76.