home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / comm / simpcomm.glb < prev    next >
Text File  |  1992-01-10  |  5KB  |  114 lines

  1. '*******************************************************************************************
  2. '* GLOBAL MODULE
  3. '*******************************************************************************************
  4. DefInt A-Z
  5.  
  6. 'COM Device Control Block (DCB) data structure.  This structure is used as an argument to
  7. 'the Windows API functions GetCommState and SetCommState.
  8.  
  9. Type CommStateDCB
  10.     Id          As String * 1   ' Port Id from OpenComm
  11.     BaudRate    As Integer      ' Baud Rate
  12.     ByteSize    As String * 1   ' Data Bit Size (4 to 8)
  13.     Parity      As String * 1   ' Parity
  14.     StopBits    As String * 1   ' Stop Bits
  15.     RlsTimeOut  As Integer      ' Carrier Detect Time "CD"
  16.     CtsTimeOut  As Integer      ' Clear-to-Send Time
  17.     DsrTimeOut  As Integer      ' Data-Set-Ready Time
  18.     ModeControl As Integer      ' Mode Control Bit Fields
  19.     XonChar     As String * 1   ' XON character
  20.     XoffChar    As String * 1   ' XOFF character
  21.     XonLim      As Integer      ' Min characters in buffer before XON is sent
  22.     XoffLim     As Integer      ' Max characters in buffer before XOFF is send
  23.     peChar      As String * 1   ' Parity Error Character
  24.     EofChar     As String * 1   ' EOF/EOD character
  25.     EvtChar     As String * 1   ' Event character
  26.     TxDelay     As Integer      ' Reserved/Not Used
  27. End Type
  28.  
  29. 'COM status record structure used by the Windows GetCommError API function
  30.  
  31. Type COMSTAT
  32.     ModeControl As String * 1
  33.     cbInQue As Integer
  34.     cbOutQue As Integer
  35. End Type
  36.  
  37. 'COM related Windows API function declarations
  38.  
  39. Declare Function OpenComm Lib "user" (ByVal lpComName As String, ByVal wInQueue As Integer, ByVal wOutQueue As Integer) As Integer
  40. Declare Function CloseComm Lib "user" (ByVal nCid As Integer) As Integer
  41.  
  42. Declare Function WriteComm Lib "user" (ByVal nCid As Integer, ByVal lpBuf As String, ByVal nSize As Integer) As Integer
  43. Declare Function ReadComm Lib "user" (ByVal nCid As Integer, ByVal lpBuf As String, ByVal nSize As Integer) As Integer
  44.  
  45. Declare Function GetCommEventMask Lib "user" (ByVal nCid As Integer, ByVal nEvtMask As Integer) As Integer
  46. Declare Function SetCommEventMask Lib "user" (ByVal nCid As Integer, ByVal nEvtMask As Integer) As Integer
  47.  
  48. Declare Function SetCommState Lib "user" (DCB As CommStateDCB) As Integer
  49. Declare Function GetCommState Lib "user" (ByVal nCid As Integer, DCB As CommStateDCB) As Integer
  50.  
  51. Declare Function GetCommError Lib "user" (ByVal nCid As Integer, lpStat As COMSTAT) As Integer
  52. Declare Function FlushComm Lib "user" (ByVal nCid As Integer, ByVal nQueue As Integer) As Integer
  53.  
  54. ' GLOBAL CONSTANTS
  55.  
  56. 'Boolean constants
  57.  
  58. Global Const False = 0
  59. Global Const True = Not False
  60.  
  61. 'OpenComm API function related errors.
  62.  
  63. Global Const IE_BADID = -1      ' Invalid or unsupported id
  64. Global Const IE_OPEN = -2       ' Device Already Open
  65. Global Const IE_NOPEN = -3      ' Device Not Open
  66. Global Const IE_MEMORY = -4     ' Unable to allocate queues
  67. Global Const IE_DEFAULT = -5    ' Error in default parameters
  68. Global Const IE_HARDWARE = -10  ' Hardware Not Present
  69. Global Const IE_BYTESIZE = -11  ' Illegal Byte Size
  70. Global Const IE_BAUDRATE = -12  ' Unsupported BaudRate
  71.  
  72. 'General communications errors
  73.  
  74. Global Const CE_BREAK = &H10    'Break occurred
  75. Global Const CE_CTSTO = &H20    'Clear-to-send line timeout
  76. Global Const CE_DNS = &H800     'Parallel device not selected
  77. Global Const CE_DSRTO = &H40    'Data-set-ready (DSR) timeout
  78. Global Const CE_FRAME = &H8     'Framing error
  79. Global Const CE_IOE = &H400     'Parallel device input/output (I/O) error
  80. Global Const CE_MODE = &H8000   'Requested mode not supported
  81. Global Const CE_OOP = &H1000    'Parallel device out of paper error
  82. Global Const CE_OVERRUN = &H2   'Overrun error
  83. Global Const CE_PTO = &H200     'Parallel device timeout
  84. Global Const CE_RLSDTO = &H80   'Receive-line-signal-detect or carrier-detect timeout
  85. Global Const CE_RXOVER = &H1    'Receive buffer overflow error
  86. Global Const CE_RXPARITY = &H4  'Parity error
  87. Global Const CE_TXFULL = &H100  'Transmit buffer full error
  88.  
  89. 'Possible event settings by calling the Windows API function SetCommEventMask
  90.  
  91. Global Const EV_RXCHAR = &H1    'Set when a character is received in the COM receive buffer
  92. Global Const EV_RXFLAG = &H2    'Set when the COM event character is received
  93. Global Const EV_TXEMPTY = &H4   'Set when the last character in the transmit buffer is sent
  94. Global Const EV_CTS = &H8       'Set when the clear-to-send (CTS) line changes state
  95. Global Const EV_DSR = &H10      'Set when the data-set-ready (DSR) line changes state
  96. Global Const EV_RLSD = &H20     'Set when the receive-line-signal-detect (RLSD) line changes state
  97. Global Const EV_BREAK = &H40    'Set when a break is detected
  98. Global Const EV_ERR = &H80      'Set when line-status error (framing, overrun or buffer overflow) occurs: see CE_FRAME, CE_OVERRUN, CE_RXPARITY above
  99. Global Const EV_RING = &H100    'Set when a ring is detected
  100. Global Const EV_PERR = &H200    'Set when a printer error is detected
  101.  
  102. 'Constants for parity settings
  103.  
  104. Global Const NOPARITY = 0
  105. Global Const ODDPARITY = 1
  106. Global Const EVENPARITY = 2
  107.  
  108. 'Constants for stop bits
  109.  
  110. Global Const ONESTOPBIT = 0
  111. Global Const ONE5STOPBITS = 1   '1.5 STOP BITS
  112. Global Const TWOSTOPBITS = 2
  113.  
  114.