home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / ASYNLIB2.ZIP / ASYNC.DOC < prev    next >
Text File  |  1991-03-21  |  5KB  |  127 lines

  1. This is a set of rather simple serial communication routines written in 
  2. assembly, and to be called from C.  If it is not stated elsewhere, this code
  3. is public domain!  Do with it as you wish, put it in your programs, etc, etc.
  4.  
  5. This is the second 'release' of the ASYNC functions.  Since the first release
  6. several people have contributed modifications to the routines, to which I
  7. want to give them thanks and some credit where credit is due.
  8.  
  9. Roy M. Silvernail --  roy%cybrspc@cs.umn.edu - OR-  cybrspc!roy@cs.umn.edu
  10.  
  11.     For clarifying the documentation of AsyncHand() and AsyncSet().  He
  12.     added a few #define's to further clarify AsyncSet().  He also is 
  13.     responsible for adding some error checking to AsyncInit()-- it now
  14.     returns a non-zero on error (when the COM port isnt there).
  15.  
  16. Steve Miller  -  uunet!pictel!miller
  17.  
  18.     For finding a rather obscure bug.  If a character was recieved and
  19.     sent at exactly the same time, then it would stop receiving or
  20.     sending characters.  
  21.  
  22. Thanks again.
  23.  
  24. In addition, the buffer size has been increased from 1024 to 8196 characters.
  25.  
  26.  
  27. Here is a list of all the files included in this package:
  28.  
  29.     async.doc    -     What you are reading.
  30.     async.h        -    The C prototypes/header file
  31.     async.asm    -    The assembly source
  32.     term.c        -    The source for a simple terminal program
  33.     asyncs.obj    -    The .obj async.asm file for the SMALL model
  34.     asyncc.obj    -    The .obj for the COMPACT model
  35.     asyncm.obj    -    The .obj for the MEDIUM model
  36.     asyncl.obj    -    The .obj for the LARGE model
  37.     term.exe    -    The executable for the terminal program
  38.  
  39. I have used these with Turbo C, and Turbo ASM without any problems.  It
  40. should work with Microsoft C and ASM, but a bit of re-writing will be needed
  41. to make the assmebler part work.  I have also used it with Turbo C++ and 
  42. Turbo Assembler 2.0 without any problem, but you will have to treat the 
  43. Async functions as standard C, rather than C++.
  44.  
  45. Here is a short tutorial of the Async functions:
  46.  
  47. AsyncInit( int Port)
  48. AsyncStop( void)
  49. These functions start and stop the interrupt handlers.  No characters can be
  50. recieved if it isn't started, and the computer will crash if they are not 
  51. stopped before the program is exited.  The paramater 'port' is the COM port
  52. to use, there are #defines in the header file that defines the values to be
  53. used.  It would be 'more bug proof' if AsyncStop was called via the atexit()
  54. function (check your compiler manual).
  55.  
  56. AsyncInit() will return a non-zero value upon an error (when the COM port is
  57. not there).
  58.  
  59.  
  60. AsyncClear( void)
  61. Clears the internal buffers.
  62.  
  63.  
  64. AsyncOut( int c)
  65. Sends out a character.
  66.  
  67.  
  68. AsyncIn( void)
  69. Returns the next character in the buffer or a NULL upon an empty buffer.  Use
  70. AsyncInStat() to check for the number of characters in the buffer.
  71.  
  72.  
  73. AsyncHand( int handshake)
  74. Sets the status of the handshaking lines.  The values are defined in the 
  75. header file and can be or'd together.  A typical call would look like this:
  76.     AsyncHand( DTR | RTS);
  77.  
  78. Roy M. Silvernail found confusion in this rather simple explanation of 
  79. AsyncHand().  I thought of editing the above description, but his description
  80. is better than mine, so here it is:
  81.  
  82. "The AsyncHand routine wants the whole set of flags upon invocation. At
  83. first, I had tried AsyncHand(~DTR) to drop DTR, but soon found it didn't
  84. work. With the 2 main control bits being DTR and RTS, AsyncHand(RTS)
  85. drops DTR just fine, and (of course) AsyncHand(DTR | RTS) raises it once
  86. again."
  87.  
  88.  
  89. AsyncSet( int Baud, int Control)
  90. This sets the baud rate, paraty, etc, of the serial line.  The paramater 'Baud'
  91. is the baud rate (ie 1200, 2400, 9600, etc), and 'control' is a number that
  92. represents parity, length and stop bits.  There are defines for this in 
  93. ASYNC.H, but here are a few commonly used examples:
  94.  
  95.     AsyncSet( 2400, BITS_8 | STOP_1 | NO_PARITY )   for 2400 baud 8N1.
  96.     AsyncSet( 9600, BITS_7 | STOP_1 | EVEN_PARITY)  for 9600 baud 7E1.
  97.  
  98.  
  99. AsyncInStat( void)
  100. This frunction returns the number of characters in the input buffer.
  101.  
  102.  
  103. AsyncOutStat( void)
  104. Returns the number of characters in the output buffer.
  105.  
  106.  
  107. AsyncStat( void)
  108. Returns the status of the handshaking lines.  Use the & and | oporaters with 
  109. the values defined in the header file to extract any useful informaton out of
  110. this value.
  111.  
  112. The values used include the normal DCD, RI, and CTS, but also include D_DCD for
  113. 'Delta-DCD' or CHANGE IN DCD.  This is useful in detecting changes in the 
  114. handshaking lines since the last time the status was read.
  115.  
  116.  
  117. These routines do have their limitations, however.  They cannot deal with more
  118. than one serial port, and cannot take advantage of the 16550 UART.  There is 
  119. also no routines for input and output of strings-- there is so many ways of 
  120. doing it that I left it up to whoever used these routines.  
  121.  
  122. Enjoy, and if you have any questions, dont hesitate to ask.
  123.  
  124. David Kessner - david@kessner.denver.co.us            | do {
  125. 1135 Fairfax, Denver CO  80220  (303) 377-1801 (p.m.) |    . . .
  126. If you cant flame MS-DOS, who can you flame?          |    } while( jones);
  127.