FOCUS Software Engineering has a new name: proconX - Professional Fieldbus Connections   

Server Functions common to all Protocol Flavours


Detailed Description

The FieldTalk Modbus Slave Protocol Library's server engine implements the most commonly used Modbus data functions as well as some control functions. The functions to perform PLC program download and other device specific functions are outside the scope of this library.

All functions of conformance Class 0 and Class 1 have been implemented. In addition the most frequent used functions of conformance Class 2 have been implemented.

The following table lists the functions supported by the slave:

Function CodeCurrent Terminology Classic Terminology
Conformance Class 0
3 (03 hex)Read Multiple Registers Read Holding Registers
16 (10 hex)Write Multiple Registers Preset Multiple Registers
Conformance Class 1
1 (01 hex)Read CoilsRead Coil Status
2 (02 hex)Read Inputs Discretes Read Input Status
4 (04 hex)Read Input Registers Read Input Registers
5 (05 hex)Write CoilForce Single Coil
6 (06 hex)Write Single Register Preset Single Register
7 (07 hex)Read Exception Status Read Exception Status
Conformance Class 2
15 (0F hex)Force Multiple Coils Force Multiple Coils
22 (16 hex)Mask Write Register Mask Write Register
23 (17 hex)Read/Write Registers Read/Write Registers


Server Management Functions

virtual int MbusSlaveServer::serverLoop ()=0
 Modbus slave server loop.

virtual void MbusSlaveServer::shutdownServer ()
 Shuts down the Modbus Server.

virtual int MbusSlaveServer::isStarted ()=0
 Returns wether server has been started up.


Protocol Configuration

long MbusSlaveServer::setTimeout (long timeOut)
 Configures master time-out supervision.

long MbusSlaveServer::getTimeout ()
 Returns the master time-out supervision value.


Transmission Statistic Functions

unsigned long MbusSlaveServer::getTotalCounter ()
 Returns how often a message transfer has been executed.

void MbusSlaveServer::resetTotalCounter ()
 Resets total message transfer counter.

unsigned long MbusSlaveServer::getSuccessCounter ()
 Returns how often a message transfer was successful.

void MbusSlaveServer::resetSuccessCounter ()
 Resets successful message transfer counter.


Utility Functions

char * MbusSlaveServer::getPackageVersion ()
 Returns the package version number.


Function Documentation

virtual int serverLoop  )  [pure virtual, inherited]
 

Modbus 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.

In most cases the server loop is executed in an endless loop:

 while (1)
 {
   mbusProtocol.serverLoop();
   doOtherStuff();
 }

Returns:
FTALK_SUCCESS on success or error code. See Protocol Errors and Exceptions for a list of error codes.

Implemented in MbusRtuSlaveProtocol, MbusAsciiSlaveProtocol, and MbusTcpSlaveProtocol.

long setTimeout long  timeOut  )  [inherited]
 

Configures master time-out supervision.

The slave is monitoring whether a master is actually polling it or not. This function sets the master poll 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.

Remarks:
The time-out value is indicative only and not guaranteed to be maintained. How precise it is followed depends on the operating system used, it's scheduling priority and it's system timer resolution.
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

unsigned long getTotalCounter  )  [inherited]
 

Returns how often a message transfer has been executed.

Returns:
Counter value

char * getPackageVersion  )  [static, inherited]
 

Returns the package version number.

Returns:
Package version string

long getTimeout  )  [inherited]
 

Returns the master time-out supervision value.

Remarks:
The time-out value is indicative only and not guaranteed to be maintained. How precise it is followed depends on the operating system used, it's scheduling priority and it's system timer resolution.
Returns:
Timeout value in ms

unsigned long getSuccessCounter  )  [inherited]
 

Returns how often a message transfer was successful.

Returns:
Counter value

void shutdownServer  )  [virtual, inherited]
 

Shuts down the Modbus Server.

This function also closes any associated serial ports or sockets.

Reimplemented in MbusSerialSlaveProtocol, and MbusTcpSlaveProtocol.

virtual int isStarted  )  [pure virtual, inherited]
 

Returns wether server has been started up.

Return values:
true = started
false = shutdown

Implemented in MbusSerialSlaveProtocol, and MbusTcpSlaveProtocol.

   Back | Top of page Info | Support | Contact | About   
Information in this document is subject to change without notice. Copyright © 2000-2010 proconX Pty Ltd. All rights reserved.
All product and brand names mentioned on this page may be trademarks or registered trademarks of their respective owners.