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

📄 mdlcommunicate.bas

📁 RS485文件传送程序
💻 BAS
字号:
Attribute VB_Name = "mdlCommunicate"

Option Explicit

Public Declare Function timeGetTime Lib "winmm.dll" () As Long


'********************** BaudRate Setting ****************************************************
Public Const B50 = &H0
Public Const B75 = &H1
Public Const B110 = &H2
Public Const B134 = &H3
Public Const B150 = &H4
Public Const B300 = &H5
Public Const B600 = &H6
Public Const B1200 = &H7
Public Const B1800 = &H8
Public Const B2400 = &H9
Public Const B4800 = &HA
Public Const B7200 = &HB
Public Const B9600 = &HC
Public Const B19200 = &HD
Public Const B38400 = &HE
Public Const B57600 = &HF
Public Const B115200 = &H10
Public Const B230400 = &H11
Public Const B460800 = &H12
Public Const B921600 = &H13

'*********************** Mode Setting ****************************************************
'Data bits define (数据位定义)
Public Const BIT_5 = &H0
Public Const BIT_6 = &H1
Public Const BIT_7 = &H2
Public Const BIT_8 = &H3

'Stop bits define (停止位定义)
Public Const STOP_1 = &H0
Public Const STOP_2 = &H4

'Parity define (奇偶效验位定义)
Public Const P_EVEN = &H18
Public Const P_ODD = &H8
Public Const P_SPC = &H38
Public Const P_MRK = &H28
Public Const P_NONE = &H0

'*********************** Modem Control Setting ****************************************
Public Const C_DTR = &H1
Public Const C_RTS = &H2

'*********************** Modem Line Status *********************************************
Public Const S_CTS = &H1
Public Const S_DSR = &H2
Public Const S_RI = &H4
Public Const S_CD = &H8

'*********************** Error Code *****************************************************
Public Const SIO_OK = 0
Public Const SIO_BADPORT = -1        ' no such port or port not opened
Public Const SIO_OUTCONTROL = -2     ' can't control AdvanTech board
Public Const SIO_NODATA = -4         ' no data to read or no buffer to write
Public Const SIO_BADPARM = -7        ' bad parameter
Public Const SIO_WIN32FAIL = -8      ' win32 function call fails, please call

'*********************** Api定义(用于数据的收送) *********************************************************************************************
Public Declare Function sio_ioctl Lib "api232.dll" (ByVal Port As Long, ByVal baud As Long, ByVal mode As Long) As Long
Public Declare Function sio_getch Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_read Lib "api232.dll" (ByVal Port As Long, ByVal buf As String, ByVal length As Long) As Long
Public Declare Function sio_putch Lib "api232.dll" (ByVal Port As Long, ByVal term As Long) As Long
Public Declare Function sio_write Lib "api232.dll" (ByVal Port As Long, ByVal buf As String, ByVal length As Long) As Long
Public Declare Function sio_flush Lib "api232.dll" (ByVal Port As Long, ByVal func As Long) As Long
Public Declare Function sio_iqueue Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_oqueue Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_lstatus Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_lctrl Lib "api232.dll" (ByVal Port As Long, ByVal mode As Long) As Long
Public Declare Function sio_break Lib "api232.dll" (ByVal Port As Long, ByVal time As Long) As Long
Public Declare Function sio_flowctrl Lib "api232.dll" (ByVal Port As Long, ByVal mode As Long) As Long
Public Declare Function sio_Tx_hold Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_close Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_open Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_getbaud Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_getmode Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_getflow Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_DTR Lib "api232.dll" (ByVal Port As Long, ByVal mode As Long) As Long
Public Declare Function sio_RTS Lib "api232.dll" (ByVal Port As Long, ByVal mode As Long) As Long
Public Declare Function sio_baud Lib "api232.dll" (ByVal Port As Long, ByVal speed As Long) As Long
Public Declare Function sio_data_status Lib "api232.dll" (ByVal Port As Long) As Long
Public Declare Function sio_putb Lib "api232.dll" Alias "sio_write" (ByVal Port As Long, ByVal buf As String, ByVal length As Long) As Long
Public Declare Function sio_linput Lib "api232.dll" (ByVal Port As Long, ByVal buf As String, ByVal length As Long, ByVal term As Long) As Long
Public Declare Function sio_putb_x Lib "api232.dll" (ByVal Port As Long, ByVal buf As String, ByVal length As Long, ByVal tick As Long) As Long
Public Declare Function sio_view Lib "api232.dll" (ByVal Port As Long, ByVal buf As String, ByVal length As Long) As Long

⌨️ 快捷键说明

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