General Properties
Retries number of times the message is sent to a slave before the function return an error code.
RaiseError When this property is True, the modbus server functions raise an error instead of returning an error code.
Serial Device Properties
These properties are only for local modbus (serial device) connections.
ByteSize - Specifies the number of bits in the bytes transmitted and received.
BaudRate - Specifies the baud rate
ComPort - Comm serial port
FlowControl - Specifies flow control.
Parity - Specifies the parity scheme to be used.
SilentInterval - silent interval marking the begin and the end of message in ms.
StopBits - number of stop bits.
Timeout - message timeout in ms.
TransmissionMode - Specifies RTU or ASCII transmission mode.
Open Modbus properties
These properties are only for remote modbus (TCP/IP) connections.
Host - Host name
Port - IP Port
syntax
mbusrv.Retries [= NumberofRetries%]
HRESULT Retries([out, retval] short *pVal);
HRESULT Retries([in] short newVal);
Remarks
Get/Set number of times the message is sent to a slave before the function return an error code. For instance, if Retries = 3 , when a messages is sent to a device and occur an error, that message will be sent again more 2 times.
Data Type
Integer
mbusrv.RaiseError [ = {True | False}]
HRESULT RaiseError([out, retval] VARIANT_BOOL
*pVal);
HRESULT RaiseError([in] VARIANT_BOOL newVal);
Remarks
When this property is True, the ModbusSrv raise an error instead of returning an error code. By Default this property is False.
example
Sub TestCom()
On Error Goto ComError
mbusrv.RaiseError=True
//It's not needed to verify each call for errors
mbusrv.ForceSingleCoil(17,172,True) ; //force coil 173 ON in slave device 17
mbusrv.PresetSingleRegister(17,1,3) ; //preset register 40002 to 03 in slave device 17
Exit Sub
ComError:
MsgBox " Comm Error " & Err.Description
Exit Sub
end sub
Data Type
Boolean
mbusrv.Retries [= ByteSize%]
HRESULT ByteSize([out, retval] short *pVal);
HRESULT ByteSize([in] short newVal);
Remarks
See also:
Data Type
Boolean
mbusrv.BaudRate [= BaudRate&]
HRESULT BaudRate([out, retval] long *pVal);
HRESULT BaudRate([in] long newVal);
Remarks
See also:
Data Type
Long
mbusrv.BaudRate [= ComPort%]
Remarks
See also:
Data Type
Integer
mbusrv.FlowControl [= FlowControl%]
HRESULT FlowControl([out, retval] short
*pVal);
HRESULT FlowControl([in] short newVal);
Remarks
mbFC_NONE | No Flow control |
mbFC_DTRDSR | Hardware Flow Control DTR/CTS |
mbFC_RTSCTS | Hardware Flow Control DTR/CTS |
mbFC_XONXOFF | Software Flow Control XON/XOFF |
If you use , for instance , software and hardware flow control set this member as mbFC_RTSCTS+mbFC_XONXOFF.
See also:
Data Type
Integer
mbusrv.Parity [= Parity%]
HRESULT Parity([out, retval] short *pVal);
HRESULT Parity([in] short newVal);
Remarks
Value | Meaning |
---|---|
mbEVENPARITY | Even |
mbMARKPARITY | Mark |
mbNOPARITY | No parity |
mbODDPARITY | Odd |
mbSPACEPARITY | Space |
See also:
Data Type
Integer
mbusrv.SilentInterval [= SilentInterval&]
HRESULT SilentInterval([out, retval] long
*pVal);
HRESULT SilentInterval([in] long newVal);
Remarks
Silent interval marking the begin and the end of a message in ms.
When using ASCII set silent interval 500 or 1000 ms.
See also:
Data Type
Long
mbusrv.StopBits [= StopBits%]
HRESULT StopBits([out, retval] short *pVal);
HRESULT StopBits([in] short newVal);
Remarks
Specifies the number of stop bits to be used.
Value | Meaning |
---|---|
mbONESTOPBIT | 1 stop bit |
mbONE5STOPBITS | 1.5 stop bits |
mbTWOSTOPBITS | 2 stop bits |
Use 1(ONESTOPBIT) stop bit if parity is used and 2(TWOSTOPBITS) bits if no parity.
See also:
Data Type
Integer
mbusrv.TimeOut [= TimeOut&]
HRESULT TimeOut([out, retval] long *pVal);
HRESULT TimeOut([in] long newVal);
Remarks
Time-out period for slave response in ms.
See also:
Data Type
Long
mbusrv.TransmissionMode [= TransmissionMode%]
HRESULT TransmissionMode([out, retval]
short *pVal);
HRESULT TransmissionMode([in] short newVal);
Remarks
Modbus use either of two transmission modes: ASCII or RTU. This member can be one of the values below:
mbMODE_RTU | RTU transmission mode |
mbMODE_ASCII | ASCII transmission mode |
See also:
Data Type
Integer
mbusrv.TcpPort [= TcpPort&]
HRESULT TcpPort([out, retval] long *pVal);
HRESULT TcpPort([in] long newVal);
Remarks:
Get/Set IP port. Open modbus protocol use port 502 as a default.
Data Type
Long
mbusrv.Host [= Host$]
HRESULT Host([out, retval] BSTR *pVal);
HRESULT Host([in] BSTR newVal);
Remarks:
Get/Set Host name. Can be numeric IP format like "198.345.125.30" or a name like "pep1.modicon.com".
Data Type
String