home *** CD-ROM | disk | FTP | other *** search
/ Software Collection (I) / TOOLS.iso / b04 / 15.img / COMM / COMDEV.H_ / COMDEV.H
Encoding:
C/C++ Source or Header  |  1991-04-19  |  13.8 KB  |  244 lines

  1. /*************************************************************************
  2. **
  3. ** Miscelaneous definitions.
  4. */
  5. typedef unsigned short ushort;
  6. typedef unsigned char uchar;
  7.  
  8. #define NULL    0
  9. #define FALSE   0
  10. #define TRUE    1
  11.  
  12. #define LPTx    0x80        /* Mask to indicate cid is for LPT device   */  /*081985*/
  13. #define LPTxMask 0x7F       /* Mask to get      cid    for LPT device   */  /*081985*/
  14.  
  15. #define PIOMAX  3           /* Max number of LPTx devices in high level */  /*081985*/
  16. #define CDEVMAX 10          /* Max number of COMx devices in high level */
  17. #define DEVMAX  13          /* Max number of devices in high level      */  /*081985*/
  18.  
  19. /*************************************************************************
  20. **
  21. ** device control block.
  22. ** This block of information defines the functional parameters of the
  23. ** communications software and hardware.
  24. **
  25. ** Fields in the DCB are defined as follows:
  26. **
  27. **      Id              - Comm device ID, set by the device driver.
  28. **      BaudRate        - Baud rate at which operating.
  29. **      ByteSize        - Number of bits per transmitted/received byte. (4-8)
  30. **                        Received data is also masked off to this size.
  31. **      Parity          - Transmitt/Receive Parity. (0,1,2,3,4) = (None, Odd,
  32. **                        Even, Mark, Space)
  33. **      StopBits        - Number of stop bits. (0,1,2) = (1, 1.5, 2)
  34. **      RlsTimeout      - Amount of time, in milleseconds, to wait for RLSD to
  35. **                        become high. RLSD, Receive Line Signal Detect is also
  36. **                        known as CD, Carrier Detect. RLSD flow control can be
  37. **                        achieved by specifying infinite timeout.
  38. **      CtsTimeout      - Amount of time, in milleseconds, to wait for CTS,
  39. **                        Clear To Send, to become high. CTS flow control can
  40. **                        be achieved by specifying infinite timeout.
  41. **      DsrTimeout      - Amount of time, in milleseconds, to wait for DSR,
  42. **                        Data Set Ready, to become high. DSR flow control can
  43. **                        be acheived by specifying infinite timeout.
  44. **      fBinary         - Binary Mode flag. In non-binary mode, EofChar is
  45. **                        recognized and remembered as end of data.
  46. **      fRtsDisable     - Disable RTS flag. If set, Request To Send is NOT
  47. **                        used, and remains low. Normally, RTS is asserted when
  48. **                        the device is openned, and dropped when closed.
  49. **      fParity         - Enable Parity Checking. Parity errors are not
  50. **                        reported when 0.
  51. **      fOutxCtsFlow    - enable output xon/xoff(hardware)  using cts
  52. **      fOutxDsrFlow    - enable output xon/xoff(hardware)  using dsr
  53. **      fOutX           - Indicates that X-ON/X-OFF flow control is to be used
  54. **                        during transmission. The transmitter will halt if
  55. **                        an X-OFF character is received, and will start again
  56. **                        when an X-ON character is received.
  57. **      fInX            - Indicates that X-ON/X-OFF flow control is to be used
  58. **                        during reception. An X-OFF character will be
  59. **                        transmitted when the receive queue comes within 10
  60. **                        characters of being full, after which an X-ON will be
  61. **                        transmitted when the queue comes with 10 characters
  62. **                        of being empty.
  63. **      fPeChar         - Indicates that characters received with parity errors
  64. **                        are to be replaced with the character specified in
  65. **                        PeChar, below.
  66. **      fNull           - Indicates that received NULL characters are to be
  67. **                        discarded.
  68. **      fChEvt          - Indicates that the reception of EvtChar is to be
  69. **                        flagged as an event by cevt.
  70. **      fDtrFlow        - Indicates that the DTR signal is to be used for
  71. **                        receive flow control. (cextfcn can be used to set and
  72. **                        clear DTR, overriding this definition).
  73. **      fRtsFlow        - Indicates that the RTS signal is to be used for
  74. **                        receive flow control. (cextfcn can be used to set and
  75. **                        clear RTS, overriding this definition).
  76. **      XonChar         - X-ON character for both transmit and receive
  77. **      XoffChar        - X-OFF character for both transmit and receive
  78. **      XonLim          - When the number of characters in the receive queue
  79. **                        drops below this value, then an X-ON character is
  80. **                        sent, if enabled, and DTR is set, if enabled.
  81. **      XoffLim         - When the number of characters in the receive queue
  82. **                        exceeds this value, then an X-OFF character is sent,
  83. **                        if enabled, and DTR is dropped, if enabled.
  84. **      PeChar          - Parity Error replacement character.
  85. **      EvtChar         - Character which triggers an event flag.
  86. **      EofChar         - Character which specifies end of input.
  87. **      TxDelay         - Specifies the minimum amount of time that must pass
  88. **                        between transmission of characters.
  89. **
  90. ** Timeouts are in milleseconds. 0 means ignore the signal. 0xffff means
  91. ** infinite timeout.
  92. **
  93. *************************************************************************/
  94. typedef struct {
  95.    char     Id;                         /* Internal Device ID               */
  96.    ushort   BaudRate;                   /* Baudrate at which runing         */
  97.    char     ByteSize;                   /* Number of bits/byte, 4-8         */
  98.    char     Parity;                     /* 0,1,2,3,4 = None,Odd,Even,Mark,Sp*/
  99.    char     StopBits;                   /* 0,1,2 = 1, 1.5, 2                */
  100.    ushort   RlsTimeout;                 /* Timeout for RLSD to be set       */
  101.    ushort   CtsTimeout;                 /* Timeout for CTS to be set        */
  102.    ushort   DsrTimeout;                 /* Timeout for DSR to be set        */
  103.  
  104.    uchar    fBinary: 1;                 /* CTRL-Z as EOF flag               */
  105.    uchar    fRtsDisable:1;              /* Suppress RTS                     */
  106.    uchar    fParity: 1;                 /* Enable parity check              */
  107.    uchar    fOutxCtsFlow: 1;            /* Enable output xon/xoff with cts  */
  108.    uchar    fOutxDsrFlow: 1;            /* Enable output xon/xoff with dsr  */
  109.    uchar    fDummy: 3;
  110.  
  111.    uchar    fOutX: 1;                   /* Enable output X-ON/X-OFF         */
  112.    uchar    fInX: 1;                    /* Enable input X-ON/X-OFF          */
  113.    uchar    fPeChar: 1;                 /* Enable Parity Err Replacement    */
  114.    uchar    fNull: 1;                   /* Enable Null stripping            */
  115.    uchar    fChEvt: 1;                  /* Enable Rx character event.       */
  116.    uchar    fDtrflow: 1;                /* Enable DTR flow control          */
  117.    uchar    fRtsflow: 1;                /* Enable RTS flow control          */
  118.    uchar    fDummy2: 1;
  119.  
  120.    char     XonChar;                    /* Tx and Rx X-ON character         */
  121.    char     XoffChar;                   /* Tx and Rx X-OFF character        */
  122.    ushort   XonLim;                     /* Transmit X-ON threshold          */
  123.    ushort   XoffLim;                    /* Transmit X-OFF threshold         */
  124.    char     PeChar;                     /* Parity error replacement char    */
  125.    char     EofChar;                    /* End of Input character           */
  126.    char     EvtChar;                    /* Recieved Event character         */
  127.    ushort   TxDelay;                    /* Amount of time between chars     */
  128.    } DCB;
  129.  
  130. /*************************************************************************
  131. **
  132. ** COMSTAT
  133. ** Status record returned by GetCommError
  134. **
  135. *************************************************************************/
  136. typedef struct {
  137.    uchar        fCtsHold: 1;            /* Transmit is on CTS hold      */
  138.    uchar        fDsrHold: 1;            /* Transmit is on DSR hold      */
  139.    uchar        fRlsdHold: 1;           /* Transmit is on RLSD hold     */
  140.    uchar        fXoffHold: 1;           /* Transmit is on X-Off hold    */
  141.    uchar        fXoffSent: 1;           /* Recieve in X-Off or DTR hold */
  142.    uchar        fEof: 1;                /* End of file character found  */
  143.    uchar        fTxim: 1;               /* Character being transmitted  */
  144.    uchar        fPerr:1;                /* Printer error                */  /*081985*/
  145.    ushort       cbInQue;                /* count of characters in Rx Que*/
  146.    ushort       cbOutQue;               /* count of characters in Tx Que*/
  147.    } COMSTAT;
  148.  
  149. /*************************************************************************
  150. **
  151. ** DCB field definitions.
  152. **
  153. *************************************************************************/
  154. #define NOPARITY        0
  155. #define ODDPARITY       1
  156. #define EVENPARITY      2
  157. #define MARKPARITY      3
  158. #define SPACEPARITY     4
  159.  
  160. #define ONESTOPBIT      0
  161. #define ONE5STOPBITS    1
  162. #define TWOSTOPBITS     2
  163.  
  164. #define IGNORE          0               /* Ignore signal                */
  165. #define INFINITE        0xffff          /* Infinite timeout             */
  166.  
  167. /*************************************************************************
  168. **
  169. ** Comm Device Driver Error Bits.
  170. **
  171. *************************************************************************/
  172. #define CE_RXOVER       0x0001          /* Receive Queue overflow       */
  173. #define CE_OVERRUN      0x0002          /* Receive Overrun Error        */
  174. #define CE_RXPARITY     0x0004          /* Receive Parity Error         */
  175. #define CE_FRAME        0x0008          /* Receive Framing error        */
  176. #define CE_CTSTO        0x0020          /* CTS Timeout                  */
  177. #define CE_DSRTO        0x0040          /* DSR Timeout                  */
  178. #define CE_RLSDTO       0x0080          /* RLSD Timeout                 */
  179. #define CE_PTO          0x0100          /* LPTx Timeout                 */  /*081985*/
  180. #define CE_IOE          0x0200          /* LPTx I/O Error               */  /*081985*/
  181. #define CE_DNS          0x0400          /* LPTx Device not selected     */  /*081985*/
  182. #define CE_OOP          0x0800          /* LPTx Out-Of-Paper            */  /*081985*/
  183. #define CE_MODE         0x8000          /* Requested mode unsupported   */
  184.  
  185. /*************************************************************************
  186. **
  187. ** Initialization Error Codes
  188. **
  189. *************************************************************************/
  190. #define IE_BADID        -1              /* Invalid or unsupported id    */
  191. #define IE_OPEN         -2              /* Device Already Open          */
  192. #define IE_NOPEN        -3              /* Device Not Open              */
  193. #define IE_MEMORY       -4              /* Unable to allocate queues    */
  194. #define IE_DEFAULT      -5              /* Error in default parameters  */
  195. #define IE_HARDWARE     -10             /* Hardware Not Present         */
  196. #define IE_BYTESIZE     -11             /* Illegal Byte Size            */
  197. #define IE_BAUDRATE     -12             /* Unsupported BaudRate         */
  198. /*************************************************************************
  199. **
  200. ** Event mask definitions. Used by SetCommEventMask and GetCommEventMask
  201. **
  202. ** RXCHAR       - Set when any character is received and placed in the input
  203. **                queue.
  204. ** RXFLAG       - Set when a particular character, as defined in the dcb, is
  205. **                received and placed in the input queue.
  206. ** TXEMPTY      - Set when the last character in the transmit queue is
  207. **                transmitted.
  208. ** CTS          - Set when the CTS signal changes state.
  209. ** DSR          - Set when the DSR signal changes state.
  210. ** RLSD         - Set when the RLSD signal changes state.
  211. ** BREAK        - Set when a break is detected on input.
  212. ** ERR          - Set when a line status error occurs.
  213. **
  214. *************************************************************************/
  215. #define EV_RXCHAR       0x0001          /* Any Character received       */
  216. #define EV_RXFLAG       0x0002          /* Received certain character   */
  217. #define EV_TXEMPTY      0x0004          /* Transmitt Queue Empty        */
  218. #define EV_CTS          0x0008          /* CTS changed state            */
  219. #define EV_DSR          0x0010          /* DSR changed state            */
  220. #define EV_RLSD         0x0020          /* RLSD changed state           */
  221. #define EV_BREAK        0x0040          /* BREAK received               */
  222. #define EV_ERR          0x0080          /* Line Status Error Occurred   */
  223. #define EV_RING         0x0100          /* Ring signal detected         */
  224. #define EV_PERR         0x0200          /* LPTx error occured           */  /*081985*/
  225.  
  226. /*************************************************************************
  227. **
  228. ** Extended Functions
  229. **
  230. ** SETXOFF      - Causes transmit to behave as if an X-OFF character had
  231. **                been received. Valid only if transmit X-ON/X-OFF specified
  232. **                in the dcb.
  233. ** SETXON       - Causes transmit to behave as if an X-ON character had
  234. **                been received. Valid only if transmit X-ON/X-OFF specified
  235. **                in the dcb.
  236. *************************************************************************/
  237. #define SETXOFF         1               /* Set X-Off for output control */
  238. #define SETXON          2               /* Set X-ON for output control  */
  239. #define SETRTS          3               /* Set RTS high                 */
  240. #define CLRRTS          4               /* Set RTS low                  */
  241. #define SETDTR          5               /* Set DTR high                 */
  242. #define CLRDTR          6               /* Set DTR low                  */
  243. #define RESETDEV        7               /* Reset device if possible     */  /*081985*/
  244.