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

📄 wsc4vb_r.txt

📁 在VB中实现通讯的例子
💻 TXT
📖 第 1 页 / 共 4 页
字号:
            (1) xyGetParameter(ByVal Port,XY_GET_STATE) returns XY_IDLE if idle.
            (2) xyGetParameter(ByVal Port,XY_GET_ERROR_CODE) returns the driver
                error code if an error has occurred or XY_NO_ERROR (0)
                otherwise.

      Return See above.





     WSC4VB Reference Manual                                   Page 22

      +-----------+-------------------------------------------------------+
      | xyRelease | Releases driver port.                                 |
      +-----------+-------------------------------------------------------+

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

      Remark The xyRelease Function releases a port that was previously
             acquired with xyAcquire. This Function should be called before
             calling the WSC Function SioDone.

      Return  0 : No error (XY_NO_ERROR).
             <0 : XYDRIVER error. See .XYDRIVER Error Codes.

       Other See xyAcquire.





      +----------------+--------------------------------------------------+
      | xySetParameter | Retrieves driver parameter.                      |
      +----------------+--------------------------------------------------+

      SYNTAX Function xySetParameter(ByVal Port, ByVal ParmName,
                                     ByVal ParmValue) As Long
             ' Port      : Port Selected.
             ' ParmName  : Parameter Name.
             ' ParmValue : Parameter Value.

      REMARK The ParmValue corresponding to the following table is set.

                        ParmName : Description
                 XY_SET_NAK_RATE : Sets the prompt delay (in seconds).
                 XY_SET_EOF_CHAR : Sets the XMODEM pad character.
                              -1 : Cannot recognize parameter.

             The XY_SET_NAK_RATE parameter sets the delay (in seconds)
             between prompts that the receiver transmits to the sender to
             start the file transfer. The legal range is 1 to 10 seconds.

             The XY_SET_EOF_CHAR parameter sets the pad character used by
             XMODEM in padding the last packet to 128 bytes. The normal
             value is control-Z (hex 1A). For example, to set the pad
             character to zeros:

                 Code = xySetParameter(COM1, XY_SET_EOF_CHAR, 0)

      RETURN See above.









     WSC4VB Reference Manual                                   Page 23

      +-----------+-------------------------------------------------------+
      | xyStartRx | Start XMODEM or YMODEM receive.                       |
      +-----------+-------------------------------------------------------+

      Syntax Function xyStartRx(ByVal Port, ByVal Filename As String,
                                ByVal NCGchar, ByVal Batch) As Long
             ' Port     : Port to use.
             ' Filename : File to receive (XMODEM only).
             ' NCGchar  : NAK, "C", or 'G'.
             ' Batch    : YMODEM flag (T/F).

      Remark The xyStartRx starts the XMODEM or YMODEM file receive. Once
             started, calls to xyDriver are made to execute the next state
             (or states). The xyStartTx Function returns immediately.

             Protocol   :  NCGchar   BatchFlag  :  Comments
             XMODEM     :   NAK        FALSE       Standard XMODEM
             XMODEM/CRC :   "C"        FALSE
             XMODEM/1K  :   "C"        FALSE
             YMODEM     :   "C"        TRUE        Standard YMODEM

             The xyStart Function is used to receive a file using XMODEM or
             YMODEM.

      Return =0 : No error (XY_NO_ERROR).
             <0 : Driver error. See .XYDRIVER Error Codes. a list of errors.

       Other See xyStartTx and xyDriver.



      +-----------+-------------------------------------------------------+
      | xyStartTx | Start XMODEM or YMODEM transmit.                      |
      +-----------+-------------------------------------------------------+

      Syntax Function xyStartTx(ByVal Port, ByVal Filename As String,
                                ByVal OneKflag, ByVal Batch) As Long
             ' Port     : Port to use.
             ' Filename : File to send.
             ' OneK     : Want 1K blocks (T/F).
             ' Batch    : YMODEM flag (T/F).

      Remark The xyStartTx starts the XMODEM or YMODEM file send. Once
             started, calls to xyDriver are made to execute the next state
             (or states). The xyStartTx Function returns immediately.

             Protocol   :  OneKflag  BatchFlag : Comments
             XMODEM     :   FALSE      FALSE     Standard XMODEM
             XMODEM/CRC :   FALSE      FALSE
             XMODEM/1K  :   TRUE       FALSE
             YMODEM     :   TRUE       TRUE      Standard YMODEM

      Return =0 : No error (XY_NO_ERROR).
             <0 : Driver error. See XYDRIVER.BAS for a list of errors.

       Other See xyStartRx and xyDriver.


     WSC4VB Reference Manual                                   Page 24


                         XYDRV Error Codes

      Error codes are always negative, except for 'no error'. Most of these
      error conditions rarely occur. Also note that XYDRV functions can
      return WSC errors. An error message is queued when an error occurs
      which can be retrieved with xyGetMessage.

      The numeric values for error codes can be found in XYDRV32.BAS.

      +--------------------------+----------------------------------------+
      |              XY_NO_ERROR | No error. (0)                          |
      |         XY_UNKNOWN_ERROR | Unknown error.                         |
      |  XY_ALREADY_ACTIVE_ERROR | Port already acquired.                 |
      |     XY_CANNOT_OPEN_ERROR | Cannot open specifed file.             |
      |      XY_EMPTY_FILE_ERROR | Specified file is empty.               |
      | XY_NO_STARTUP_CHAR_ERROR | Must specify NAK or "C".               |
      |         XY_NOT_NCG_ERROR | Expected NAK or "C".                   |
      |       XY_DISK_READ_ERROR | Error reading disk.                    |
      |      XY_NO_EOT_ACK_ERROR | EOT was not ACKed.                     |
      |        XY_INTERNAL_ERROR | Internal error!                        |
      |       XY_CANCELLED_ERROR | Other side cancelled.                  |
      |     XY_OUT_OF_SYNC_ERROR | Protocol has lost synchronization.     |
      |         XY_RETRIES_ERROR | Packet retry limit was exceeded.       |
      |  XY_BAD_PACKET_NBR_ERROR | Incorrect packet number.               |
      |       XY_TIMED_OUT_ERROR | Timed out waiting for other side.      |
      |    XY_NO_SUCH_FILE_ERROR | No such file.                          |
      |      XY_NOT_ACTIVE_ERROR | Port not acquired by xyAcquire.        |
      |      XY_PORT_RANGE_ERROR | Port number out of range.              |
      +--------------------------+----------------------------------------+




























     WSC4VB Reference Manual                                   Page 25

      +----------+--------------------------------------------------------+
      | ascAbort | Aborts the Ascii state driver.                         |
      +----------+--------------------------------------------------------+

      Syntax Function ascAbort() As Long

      Remark The ascAbort function forces the ASCII driver to IDLE,
             terminating any file transfer which may be in progress.

      Return none.



      +-----------+-------------------------------------------------------+
      | ascDriver | Ascii state driver.                                   |
      +-----------+-------------------------------------------------------+

      Syntax Function ascDriver() As Long

      Return 1 : IDLE (A transfer is not underway).
             0 : Running (A transfer is underway).

      Remark The ascDriver function drives the state engine. It executes
             the next driver state, and is typically called from within a
             timer loop.

             ascDriver can be called as often as wanted whether or not a
             file transfer was initiated. Note that ascDriver never
             returns an error code.

       Other See ascStartTx and ascStartRx.



























     WSC4VB Reference Manual                                   Page 26

      +---------------+---------------------------------------------------+
      | ascGetMessage |  Get next Ascii driver message.                   |
      +---------------+---------------------------------------------------+

      Syntax Function ascGetMessage(ByVal Buffer As String, ByVal Size)
                                    As Long
             ' Buffer : Message buffer.
             ' Size   : Size of message buffer.

      Remark The ascGetMessage function retieves the next message from the
             driver message queue.

      Return  TRUE : A message was copied into Buffer.
             FALSE : No messages are available.

       Other See ascGetParameter.



      +-----------------+-------------------------------------------------+
      | ascGetParameter | Retrieves driver parameter.                     |
      +-----------------+-------------------------------------------------+

      Syntax Function ascGetParameter(ByVal Parameter) As Long
             ' Parameter : Parameter to return.

      Remark The driver parameter corresponding to the following table is
             returned.

                       Parameter :  Desciption
               ASC_GET_ERROR_CODE : Driver error code (see ASCDRV.BAS)
              ASC_GET_ERROR_STATE : Error state (if in error).
                    ASC_GET_STATE : Current state (ss ASCDRV.BAS).
                               -1 : Cannot recognize parameter.

             The ascGetParameter function can be used to check the state of
             the driver. For example:

            (1) ascGetParameter(Port,ASC_GET_STATE) returns the current
                state.
            (2) ascGetParameter(Port,ASC_GET_ERROR_CODE) returns the driver
                error code if an error has occurred or ASC_NO_ERROR (0)
                otherwise.

      Return See above.













     WSC4VB Reference Manual                                   Page 27

      +---------+---------------------------------------------------------+
      | ascInit | Start Ascii receive.                                    |
      +---------+---------------------------------------------------------+

      Syntax Function ascInit(ByVal Port, ByVal RxBufSize,
                              ByVal xFlag) As Long
             ' Port : Port selected.
             ' RxBufSize : RX buffer size
             ' xFlag : Perform XON/XOFF flag (T/F).

      Remark The ascInit initializes the Ascii driver for subsequent use.
             RxBufSize is the size of the receive buffer as passed to
             SioReset. xFlag is used to request that XON/XOFF flow control
             be performed by the Ascii driver.

      Return =0 : No error (ASC_NO_ERROR).
             <0 : Driver error. See "Error Codes" for a list of errors.

       Other See ascStartTx and ascDriver.

      +------------+------------------------------------------------------+
      | ascStartRx | Start Ascii receive.                                 |
      +------------+------------------------------------------------------+

      Syntax function ascStartRx(ByVal FileName As String,
                                 ByVal TermChar, ByVal FirstWait,
                                 ByVal CharWait, ByVal EchoFlag) As Long
             ' Filename : File to receive
             ' TermChar : Termination character ($00 if none)
             ' FirstWait: Max seconds to wait for 1st incoming char
             ' CharWait : Max seconds between chars to wait
             ' EchoFlag : Echo to display if true

      Remark The ascStartRx starts the ASCII file receive. Once
             started, calls to ascDriver are made to execute the next state
             (or states). The ascStartTx function returns immediately.

             You may need to prompt the sender by sending a carriage return
             ($0d) or XON character ($11).
             example.

      Return =0 : No error (ASC_NO_ERROR).
             <0 : Driver error. See "Error Codes" for a list of errors.

       Other See ascStartTx and ascDriver.













     WSC4VB Reference Manual                                   Page 28

      +------------+------------------------------------------------------+
      | ascStartTx | Start Ascii transmit.                                |
      +------------+------------------------------------------------------+

      Syntax Function ascStartTx(ByVal FileName As String,
                                 ByVal CharPace, ByVal TermChar,
                                 ByVal EchoFlag) As Long
             ' Filename : File to receive
             ' CharPace : Delay in millisecs between chars
             ' TermChar : Termination character ($00 if none)
             ' EchoFlag : Echo to display if true

      Remark The ascStartTx starts the Ascii file send. Once
             started, calls to ascDriver are made to execute the next state
             (or states). The ascStartTx function returns immediately.

      Return =0 : No error (ASC_NO_ERROR).
             <0 : Driver error. See XTDRIVER.BAS for a list of errors.

       Other See ascStartRx and ascDriver.

                         ASCDRV Error Codes

      Error codes are always negative, except for 'no error'. Most of these
      error conditions rarely occur. Also note that ASCII DRIVER functions
      can return WSC errors. An error message is queued when an error
      occurs which can be retrieved with ascGetMessage.

      The numeric values for error codes can be found in AscDriver.bas.

      +------------------------+------------------------------------------+
      |           ASC_NO_ERROR | No error. (0)                            |
      |   ASC_NOT_ACTIVE_ERROR | ascInit not previously called.           |
      |  ASC_CANNOT_OPEN_ERROR | Cannot open specifed file.               |
      |      ASC_DISK_IO_ERROR | Error reading or writting disk.          |
      |     ASC_INTERNAL_ERROR | Internal error!                          |
      |     ASC_NOT_OPEN_ERROR | File not open.                           |
      +------------------------+------------------------------------------+




















     WSC4VB Reference Manual                                   Page 29

⌨️ 快捷键说明

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