Base class which implements the Modbus server engine.
More...
Base class which implements the Modbus server engine.
This class realises the server engine. The server engines processes Modbus messages, parses the function codes and upon receipt of a valid master query it calls Data Provider methods to exchange data with the user application. For a more detailed description which Modbus data and control functions have been implemented in the server engine see section Server Functions common to all Modbus Protocol Flavours.
- See also
- Server Functions common to all Modbus Protocol Flavours
-
MbusDataTableInterface, MbusRtuSlaveProtocol, MbusAsciiSlaveProtocol, MbusTcpSlaveProtocol
◆ ~MbusSlaveServer()
Destructor.
Shuts down server, closes any associated communication resources (serial ports or sockets) and releases any resources.
◆ 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.
◆ serverLoop()
| virtual int serverLoop |
( |
| ) |
|
|
pure virtual |
◆ shutdownServer()
| virtual void shutdownServer |
( |
| ) |
|
|
pure virtual |
◆ isStarted()
| virtual int isStarted |
( |
| ) |
|
|
pure virtual |
◆ getConnectionStatus()
| int getConnectionStatus |
( |
| ) |
|
|
inline |
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 | ) |
|
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 |
( |
| ) |
|
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 |
( |
| ) |
|
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 |
( |
| ) |
|
|
inline |
Returns how often a message transfer has been executed.
- Returns
- Counter value
◆ getSuccessCounter()
| unsigned long getSuccessCounter |
( |
| ) |
|
|
inline |
Returns how often a message transfer was successful.
- Returns
- Counter value
◆ getPackageVersion()
| const TCHAR * getPackageVersion |
( |
| ) |
|
|
static |
Returns the library version number.
- Returns
- Version string