FieldTalk Modbus® Slave Library C++ Editions |
![]() |
This class realises the Modbus RTU slave protocol. It provides functions to start-up and to execute the server engine which includes opening and closing of the serial port. Upon receipt of a valid master query the server engine 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 Protocol Flavours.
It is possible to instantiate multiple instances for establishing multiple connections on different serial ports (They should be executed in separate threads).
Serial Server Management Functions | |
int | startupServer (const char *const portName, long baudRate) |
Puts the Modbus RTU server into operation and opens the associated serial port with default port parameters. | |
int | startupServer (int slaveAddr, const char *const portName, long baudRate) |
Puts the Modbus RTU server into operation and opens the associated serial port with default port parameters. | |
void | shutdownServer () |
Shuts down the Modbus server. | |
int | isStarted () |
Returns if server has been started up. | |
int | getConnectionStatus () |
Checks if a Modbus master is polling periodically. | |
virtual int | enableRs485Mode (int rtsDelay) |
Enables RS485 mode. | |
Server Management Functions | |
int | addDataTable (int slaveAddr, MbusDataTableInterface *dataTablePtr) |
Associates a protocol object with a Data Provider and a slave address. | |
Protocol Configuration | |
long | setTimeout (long timeOut) |
Configures master transmit time-out supervision. | |
long | getTimeout () |
Returns the master time-out supervision value. | |
Transmission Statistic Functions | |
unsigned long | getTotalCounter () |
Returns how often a message transfer has been executed. | |
void | resetTotalCounter () |
Resets total message transfer counter. | |
unsigned long | getSuccessCounter () |
Returns how often a message transfer was successful. | |
void | resetSuccessCounter () |
Resets successful message transfer counter. | |
Utility Functions | |
static char * | getPackageVersion () |
Returns the package version number. | |
Public Types | |
enum | { SER_DATABITS_7 = SerialPort::SER_DATABITS_7, SER_DATABITS_8 = SerialPort::SER_DATABITS_8 } |
enum | { SER_STOPBITS_1 = SerialPort::SER_STOPBITS_1, SER_STOPBITS_2 = SerialPort::SER_STOPBITS_2 } |
enum | { SER_PARITY_NONE = SerialPort::SER_PARITY_NONE, SER_PARITY_EVEN = SerialPort::SER_PARITY_EVEN, SER_PARITY_ODD = SerialPort::SER_PARITY_ODD } |
Public Member Functions | |
MbusRtuSlaveProtocol () | |
Constructs a MbusRtuSlaveProtocol object. | |
MbusRtuSlaveProtocol (MbusDataTableInterface *dataTablePtr) | |
Constructs a MbusRtuSlaveProtocol object and associates it with a Data Provider. | |
int | startupServer (const char *const portName, long baudRate, int dataBits, int stopBits, int parity) |
Puts the Modbus RTU server into operation and opens the associated serial port with specific port parameters. | |
int | startupServer (int slaveAddr, const char *const portName, long baudRate, int dataBits, int stopBits, int parity) |
Puts the Modbus RTU server into operation and opens the associated serial port with specific port parameters. | |
int | serverLoop () |
Modbus RTU slave server loop. | |
Protected Types | |
enum | { SER_RS232, SER_RS485 } |
|
|
|
|
|
|
|
|
|
Constructs a MbusRtuSlaveProtocol object. The association with a Data Provider is done after construction using the addDataTable method. |
|
Constructs a MbusRtuSlaveProtocol object and associates it with a Data Provider. Function is kept for compatibility with previous API versions, do not use for new implementations.
|
|
Puts the Modbus RTU server into operation and opens the associated serial port with specific port parameters. This function opens the serial port and initialises the server engine.
Reimplemented from MbusSerialSlaveProtocol. |
|
Puts the Modbus RTU server into operation and opens the associated serial port with specific port parameters. This function opens the serial port and initialises the server engine. Function is kept for compatibility with previous API versions, do not use for new implementations.
Reimplemented from MbusSerialSlaveProtocol. |
|
Modbus RTU slave server loop. This server loop must be called continuously. It must not be blocked. The server has to be started before calling the serverLoop() method.
Implements MbusSlaveServer. |
|
Puts the Modbus RTU server into operation and opens the associated serial port with default port parameters. This function opens the serial port with 8 databits, 1 stopbit and even parity and initialises the server engine.
|
|
Puts the Modbus RTU server into operation and opens the associated serial port with default port parameters. This function opens the serial port with 8 databits, 1 stopbit and even parity and initialises the server engine. Function is kept for compatibility with previous API versions, do not use for new implementations.
|
|
Shuts down the Modbus server. This function also closes the serial port. Reimplemented from MbusSlaveServer. |
|
Returns if server has been started up.
Implements MbusSlaveServer. |
|
Checks if a Modbus master is polling periodically.
Implements MbusSlaveServer. |
|
Enables RS485 mode. In RS485 mode the RTS signal can be used to enable and disable the transmitter of a RS232/RS485 converter. The RTS signal is asserted before sending data. It is cleared after the transmit buffer has been emptied and in addition the specified delay time has elapsed. The delay time is necessary because even the transmit buffer is already empty, the UART's FIFO will still contain unsent characters.
|
Copyright © 2002-2006
FOCUS Software Engineering Pty Ltd, Australia.
All rights reserved.
Please see the Notices page for trademark notices. Last updated: 20 Oct 2006 |