Base class for all IP based Slave Protocol classes.
More...
|
| virtual int | startupServer () |
| | Puts the Modbus server into operation. More...
|
| |
|
virtual int | startupServer (const char *const hostName)=0 |
| |
| virtual void | shutdownServer () |
| | Shuts down the Modbus server. More...
|
| |
| virtual int | serverLoop ()=0 |
| | Modbus slave server loop. More...
|
| |
| int | isStarted () |
| | Returns whether server has been started up. More...
|
| |
| int | setPort (unsigned short portNo) |
| | Sets the TCP port number to be used by the protocol. More...
|
| |
|
void | installIpAddrValidationCallBack (int(*f)(const char *masterIpAddrSz)) |
| |
| void | installIpAddrValidationCallBack (int(*f)(void *userData, const char *masterIpAddrSz), void *userData) |
| | This function installs a callback handler for validating a master's IP address. More...
|
| |
|
void | installMasterPollNotifyCallBack (int(*f)(const char *masterIpAddrSz)) |
| |
| void | installMasterPollNotifyCallBack (int(*f)(void *userData, const char *masterIpAddrSz), void *userData) |
| | This function installs a callback handler to be called everytime a master polls this slave and allows a forced closure of the master connection by returning 0. More...
|
| |
| unsigned short | getPort () |
| | Returns the TCP port number used by the protocol. More...
|
| |
Base class for all IP based Slave Protocol classes.
This class is a base class for the various flavours of IP based protocols.
- See also
- Server Functions common to all Modbus Protocol Flavours, IP based Protocols
◆ startupServer()
Puts the Modbus server into operation.
The server accepts connections on any interface.
This function opens a TCP/IP socket, binds the configured TCP port to the Modbus/TCP protocol and initialises the server engine.
- Note
- If the configured TCP port is below IPPORT_RESERVED (usually 1024), the process has to run with root privilege!
- Returns
- FTALK_SUCCESS on success or error code. See Error Management for a list of error codes.
Reimplemented in MbusTcpSlaveProtocol, and MbusUdpSlaveProtocol.
◆ shutdownServer()
◆ serverLoop()
| virtual int serverLoop |
( |
| ) |
|
|
pure virtual |
◆ isStarted()
Returns whether server has been started up.
- Return values
-
| true | = started |
| false | = shutdown |
Implements MbusSlaveServer.
◆ setPort()
| int setPort |
( |
unsigned short |
portNo | ) |
|
Sets the TCP port number to be used by the protocol.
- Note
- If the configured TCP port is below IPPORT_RESERVED (usually 1024), the process has to run with root or administrator privilege!
-
This parameter must be set before starting the server in order to come into effect.
- Parameters
-
| portNo | Port number the server shall listen on |
- Return values
-
| FTALK_SUCCESS | Success |
| FTALK_ILLEGAL_STATE_ERROR | Server already running |
References FTALK_ILLEGAL_STATE_ERROR, FTALK_SUCCESS, and isStarted().
◆ installIpAddrValidationCallBack()
| void installIpAddrValidationCallBack |
( |
int(*)(void *userData, const char *masterIpAddrSz) |
f, |
|
|
void * |
userData |
|
) |
| |
This function installs a callback handler for validating a master's IP address.
Pass a pointer to a function with checks a master's IP address and either accepts or rejects a master's connection.
- Parameters
-
| f | Callback function pointer |
| userData | A void pointer which is passed as argument to the callback. |
- Returns
- Returns 1 to accept a connection or 0 to reject it.
◆ installMasterPollNotifyCallBack()
| void installMasterPollNotifyCallBack |
( |
int(*)(void *userData, const char *masterIpAddrSz) |
f, |
|
|
void * |
userData |
|
) |
| |
This function installs a callback handler to be called everytime a master polls this slave and allows a forced closure of the master connection by returning 0.
This routine can be used to implement custom time-out mechanisms.
- Parameters
-
| f | Callback function pointer |
| userData | A void pointer which is passed as argument to the callback. |
- Returns
- Returns 1 to process the poll or 0 to reject and drop the connection.
◆ getPort()
| unsigned short getPort |
( |
| ) |
|
|
inline |
Returns the TCP port number used by the protocol.
- Returns
- Port number used by the protocol
◆ addDataTable()
Associates a protocol object with a Data Provider and a Modbus slave ID.
- Parameters
-
| slaveAddr | Modbus slave address for server to listen on (-1 - 255). 0 is regarded as a valid value for a MODBUS/TCP server address. A value of -1 means the server disregards the slave address and listens to all slave addresses. 0 or -1 is only valid for MODBUS/TCP! |
| dataTablePtr | Modbus data table pointer. Must point to a Data Provider object derived from the MbusDataTableInterface class. The Data Provider is the interface between your application data and the Modbus network. |
- Returns
- FTALK_SUCCESS on success or error code. See Error Management for a list of error codes.
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
◆ getConnectionStatus()
| int getConnectionStatus |
( |
| ) |
|
|
inlineinherited |
Checks if a Modbus master is polling periodically.
- Return values
-
| true | = A master is polling at a frequency higher than the master transmit time-out value |
| false | = No master is polling within the time-out period |
- Note
- The master transmit time-out value must be set > 0 in order for this function to work.
◆ setTimeout()
| int setTimeout |
( |
long |
timeOut | ) |
|
|
inherited |
Configures master activity time-out supervision.
The slave can monitor whether a master is actually polling or not. This function sets the activity time-out to the specified value. A value of 0 disables the time-out, which stops time-out notifications being sent to the Data Provider. Default value is 1000 ms.
- Note
- The time-out does not check whether a master is sending valid frames. The transmission of characters is sufficient to avoid the time-out.
- Parameters
-
| timeOut | Timeout value in ms (Range: 0 - 100000), 0 disables time-out |
- Return values
-
| FTALK_SUCCESS | Success |
| FTALK_ILLEGAL_ARGUMENT_ERROR | Argument out of range |
References FTALK_ILLEGAL_ARGUMENT_ERROR, and FTALK_SUCCESS.
◆ getTimeout()
Returns the currently set master activity time-out value.
- Returns
- Timeout value in ms
◆ disableExceptionReplies()
| void disableExceptionReplies |
( |
| ) |
|
|
inherited |
Supress exception replies to be sent.
With this option only positive replies are sent to the master. All failure replies are silently discarded. This option can be useful if redundant Modbus devices are used. In this scenario supressing the reply would trigger a swap-over of the redundant devices.
◆ enableExceptionReplies()
| void enableExceptionReplies |
( |
| ) |
|
|
inherited |
Enables exception replies after they have been turned off.
Sending exception replies in case of slave failures is the normal mode of operation.
◆ getTotalCounter()
| unsigned long getTotalCounter |
( |
| ) |
|
|
inlineinherited |
Returns how often a message transfer has been executed.
- Returns
- Counter value
◆ getSuccessCounter()
| unsigned long getSuccessCounter |
( |
| ) |
|
|
inlineinherited |
Returns how often a message transfer was successful.
- Returns
- Counter value
◆ getPackageVersion()
| const TCHAR * getPackageVersion |
( |
| ) |
|
|
staticinherited |
Returns the library version number.
- Returns
- Version string