⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsc4vb_r.txt

📁 在VB中实现通讯的例子
💻 TXT
📖 第 1 页 / 共 4 页
字号:

       Other See SioUnGetc and SioGets.








      +------------+------------------------------------------------------+
      |   SioGets  |  Reads the next byte buffer from the serial line.    |
      +------------+------------------------------------------------------+

      Syntax Function SioGets(ByVal Port, ByVal Buffer As String,
                              ByVal Cnt) As Long
             ' Port   : Port selected.
             ' Buffer : Receive buffer.
             ' Cnt    : Number bytes wanted.

      Remark The SioGets Function reads the smaller of the number of bytes
             wanted (Cnt) and the number of bytes in the receive buffer. A
             zero is return if no bytes are read.


      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.
                 >= 0 : Number of characters actually read.

       Other See SioUnGetc and SioPutc.













     WSC4VB Reference Manual                                   Page 8

      +-------------+-----------------------------------------------------+
      |   SioInfo   |  Returns WSC4VB library information.                |
      +-------------+-----------------------------------------------------+

      Syntax Function SioInfo(ByVal Cmd) As Long
             ' Cmd : Command (See below).

      Remark The SioInfo Function returns an integer code corresponding to
             the Cmd as follows.

                  Command   SioInfo returns
                    "V"     Library version number. For example,

                            ' display WSC version
                            Version = SioInfo(ASC("V"))
                            C = Hex$(&HF And Version)
                            Version = Version / 16
                            B = Hex$(&HF And Version)
                            Version = Version / 16
                            A = Hex$(&HF And Version)
                            PRINT "WSC Version " + A + "." + B + "." + C

      Return See remarks above.
             -1 : Cannot recognize Cmd.


      +-------------+-----------------------------------------------------+
      |  SioParms   |  Sets parity, stop bits, and word length.           |
      +-------------+-----------------------------------------------------+

      Syntax Function SioParms(ByVal Port, ByVal Parity,
                               ByVal StopBits, ByVal DataBits) As Long
             ' Port     : Port selected.
             ' Parity   : Parity code [0,1,2,3,4].
             ' StopBits : Stop bits code [0,1].
             ' DataBits : Word length code [0,1,2,3].

      Remark The SioParms Function sets the parity, stop bits, and word
             length.  If the default parity (none), stop bits (1), or word
             length (8) is not acceptable, then they can be changed by
             calling SioParms.  SioParms can be called either before or
             after calling SioReset. See file WSC4VB.BAS.

             Use the constant values defined in WSC4VB.BAS to minimize the
             chance of passing an incorrect parameter value.

               Parity : NoParity, OddParity, EvenParity,
                        MarkParity, SpaceParity.
             StopBits : OneStopBit, TwoStopBits.
             DataBits : WordLength7, WorldLength8.

      Return    IE_BADID : No such port.
             IE_BYTESIZE : Word length not supported.
               WSC_RANGE : Parameter out of range.

       Other See SioReset.


     WSC4VB Reference Manual                                   Page 9

      +-------------+-----------------------------------------------------+
      |   SioPutc   |  Transmit a character over a serial line.           |
      +-------------+-----------------------------------------------------+

      Syntax Function SioPutc(ByVal Port, ByVal Chr) As Long
             ' Port : Port selected.
             ' Chr  : Character to send.

      Remark The SioPutc Function copies the character to the transmit
             queue for subsequent transmission.

      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.
                    0 : No error.

       Other See SioGetc and SioFlow.










      +-------------+-----------------------------------------------------+
      |   SioPuts   |  Transmits a byte buffer over a serial line.        |
      +-------------+-----------------------------------------------------+

      Syntax Function SioPuts(ByVal Port, ByVal Buffer As String,
                              ByVal Cnt) As Long
             ' Port   : Port selected.
             ' Buffer : String of bytes to transmit.
             ' Cnt    : Bytes in Buffer to send.

      Remark The SioPuts Function copies the characters to the transmit
             queue for subsequent transmission.


      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.
                 >= 0 : The number of bytes actually transmitted.

       Other See SioGetc and SioFlow.













     WSC4VB Reference Manual                                   Page 10

      +-------------+-----------------------------------------------------+
      |  SioRead    |  Read any UART port register.                       |
      +-------------+-----------------------------------------------------+

      Syntax Function SioRead(ByVal Port, ByVal Register) As Long
             ' Port     : Port selected.
             ' Register : UART register [0 through 6].

      REMARK The SioRead function reads any of the 7 I/O ports directly,
             by-passing the Windows API. Only for COM1 through COM4.

             Note that all modem and/or line status bits can also be read
             using SioDTR, SioRTS, SioDCD, SioRI, SioDSR, and SioCTS. Refer
             to the RS232 User's Manual (RS232.TXT) for a description of
             the UART registers.

      Return    IE_BADID : No such port.
                 IE_OPEN : Already open.
                    else : Value of selected register.



      +-------------+-----------------------------------------------------+
      |  SioReset   |  Initialize a serial port for processing.           |
      +-------------+-----------------------------------------------------+

      Syntax Function SioReset(ByVal Port, ByVal RxQueSize,
                               ByVal TxQueSize) As Long
             ' Port      : Port selected.
             ' RxQueSize : Receive queue size.
             ' TxQueSize : Transmit queue size.

      Remark The SioReset Function initializes the selected serial port.
             SioReset should be called before making any other calls to
             WSC4VB.  SioReset uses the parity, stop bits, and word length
             value previously set if SioParm was called, otherwise the
             default values (see SioParm) are used.

      Return    IE_BADID : No such port.
                 IE_OPEN : Already open.
               IE_MEMORY : Cannot allocate memory.
             IE_HARDWARE : Hardware error.

       Other See SioBaud, SioParms, and SioDone.














     WSC4VB Reference Manual                                   Page 11

      +-------------+-----------------------------------------------------+
      |    SioRI    |  Reads the Ring Indicator (RI) modem status bit.    |
      +-------------+-----------------------------------------------------+

      Syntax Function SioRI(ByVal Port) As Long
             ' Port : Port selected.

      Remark The SioRI Function is used to read the Ring Indicator (RI)
             modem status bit.

      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.
                    0 : RI is clear.
                   >0 : RI is set (RING has occurred).

       Other See SioDSR, SioCTS, and SioDCD.




      +-------------+-----------------------------------------------------+
      |    SioRTS   |  Sets, clears, or reads the Request to Send (RTS).  |
      +-------------+-----------------------------------------------------+

      Syntax Function SioRTS(ByVal Port, ByVal Cmd) As Long
             ' Port : Port selected.
             ' Cmd  : RTS command (SET, CLEAR, or READ).

      Remark The SioRTS Function controls the Request to Send (RTS bit in
             the modem control register.

             The RTS line is used by some error correcting modems to
             implement hardware flow control.  RTS is dropped by the
             computer to signal the modem not to send data, and is raised
             to signal the modem to continue. RTS should be set when
             communicating with a modem unless Flow Control is being used.

             Refer to the RS232 User's Manual (RS232.TXT) for a discussion
             of flow control. Commands (defined in WSC4VB.BAS) are:

                    SET_LINE  "S" : set RTS (ON)
                  CLEAR_LINE  "C" : clear RTS (OFF)
                   READ_LINE  "R" : read RTS

      Return  IE_NOPEN : Port not opened. Call SioReset first.
              IE_BADID : No such port.
             WSC_RANGE : Command is not one of "S", "C", or "R".
                     0 : RTS is OFF ("R" command).
                    >0 : RTS is ON  ("R" command).

       Other See SioFlow and SioDTR.







     WSC4VB Reference Manual                                   Page 12

      +------------+------------------------------------------------------+
      | SioRxClear |  Clears the receive buffer.                          |
      +------------+------------------------------------------------------+

      Syntax Function SioRxClear(ByVal Port) As Long
             ' Port : Port selected.

      Remark The SioRxClear Function will delete any characters in the
             receive buffer for the specified port.  After execution, the
             receive buffer will be empty.

      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.

       Other See SioRxQue.









      +-------------+-----------------------------------------------------+
      |  SioRxQue   |  Returns the number of bytes in the receive queue.  |
      +-------------+-----------------------------------------------------+

      Syntax Function SioRxQue(ByVal Port) As Long
             ' Port : Port selected.

      Remark The SioRxQue Function will return the number of characters in
             the receive queue at the time of the call.

      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.

       Other See SioTxQue.




















     WSC4VB Reference Manual                                   Page 13

      +------------+------------------------------------------------------+
      | SioStatus  |  Returns the serial port status.                     |
      +------------+------------------------------------------------------+

      Syntax Function SioStatus(ByVal Port, ByVal Mask) As Long
             ' Port : Port selected.
             ' Mask : Error mask.

      Remark The SioStatus Function returns the serial port error status
             corresponding to the Mask argument. The numerical values of
             the PortMask constants are defined in WSC4VB.BAS.

                WSC_RXOVER  : The receive queue overflowed.
                WSC_OVERRUN : An incoming byte was overwritten.
                 WSC_PARITY : A parity error was detected (incoming byte)
                  WSC_FRAME : A framing error was detected (incoming byte)
                  WSC_BREAK : A break signal was detected.
                 WSC_TXFULL : The transmit queue is full.

      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.


      +-----------+-------------------------------------------------------+
      | SioTimer  |  Returns the system time in milliseconds.             |
      +-----------+-------------------------------------------------------+

      Syntax Function SioTimer() As Long

      Remark The SioTimer function returns the system in milliseconds. Its
             primary purpose is to compute the time between two events.

      Return The system time in milliseconds.


      +------------+------------------------------------------------------+
      | SioTxClear |  Clears the transmitter buffer.                      |
      +------------+------------------------------------------------------+

      Syntax Function SioTxClear(ByVal Port) As Long
             ' Port : Port selected.

      Remark The SioTxClear Function will delete any characters in the
             transmit buffer for the specified port.

             Once this function is called, any character in the transmit
             buffer (put there by SioPutc) will be lost and therefore not
             transmitted.

      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.

       Other See SioTxQue.





     WSC4VB Reference Manual                                   Page 14

      +------------+------------------------------------------------------+
      |  SioTxQue  |  Returns the number of bytes in the transmit queue.  |
      +------------+------------------------------------------------------+

      Syntax Function SioTxQue(ByVal Port) As Long
             ' Port : Port selected.

      Remark The SioTxQue Function will return the number of characters in
             the transmit queue at the time of the call.

      Return IE_NOPEN : Port not opened. Call SioReset first.
             IE_BADID : No such port.

       Other See SioRxQue.










      +------------+------------------------------------------------------+
      | SioUnGetc  |  "Ungets" the last character read with SioGetc().    |
      +------------+------------------------------------------------------+

      Syntax Function SioUnGetc(ByVal Port, ByVal Ch) As Long
             ' Port : Port selected.
             ' Ch   : Character to unget.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -