home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODEM / UWPC201.ZIP / UW-SRC.ZIP / COMMTEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-11  |  5.2 KB  |  159 lines

  1. /*-----------------------------------------------------------------------------
  2.  
  3.    COMMTEST.C - Testing version of the Communications Library.  This simulates
  4.            the COM ports without actually doing anything.
  5.  
  6.     This file is part of UW/PC - a multi-window comms package for the PC.
  7.     Copyright (C) 1990-1991  Rhys Weatherley
  8.  
  9.     This program is free software; you can redistribute it and/or modify
  10.     it under the terms of the GNU General Public License as published by
  11.     the Free Software Foundation; either version 1, or (at your option)
  12.     any later version.
  13.  
  14.     This program is distributed in the hope that it will be useful,
  15.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.     GNU General Public License for more details.
  18.  
  19.     You should have received a copy of the GNU General Public License
  20.     along with this program; if not, write to the Free Software
  21.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23.    Revision History:
  24.    ================
  25.  
  26.     Version  DD/MM/YY  By  Description
  27.     -------  --------  --  ---------------------------------------------------
  28.       1.0    11/04/91  RW  Original version of COMMTEST.C
  29.  
  30.    Authors:
  31.    =======
  32.  
  33.     RW - Rhys Weatherley (e-mail: rhys@cs.uq.oz.au)
  34.          5 Horizon Drive
  35.      Jamboree Heights  QLD  4074
  36.      Australia
  37.  
  38. -----------------------------------------------------------------------------*/
  39.  
  40. #include "comms.h"        /* Declarations for this module */
  41.  
  42. #pragma    warn    -par        /* Turn off annoying warnings */
  43.  
  44. /* Define the port addresses for the 4 serial ports. */
  45. /* These can be changed by the caller if necessary.  */
  46. int    _Cdecl    comports[4] = {0,0,0,0};
  47.  
  48. /* Enable a COM port for Interrupt Driven I/O by this module */
  49. void    _Cdecl    comenable (int port)
  50. {
  51.   /* Nothing to be done here - just ignore the request */
  52. } /* comenable */
  53.  
  54. /* Save the current setting of a COM port to be restored later */
  55. /* Call this function before calling 'comenable' on the port.  */
  56. void    _Cdecl    comsave (int port)
  57. {
  58.   /* Nothing to be done here - just ignore the request */
  59. } /* comsave */
  60.  
  61. /* Set the communications parameters for a COM port */
  62. void    _Cdecl    comparams (int port,int params)
  63. {
  64.   /* Nothing to be done here - just ignore the request */
  65. } /* comparams */
  66.  
  67. /* Disable the interrupt I/O for a COM port */
  68. /* If 'leavedtr' != 0, then leave DTR up    */
  69. void    _Cdecl    comdisable (int port,int leavedtr)
  70. {
  71.   /* Nothing to be done here - just ignore the request */
  72. } /* comdisable */
  73.  
  74. /* Restore the setting of a COM port - after 'comdisable'    */
  75. /* If 'leavedtr' is non-zero the keep DTR set no matter what */
  76. void    _Cdecl    comrestore (int port,int leavedtr)
  77. {
  78.   /* Nothing to be done here - just ignore the request */
  79. } /* comrestore */
  80.  
  81. /* Turn a COM port's test loop-back mode on or off */
  82. /* NOTE: comenable always turns the loop-mode off  */
  83. void    _Cdecl    comtest (int port,int on)
  84. {
  85.   /* Nothing to be done here - just ignore the request */
  86. } /* comtest */
  87.  
  88. /* Return the number of available input chars on a COM port */
  89. /* Will raise the DTR signal if it is not already raised.   */
  90. int    _Cdecl    comavail (int port)
  91. {
  92.   return (0);        /* Nothing is ever received by these routines */
  93. } /* comavail */
  94.  
  95. /* Flush all input from the COM port */
  96. void    _Cdecl    comflush (int port)
  97. {
  98.   /* Nothing to be done here - just ignore the request */
  99. } /* comflush */
  100.  
  101. /* Receive a character from the COM port: -1 if not ready */
  102. /* Will raise the DTR signal if it is not already raised. */
  103. int    _Cdecl    comreceive (int port)
  104. {
  105.   return (-1);        /* Return "no character available" signal */
  106. } /* comreceive */
  107.  
  108. /* Test to see if the COM port is ready for a new */
  109. /* character to transmit.  Will raise the DTR     */
  110. /* signal if it is not already raised.          */
  111. int    _Cdecl    comready (int port)
  112. {
  113.   return (1);        /* Return that the COM port is always ready */
  114. } /* comready */
  115.  
  116. /* Output a character to a COM port.  Will raise */
  117. /* the DTR signal if it is not already raised.   */
  118. void    _Cdecl    comsend (int port,int ch)
  119. {
  120.   /* Nothing to be done here - just ignore the request */
  121. } /* comsend */
  122.  
  123. /* Test to see if a carrier is present - can be called before comenable */
  124. int    _Cdecl    comcarrier (int port)
  125. {
  126.   return (1);        /* Imitate an available carrier signal */
  127. } /* comcarrier */
  128.  
  129. /* Test to see if the DSR (Data Set Ready) signal is present */
  130. int    _Cdecl    comdsr (int port)
  131. {
  132.   return (1);        /* Imitate an available DSR signal */
  133. } /* comdsr */
  134.  
  135. /* Drop the DTR signal on a COM port */
  136. void    _Cdecl    comdropdtr (int port)
  137. {
  138.   /* Nothing to be done here - just ignore the request */
  139. } /* comdropdtr */
  140.  
  141. /* Raise the DTR signal on a COM port */
  142. void    _Cdecl    comraisedtr (int port)
  143. {
  144.   /* Nothing to be done here - just ignore the request */
  145. } /* comraisedtr */
  146.  
  147. /* Set the BREAK pulse on a COM port to 0 or 1 */
  148. void    _Cdecl    combreak (int port,int value)
  149. {
  150.   /* Nothing to be done here - just ignore the request */
  151. } /* combreak */
  152.  
  153. /* Restore a COM port after a DOS shell-out, since */
  154. /* a program may have disabled interrupts, etc.    */
  155. void    _Cdecl    comfix (int port)
  156. {
  157.   /* Nothing to be done here - just ignore the request */
  158. } /* comfix */
  159.