Attribute VB_Name = "Modbus_RTU"
'串口控制函数
Declare Function mbrtuComOpen Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal BaudRate As Long, ByVal DataBits As Long, ByVal Parity As String, ByVal StopBits As Long, ByVal User As String) As Long
Declare Function mbrtuComClose Lib "modbus_rtu.dll" (ByVal nport As Long) As Long
Declare Function mbrtuSetDelay Lib "modbus_rtu.dll" (ByVal value As Long) As Long
Declare Function mbrtuComTrue Lib "modbus_rtu.dll" (ByVal nport As Long) As Long
Declare Function mbrtuComWork Lib "modbus_rtu.dll" (ByVal nport As Long) As Long

'标准modbus函数
Declare Function mbrtufcn01 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn02 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn03 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn04 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn05 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal value As Long) As Long
Declare Function mbrtufcn06 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal value As Long) As Long
Declare Function mbrtufcn15 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Count As Long, TxdBuffer As Any) As Long
Declare Function mbrtufcn16 Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Count As Long, TxdBuffer As Any) As Long

'延伸modbus函数
Declare Function mbrtufcn03DInt Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal regular As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn03Float Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal regular As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn04DInt Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal regular As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn04Float Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal regular As Long, ByVal address As Long, ByVal Count As Long, RxdBuffer As Any) As Long
Declare Function mbrtufcn16DInt Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal regular As Long, ByVal address As Long, ByVal Count As Long, TxdBuffer As Any) As Long
Declare Function mbrtufcn16Float Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal regular As Long, ByVal address As Long, ByVal Count As Long, TxdBuffer As Any) As Long
Declare Function mbrtuWordBitWrite Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Bit As Long, ByVal value As Long) As Long
Declare Function mbrtuWordBitSetReset Lib "modbus_rtu.dll" (ByVal nport As Long, ByVal node As Long, ByVal address As Long, ByVal Bit As Long) As Long

'混合读写时等情况所需拓展函数
Declare Function DecBitBin Lib "modbus_rtu.dll" (ByVal value As Long, ByVal Bitaddress As Long) As Long
Declare Function Int32ToInt_16h Lib "modbus_rtu.dll" (ByVal value As Long) As Long
Declare Function Int32ToInt_16l Lib "modbus_rtu.dll" (ByVal value As Long) As Long
Declare Function Int16ToInt32 Lib "modbus_rtu.dll" (ByVal valueH As Long, ByVal valueL As Long) As Long
Declare Function Float32ToInt_16h Lib "modbus_rtu.dll" (ByVal value As Single) As Long
Declare Function Float32ToInt_16l Lib "modbus_rtu.dll" (ByVal value As Single) As Long
Declare Function Int16ToFloat32 Lib "modbus_rtu.dll" (ByVal valueH As Long, ByVal valueL As Long) As Single
